WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: i2c  (Read 3878 times)

Offline CharlieDelta

  • Newbie
  • *
  • Posts: 8
i2c
« on: October 15, 2020, 09:30:35 AM »
OK I am here again and this time I would like some help getting RPi i2c bus working using Python.
I understand I need an extension (I think) that involves i2c tools and smbus. I looked at various searches on this forum for i2c and smbus and it looks like I should have to hand something like "....python-smbus.tcz added to repo"
[care of suicidal_orange. Re: python smbus extension? « Reply #5 on: April 20, 2014, 06:04:50]
but the Apps prog does not reveal anything to do with smbus or i2c
 
Any assistance would be gratefully received
BTW I am running piCore 11.0 and Python 3.8 and RPi 1B (2012)

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1063
Re: i2c
« Reply #1 on: October 15, 2020, 09:46:19 AM »
You will likely need to load the i2c-dev kernel module manually.


Offline CharlieDelta

  • Newbie
  • *
  • Posts: 8
Re: i2c
« Reply #2 on: October 16, 2020, 04:16:48 AM »
Thank you Paul

Offline silvio

  • Newbie
  • *
  • Posts: 8
Re: i2c
« Reply #3 on: September 08, 2021, 07:41:34 AM »
Thank you Paul for all your efforts
sudo modprobe i2c-dev works and creates my desired /dev/i2c-1 and i2cdecect -y 1 works as well.
Besides of loading i2c-dev manually, Is there an other way to create the /dev/i2c-1 entry?

Silvio

Offline vincenthure

  • Newbie
  • *
  • Posts: 16
Re: i2c
« Reply #4 on: December 11, 2021, 08:42:59 AM »
Hello,

my setup is
pi 2W
MPU 9250
tiny linux piCore 13.1.0
RTIMUlib2

In my python file when imu.IMURead() I get (0,0,0) !
in CLI when  i2cdetect -y 1 I get Error: Could not open file `/dev/i2c-1'

I try sudo modprobe i2c-dev, but it change nothing.
Thank you, I somebody can help me to see my IMU device.

Offline vincenthure

  • Newbie
  • *
  • Posts: 16
Re: i2c
« Reply #5 on: December 17, 2021, 01:03:29 PM »
I am stuck since one week!

sudo modprobe i2c-bcm2835
sudo modprobe i2c-dev
i2cdetect -y 1
And I get always this :
Error: Could not open file `/dev/i2c-1' or `/dev/i2c/1': No such file or directory

When modinfo i2c_dev
filename:       /lib/modules/5.10.77-piCore-v7/kernel/drivers/i2c/i2c-dev.ko.gz
author:         Simon G. Vogl <simon@tk.uni-linz.ac.at>
author:         Frodo Looijaard <frodol@dds.nl>
description:    I2C /dev entries driver
license:        GPL
srcversion:     FAA806EAA87DC7C27E86ABB
depends:       
intree:         Y
vermagic:       5.10.77-piCore-v7 SMP mod_unload modversions ARMv7 p2v8

What's wrong?
They is some specilal driver for the PI zero 2W?

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1063
Re: i2c
« Reply #6 on: December 19, 2021, 05:44:36 AM »
Is the bus enabled in your config.txt?

Offline vincenthure

  • Newbie
  • *
  • Posts: 16
Re: i2c
« Reply #7 on: December 19, 2021, 02:08:05 PM »
I don' make a config.txt file !
To enable the i2c Bus, I saw that this file should contain :
dtparam=i2c_arm=on
Is it right?

Where should I put this file?
I try in  /mnt/mmcblk0p1 but it disapear on reboot!

I would like to access to the wiki but I can't "Permission Denied" with login/password of the forum.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: i2c
« Reply #8 on: December 19, 2021, 02:14:31 PM »
Hi vincenthure
If you mount  mmcblk0p1  you should find it there.

Offline vincenthure

  • Newbie
  • *
  • Posts: 16
Re: i2c
« Reply #9 on: December 21, 2021, 04:21:58 AM »
Thank for your help.
I finaly see my IMU on the i2C bus  ;D

Offline vincenthure

  • Newbie
  • *
  • Posts: 16
Re: i2c
« Reply #10 on: December 22, 2021, 09:27:40 AM »
My IMU is now working well
I have one more question :
I can get the data only when I call my program with sudo.
Is it possible to get the data without the admin mode?

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: i2c
« Reply #11 on: December 22, 2021, 10:01:59 AM »
Hi vincenthure
You could try adjusting the ownership of  /dev/i2c-1:
Code: [Select]
sudo chown root:staff /dev/i2c-1

Offline vincenthure

  • Newbie
  • *
  • Posts: 16
Re: i2c
« Reply #12 on: December 27, 2021, 02:14:33 PM »
Thank you
So easy when somebody explain for you!

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: i2c
« Reply #13 on: December 27, 2021, 02:17:17 PM »
Hi vincenthure
You are welcome. :) Glad I could help.