remix7196
Posts: 10
Joined: Sun Apr 09, 2017 4:48 pm

Frequent but inconsistent i2c errors

Thu Jun 08, 2017 8:40 pm

Hello, community! I'm currently running Node.js and I have a HTU21D-F sensor hooked up through i2c on a Pi 3.

i2cdetect sees the address correctly, and I have a JavaScript file that runs and updates a dashboard (Blynk) that works perhaps once every 10-15 attempts, but more often than not it will throw any one of the following three errors:

Code: Select all

Error: Cannot write to device
  at i2c.writeByte (/home/pi/node_modules/i2c/lib/i2c.coffee:58:10)
  at htu21d.readTemperature (/home/pi/node_modules/htu21d-i2c/index.js:70:14)
  at Timeout._onTimeout (/home/pi/blynk1.js:26:9)
  at ontimeout (timers.js:386:14)
  at tryOnTimeout (timers.js:250:5)
  at Timer.listOnTimeout (timers.js:214:5)

Error: Cannot write to device
  at i2c.writeByte (/home/pi/node_modules/i2c/lib/i2c.coffee:58:10)
  at htu21d.readHumidity (/home/pi/node_modules/htu21d-i2c/index.js:97:14)
  at /home/pi/blynk1.js:29:13
  at /home/pi/node_modules/htu21d-i2c/index.js:86:29
  at Immediate.<anonymous> (/home/pi/node_modules/i2c/lib/i2c.coffee:73:9)
  at runCallback (timers.js:672:20)
  at tryOnImmediate (timers.js:645:5)
  at processImmediate [as _immediateCallback] (timers.js:617:5)


Error: Cannot read from device
  at i2c.read (/home/pi/node_modules/i2c/lib/i2c.coffee:71:10)
  at Timeout._onTimeout (/home/pi/node_modules/htu21d-i2c/index.js:77:26)
  at ontimeout (timers.js:386:14)
  at tryOnTimeout (timers.js:250:5)
  at Timer.listOnTimeout (timers.js:214:5)
I'd be happy to supply any of the code, but does anyone have any idea what could be happening just based on this? Thanks in advance!

User avatar
joan
Posts: 14960
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Frequent but inconsistent i2c errors

Thu Jun 08, 2017 8:43 pm

The software will be using the standard Linux I2C driver which is reliable.

I'd concentrate on checking the wiring.

Return to “Troubleshooting”