Long story short, I am using this BME280 library which utilizes the GPIO one. Every thing seems to be working great, except that after extended use, I get this fun little error:
Traceback (most recent call last):
File "Skynet/main.py", line 8, in <module>
from bme import ReadTPH
File "/home/pi/Skynet/bme.py", line 9, in <module>
sensor = BME280(mode=BME280_OSAMPLE_8)
File "/home/pi/Skynet/Adafruit_BME280.py", line 90, in __init__
self._load_calibration()
File "/home/pi/Skynet/Adafruit_BME280.py", line 96, in _load_calibration
self.dig_T1 = self._device.readU16LE(BME280_REGISTER_DIG_T1)
File "/usr/local/lib/python2.7/dist-packages/Adafruit_GPIO-1.0.3-py2.7.egg/Adafruit_GPIO/I2C.py", line 185, in readU16LE
return self.readU16(register, little_endian=True)
File "/usr/local/lib/python2.7/dist-packages/Adafruit_GPIO-1.0.3-py2.7.egg/Adafruit_GPIO/I2C.py", line 164, in readU16
result = self._bus.read_word_data(self._address,register) & 0xFFFF
File "/usr/local/lib/python2.7/dist-packages/Adafruit_PureIO-0.2.1-py2.7.egg/Adafruit_PureIO/smbus.py", line 173, in read_word_data
ioctl(self._device.fileno(), I2C_RDWR, request)
IOError: [Errno 121] Remote I/O error
Now, I can of course catch this with try-except, but what I cannot do is resolve it. There must be a way? The only thing that currently works is unhooking the vin to "reboot" the sensor. Is there a way to do this programmatically? Once this in the final design, I can't tell the user: "unplug this cable when it breaks hur dur"
Any pointers would be greatly appreciated!
EDIT: According to Adafruit, I can force a reset:
You can force a reset by writing 0xB6 to register 0xE0
However, I have no idea how to do that with the libraries at hand.