i2c fails on raspberry pi
brennen opened this issue · 7 comments
With latest release from PyPI, on Raspberry Pi 3 model B:
(blinkenlight) pi@raspberrypi:~/blinkenlight $ cat bme680.py
import board
import busio
import time
import adafruit_bme680
# Initialize I2C bus and create sensor instance.
i2c = busio.I2C(board.SCL, board.SDA)
sensor = adafruit_bme680.Adafruit_BME680_I2C(i2c)
# Main loop prints sensor values every second.
while True:
print('Temperature: {} degrees C'.format(sensor.temperature))
print('Gas: {} ohms'.format(sensor.gas))
print('Humidity: {}%'.format(sensor.humidity))
print('Pressure: {}hPa'.format(sensor.pressure))
time.sleep(1.0)
(blinkenlight) pi@raspberrypi:~/blinkenlight $ python3 bme680.py
Traceback (most recent call last):
File "bme680.py", line 10, in <module>
sensor = adafruit_bme680.Adafruit_BME680_I2C(i2c)
File "/home/pi/blinkenlight/lib/python3.5/site-packages/adafruit_bme680.py", line 330, in __init__
super().__init__(refresh_rate=refresh_rate)
File "/home/pi/blinkenlight/lib/python3.5/site-packages/adafruit_bme680.py", line 105, in __init__
self._read_calibration()
File "/home/pi/blinkenlight/lib/python3.5/site-packages/adafruit_bme680.py", line 291, in _read_calibration
coeff = list(struct.unpack('<hbBHhbBhhbbHhhBBBHbbbBbHhbb', bytes(coeff[1:])))
struct.error: unpack requires a bytes object of length 38
Um, this is a library for CircuitPython, not for Python 3.
The raspberry pi 1 had a hardware bug pertaining to clock stretching, where it effectively prevented communication with a device that would do it. However, I don't think the error mentioned here is related to that, I think it's about the differences between how the struct module works on MicroPython/CircuitPython and Python 3.
@brennen is testing all of these pypi'd libraries on RPi, so perhaps this is one to look at first.
Oops, he's the issue writer. Never mind... :) I should eat breakfast before commenting.
lol -its not clock stretching its something else because its not getting the full amount of data. which is weird. im not sure what it is, possibly some internal raspi buffer thing.