LTR-559 Details

I plan to use the LTR-559 breakout with an ATTiny mcu, rather than a Raspberry Pi, coding on the Arduino IDE.

As things stand I can get only part way using a combination of the Python code example and the Liteon data sheet. The problem is that the Liteon sheet is incomplete in many ways, for example it does not describe the way to calculate the ALS value (whereas the author of the Python code must have figured it out from somewhere). There are other things it would be useful to have, including an introduction to the device operating principles!

So my first question is whether there is another LTR-559 data sheet or reference elsewhere that I am missing? I cannot see it on either the Pimoroni site or the Liteon site.

A second question is - does anyone have available a circuit diagram for what is on the breakout, besides the LTR-559 itself. For instance I assume there are terminator resistors for the I2C, but what are their values?

Datasheets are a very mixed bag, and unfortunately some of them are absolutely awful. Sometimes you’d almost think they don’t want you to be able to figure out how to use their device.

That said, what do you mean by the ALS value? Do you mean the Lux value? You can piece it together from the Python code in Pimoroni’s library:

def update_sensor(self):
        """Update the sensor lux and proximity values.
        Will perform a read of the status register and determine if either an interrupt
        has triggered or the new data flag for the light or proximity sensor is flipped.
        If new data is present it will be calculated and stored for later retrieval.
        Proximity data is stored in `self._ps0` and can be retrieved with `get_proximity`.
        Light sensor data is stored in `self._lux` and can be retrieved with `get_lux`.
        Raw light sensor data is also stored in `self._als0` and self._als1` which store
        the ch0 and ch1 values respectively. These can be retrieved with `get_raw_als`.
        """
        status = self._ltr559.get('ALS_PS_STATUS')
        ps_int = status.ps_interrupt or status.ps_data
        als_int = status.als_interrupt or status.als_data

        if ps_int:
            self._ps0 = self._ltr559.get('PS_DATA').ch0

        if als_int:
            als = self._ltr559.get('ALS_DATA')
            self._als0 = als.ch0
            self._als1 = als.ch1

            self._ratio = self._als1 * 100 / (self._als1 + self._als0) if self._als0 + self._als1 > 0 else 101

            if self._ratio < 45:
                ch_idx = 0
            elif self._ratio < 64:
                ch_idx = 1
            elif self._ratio < 85:
                ch_idx = 2
            else:
                ch_idx = 3

            try:
                self._lux = (self._als0 * self._ch0_c[ch_idx]) - (self._als1 * self._ch1_c[ch_idx])
                self._lux /= (self._integration_time / 100.0)
                self._lux /= self._gain
                self._lux /= 10000.0
            except ZeroDivisionError:
                self._lux = 0

Alternatively the datasheet says the formula is in Appendix A which seems to be missing, but this issue on Pimoroni’s Github suggests that Liteon will email it to you if you ask nicely.

does anyone have available a circuit diagram for what is on the breakout

Unfortunately Pimoroni don’t publish circuit diagrams. I2C pull-up resistors are built into the Pi. As far as I know, Breakout Garden boards have built-in level shifting, so I’d assume the two ICs beside the SDA/SCL pins are to do with that and I’d assume then that the IC beside the 3-6V pin is a voltage regulator.

Shoe, thank you for the information. For the present I am using the ALS algorithm from the Pimanori library as a starting point but it is going to take a bit of work translating from the arithmetic capabilities of Python on a Pi down to an 8/16 bit mcu. Some compromises are going to be needed, especially as all I really need is to be able to determine when it is “dark”. So maybe I just use the daylight sensor channel and ignore the ir. That’s why I was hoping for more information from either Liteon or Pimanori (someone somewhere wrote that Python code) but I will chase down the reference you gave.