I am trying to get the TSL2591 outputting values on a raspberry pi zero W with extended pins and a pijuice zero over it. The following code
import board
import adafruit_tsl2591
import time
i2c = board.I2C()
while not i2c.try_lock():
pass
try:
while True:
print(
"I2C addresses found:",
[hex(device_address) for device_address in i2c.scan()],
)
time.sleep(2)
finally: # unlock the i2c bus when ctrl-c'ing out of the loop
i2c.unlock()
works fine and shows the following output
I2C addresses found: ['0x14', '0x28', '0x29', '0x68']
I2C addresses found: ['0x14', '0x28', '0x29', '0x68']
I2C addresses found: ['0x14', '0x28', '0x29', '0x68']
I2C addresses found: ['0x14', '0x28', '0x29', '0x68']
However, when I run the code from the installation instructions
import board
import adafruit_tsl2591
import time
i2c = board.I2C()
sensor = adafruit_tsl2591.TSL2591(i2c)
there is a stream of errors
Traceback (most recent call last):
File "/home/pi/.virtualenvs/lightsensor/lib/python3.9/site-packages/adafruit_bus_device/i2c_device.py", line 175, in __probe_for_device
self.i2c.writeto(self.device_address, b"")
File "/home/pi/.virtualenvs/lightsensor/lib/python3.9/site-packages/busio.py", line 196, in writeto
return self._i2c.writeto(address, buffer, stop=stop)
File "/home/pi/.virtualenvs/lightsensor/lib/python3.9/site-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 52, in writeto
self._i2c_bus.write_bytes(address, buffer[start:end])
File "/home/pi/.virtualenvs/lightsensor/lib/python3.9/site-packages/Adafruit_PureIO/smbus.py", line 303, in write_bytes
self._device.write(buf)
OSError: [Errno 121] Remote I/O error
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pi/.virtualenvs/lightsensor/lib/python3.9/site-packages/adafruit_bus_device/i2c_device.py", line 181, in __probe_for_device
self.i2c.readfrom_into(self.device_address, result)
File "/home/pi/.virtualenvs/lightsensor/lib/python3.9/site-packages/busio.py", line 186, in readfrom_into
return self._i2c.readfrom_into(address, buffer, stop=stop)
File "/home/pi/.virtualenvs/lightsensor/lib/python3.9/site-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 59, in readfrom_into
readin = self._i2c_bus.read_bytes(address, end - start)
File "/home/pi/.virtualenvs/lightsensor/lib/python3.9/site-packages/Adafruit_PureIO/smbus.py", line 170, in read_bytes
return self._device.read(number)
OSError: [Errno 121] Remote I/O error
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pi/init_tsl2591.py", line 6, in <module>
sensor = adafruit_tsl2591.TSL2591(i2c)
File "/home/pi/.virtualenvs/lightsensor/lib/python3.9/site-packages/adafruit_tsl2591.py", line 129, in __init__
self._device = i2c_device.I2CDevice(i2c, address)
File "/home/pi/.virtualenvs/lightsensor/lib/python3.9/site-packages/adafruit_bus_device/i2c_device.py", line 62, in __init__
self.__probe_for_device()
File "/home/pi/.virtualenvs/lightsensor/lib/python3.9/site-packages/adafruit_bus_device/i2c_device.py", line 184, in __probe_for_device
raise ValueError("No I2C device at address: 0x%x" % self.device_address)
ValueError: No I2C device at address: 0x29
I've double checked the connections, and even used a multimeter to test the connectivity of the jumper wires: all okay. The hardware setup is shown below
Any thoughts about why I am not able to read the sensor/other things to test? Thanks.