nophead/EnviroPlusWeb

Remote I/O error

Closed this issue · 7 comments

I am seeing the following error on 3 different enviroplus_pi0s after several hours of operation. Restart of the python script fixes things. Any way to make this error better with a try-except ?

init__.py", line 467, in update_sensor
   self._ps0 = self._ltr559.get('PS_DATA').ch0
 File "/usr/local/lib/python3.7/dist-packages/i2cdevice-0.0.7-py3.7.egg/i2cdevice/__init__.py", line 230, in get
   self.read_register(register)
 File "/usr/local/lib/python3.7/dist-packages/i2cdevice-0.0.7-py3.7.egg/i2cdevice/__init__.py", line 183, in read_register
   self.values[register.name] = self._i2c_read(register.address, register.bit_width)
 File "/usr/local/lib/python3.7/dist-packages/i2cdevice-0.0.7-py3.7.egg/i2cdevice/__init__.py", line 288, in _i2c_read
   for x in self._i2c.read_i2c_block_data(self._i2c_address, register, bit_width // self._bit_width):
OSError: [Errno 121] Remote I/O error

Perhaps because you have the board connected with an extension cable. I don't get any errors in more than a year of operation of two units.

@nophead
None of the boards exhibiting this issue are connected with an extension cable. Your comment above made me want to give you yet another data point. I have hooked up an external i2c sensor the sensirion scd30 (https://www.sensirion.com/en/environmental-sensors/carbon-dioxide-sensors/carbon-dioxide-sensors-scd30/) to the enviroplus

The boards exhibiting this issue after several houurs of operation all have the scd30 whereas another board without the scd30 is not encountering any problems

Could it be bus contention or collision due to timing and three different scripts all trying to access various i2c sensors independently?

Traceback (most recent call last):
  File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.7/threading.py", line 865, in run
    self._target(*self._args, **self._kwargs)
  File "app_mqtt.py", line 249, in background
    record = read_data(t)
  File "app_mqtt.py", line 154, in read_data
    gases = gas.read_all()
  File "/usr/local/lib/python3.7/dist-packages/enviroplus-0.0.3-py3.7.egg/enviroplus/gas.py", line 82, in read_all
    nh3 = adc.get_voltage('in2/gnd')
  File "/usr/local/lib/python3.7/dist-packages/ads1015-0.0.6-py3.7.egg/ads1015/__init__.py", line 278, in get_voltage
    self.set_multiplexer(channel)
  File "/usr/local/lib/python3.7/dist-packages/ads1015-0.0.6-py3.7.egg/ads1015/__init__.py", line 176, in set_multiplexer
    self._ads1015.set('CONFIG', multiplexer=value)
  File "/usr/local/lib/python3.7/dist-packages/i2cdevice-0.0.7-py3.7.egg/i2cdevice/__init__.py", line 215, in set
    self.read_register(register)
  File "/usr/local/lib/python3.7/dist-packages/i2cdevice-0.0.7-py3.7.egg/i2cdevice/__init__.py", line 183, in read_register
    self.values[register.name] = self._i2c_read(register.address, register.bit_width)
  File "/usr/local/lib/python3.7/dist-packages/i2cdevice-0.0.7-py3.7.egg/i2cdevice/__init__.py", line 288, in _i2c_read
    for x in self._i2c.read_i2c_block_data(self._i2c_address, register, bit_width // self._bit_width):
OSError: [Errno 121] Remote I/O error

Yes if you have more than one script accessing the same I2C bus I would expect it to get contention unless it is going through a driver that guards against that by using some form of thread locking.

@nophead ,
Would it be possible for you to put a try-except for each of the i2c reads in the while loop so that one failed i2c-read doesn't bring the whole app.py flow to a standstill ?

I don't like to code around hardware problems. I2C should never fail. It is an inter IC bus designed to link chips on the same board where signals are assumed to be 100% reliable.

If you have bus contention anything could happen. You might read bad values. Can you put the other devices on another bus?

@nophead
I have noted your reluctance and I concur .

Thanks