LTR559 on the Raspberry Pi Pico via Explorer Base

Hi folks,

I am playing around with the LTR559 connected to my Raspberry Pi Pico via the Explorer base. I am running version 0.2.2 of the Pimoroni Pico micro python library. My first port of call was to check out the example here and appears to build fine.

import time
from pimoroni_i2c import PimoroniI2C
from breakout_ltr559 import BreakoutLTR559

PINS_BREAKOUT_GARDEN = {"sda": 4, "scl": 5}
PINS_PICO_EXPLORER = {"sda": 20, "scl": 21}

ltr = BreakoutLTR559(i2c)

part_id = ltr.part_id()
print("Found LTR559. Part ID: 0x", '{:02x}'.format(part_id), sep="")

while True:
    reading = ltr.get_reading()
    if reading is not None:
        print("Lux:", reading[BreakoutLTR559.LUX], "Prox:", reading[BreakoutLTR559.PROXIMITY])


Nothing appears to happen for the first 12 seconds and then I see the following outputted until I stop the program.

Lux: 0 Prox: 1457
Lux: 0 Prox: 1457
Lux: 0 Prox: 1457

No matter where I put the sensor, lux appears to always be 0 and the proximity is always 1457, even if I put something in front of it. It simply never changes.

What I was expecting was to see the values change if I move the sensor to a lighter environment and also see the proximity value change if I put something in front of it, but this appears to never happen.

I wanted to check to see if my understanding and expectations of the sensor are valid.

I have one, I used it with a Pi Zero. If I remember correctly the LUX value goes up in bright light and down in low light. The brighter the light the higher the number. And the proximity value increases as the detected object gets closer to the sensor.

I’m getting the same results running that code on my Explorer.
Lux: 0 Prox: 1377
Lux: 0 Prox: 1377
Lux: 0 Prox: 1377
Lux: 0 Prox: 1377
Lux: 0 Prox: 1377

If I run an i2c scan

import machine
sda=machine.Pin(20) #20 Explorer 3 Breakout
scl=machine.Pin(21) #21 Explorer 4 Breakout
i2c=machine.I2C(0,sda=sda, scl=scl, freq=400000)
print('Scan i2c bus...')
devices = i2c.scan()
if len(devices) == 0:
  print("No i2c device !")
  print('i2c devices found:',len(devices))
  for device in devices:  
    print("Decimal address: ",device," | Hex address: ",hex(device))

I get the following,
Scan i2c bus…
i2c devices found: 1
Decimal address: 35 | Hex address: 0x23
Which is the correct address.

i2c = PimoroniI2C(**PINS_PICO_EXPLORER)
And it will work. =)

Amazing. Works like a treat. Cant believe I didnt spot that. Wont admit to hour many hours I wasted :D.

Thanks again.

It was easy enough to miss. I didn’t see it right away, I messed around for a while until the light came on. We won’t likely forget now though. I have a Breakout Garden Base on the way, to compliment my Explorer Base. I can see myself getting “momentarily” caught up once or twice forgetting to edit that line. ;)