fivdi / i2c-bus

I2C serial bus access with Node.js
MIT License
348 stars 57 forks source link

i'm getting lots of "Error: , Remote I/O error" #36

Closed nielsnl68 closed 7 years ago

nielsnl68 commented 7 years ago

Hello,

lately i created a set of node-red nodes with your library as basis. And everything works very well most of the time. Except i'm getting "Error: , Remote I/O error" error sometimes. I use node-red on a Raspberry Pi3 connected to a couple of arduino's.

Not sure where the issue is coming from.

fivdi commented 7 years ago

All variants of the Raspberry Pi have an I2C hardware bug which prevents I2C clock stretching from functioning correctly. A symptom of this bug is "remote I/O errors". To avoid this issue do not use I2C devices which stretch the I2C clock with a Raspberry Pi.

Arduino UNOs are not particularly fast and it's relatively easy to implement code that is not fast enough to prevent an Arduino UNO from stretching the I2C clock.

I would imagine that you are seeing this issue here.

The default baudrate on the raspberry Pi is 100000. It can be lowered to 10000 by adding the following line to /boot/config.txt and rebooting the Pi.

dtparam=i2c_baudrate=10000

Give this a try to see if it helps.

If it does help you could increase the baudrate bit by bit to determine what the max baudrate is that functions correctly.

An alternative would be to catch the error and retry.

fivdi commented 7 years ago

There's no todo for i2c-bus here so I'll go ahead and close the issue.

emilbayes commented 7 years ago

This issue helped me too. Thanks!

fivdi commented 6 years ago

If you are having issues communicating with an I2C device connected to a Raspberry Pi and the issues are related to the hardware I2C clock stretching bug consider using software I2C rather than hardware I2C. See Configuring Software I2C on the Raspberry Pi for further details.

msi-matthew commented 6 years ago

@fivdi Do you have an example of the a catch/retry?

fivdi commented 6 years ago

There's an example using try/catch in i2cscan.js. The example doesn't retry but that shouldn't be too difficult to figure out using the example as a starting point.