i2c problem

Hello Adrian!

Sunday January 27 2019 17:19, you wrote to All:

Have you run raspi-config to set up the hardware and interface ?

See option P5

Must be run as root (or via sudo).

Vince

Reply to
Vince Coen
Loading thread data ...

I'm having problems with i2c, and after a couple of hours trying all the options that Google throws up, I'm stumped.

Pi 3 4.14.79-v7+

sudo i2cdetect -y 1 Error: could not open file '/dev/i2c/1': No such file or directory

cat /etc/modules i2c-bcm2708 i2c-dev

tail /boot/config.txt

dtparam=i2c=on dtparam=i2c_arm=on dtparam=i2c_vc device_tree_param=i2c=on1=on dtparam=spi=on dtparam=i2s=on

/etc/modprobe.d/raspi-blacklist.conf is empty

Any suggestions ?

TIA

Adrian

--
To Reply : 
replace "bulleid" with "adrian" - all mail to bulleid is rejected 
Sorry for the rigmarole, If I want spam, I'll go to the shops 
Every time someone says "I don't believe in trolls", another one dies.
Reply to
Adrian

Is this an original model B with 256MB of RAM? If so it only has bus 0.

---druck

Reply to
druck

What does "i2cdetect -l" show?

--
Lew Pitcher 
"In Skills, We Trust"
Reply to
Lew Pitcher

On a sunny day (Sun, 27 Jan 2019 17:19:34 +0000) it happened Adrian wrote in :

Well, I use a lot of i2c also on raspberry, and I use a C library for that do the I/O not via the dedicated pins but via any pin I want. I2c is largely time insensitive (as for example to a task switch) so it always works. Want the library? I can publish the c code here. I use actualy 3 pins, scl (output), sda_in (input), and sda_pulldown (output via pulldown diode connected to sda line). If you scroll down on this page you see a circuit diagram with 2 separate i2c busses:

formatting link
actualy the library is the .tgz link at the bottom of the page. Saved time, uses a hundred of more times...

All assuming you know C.and hardware.

Reply to
Jan Panteltje

Pi 3 with 1GB

Adrian

--
To Reply : 
replace "bulleid" with "adrian" - all mail to bulleid is rejected 
Sorry for the rigmarole, If I want spam, I'll go to the shops 
Every time someone says "I don't believe in trolls", another one dies.
Reply to
Adrian

i2c-0 i2c bcm2835 I2C adapter I2C adapter

Adrian

--
To Reply : 
replace "bulleid" with "adrian" - all mail to bulleid is rejected 
Sorry for the rigmarole, If I want spam, I'll go to the shops 
Every time someone says "I don't believe in trolls", another one dies.
Reply to
Adrian

Hello Vince,

Yes, with several reboots afterwards.

Adrian

-- To Reply : replace "bulleid" with "adrian" - all mail to bulleid is rejected Sorry for the rigmarole, If I want spam, I'll go to the shops Every time someone says "I don't believe in trolls", another one dies.

Reply to
Adrian

It's interesting, I've never user i2c on my RPi (3+) but after enabling it via raspi-config (didn't reboot) I have /dev/i2c-1 but not /dev/i2c/1. So why the difference?

Why i2c-bcm2708? I have only i2c-dev in /etc/modules. i2c-bcm2708 isn't loaded but i2c-bcm2835 is.

Of these I have only dtparam=i2c_arm=on.

Reply to
Anssi Saari

I have /dev/i2c-0

I've added i2c-bcm2835 (and rebooted), and still no luck.

Adrian

--
To Reply : 
replace "bulleid" with "adrian" - all mail to bulleid is rejected 
Sorry for the rigmarole, If I want spam, I'll go to the shops 
Every time someone says "I don't believe in trolls", another one dies.
Reply to
Adrian

First thing I'd suggest you try would be 'sudo i2cdetect -y 0'. Don't know why, but that sure seems to be indicated.

Reply to
ray carter

Thanks.

That works. I get blanks in the first three cells, and the last 8 cells, otherwise it is "--".

Adrian

--
To Reply : 
replace "bulleid" with "adrian" - all mail to bulleid is rejected 
Sorry for the rigmarole, If I want spam, I'll go to the shops 
Every time someone says "I don't believe in trolls", another one dies.
Reply to
Adrian

In message , Adrian writes

A bit more digging.

I'm trying to listen to a BME280 sensor (temperature, pressure and humidity), and there is some Python code available to do so. That uses /dev/i2c/1, however, if I alter the code slightly, and tell it to use a different port (so it points to /dev/i2c-0), I get a different error (no great surprise) :

Traceback (most recent call last): File "bme280_sensor.py", line 9, in bme280.load_calibration_params(bus, address) File "/usr/local/lib/python3.5/dist-packages/bme280/__init__.py", line

155, in load_calibration_params compensation_params.dig_T1 = read.unsigned_short(0x88) File "/usr/local/lib/python3.5/dist-packages/bme280/reader.py", line 40, in unsigned_short return self._bus.read_word_data(self._address, register) & 0xffff File "/usr/local/lib/python3.5/dist-packages/smbus2/smbus2.py", line 410, in read_word_data ioctl(self.fd, I2C_SMBUS, msg) OSError: [Errno 121] Remote I/O error

sudo i2cdetect -y 0 gives me :

0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --

So, does that suggest that the bus is working, or that that I've got the right bus, but there is no data or what ?

Thanks

Adrian

--
To Reply : 
replace "bulleid" with "adrian" - all mail to bulleid is rejected 
Sorry for the rigmarole, If I want spam, I'll go to the shops 
Every time someone says "I don't believe in trolls", another one dies.
Reply to
Adrian
[Snip]

It looks like the internal i2c bus 0 is enabled, and not the external bus 1, which your sensor will be connected to.

Try going back to a stock config.txt and cmdline.txt from a Raspbian image, reboot, use raspi-config to enable i2c, reboot again.

---druck

Reply to
druck

Thanks.

I've done that, and now I get /dev/i2c-1 present (but not 0 !)

Running the python code, I now get readings from the sensors.

Problem resolved. Many thanks to those who've contributed.

Adrian

--
To Reply : 
replace "bulleid" with "adrian" - all mail to bulleid is rejected 
Sorry for the rigmarole, If I want spam, I'll go to the shops 
Every time someone says "I don't believe in trolls", another one dies.
Reply to
Adrian

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.