adafruit / Adafruit_CircuitPython_TSL2561

CircuitPython driver for TSL2561 Light Sensor
MIT License
4 stars 7 forks source link

TSL2561 Chip id, part number, must 5? Code States That Datasheet is wrong? #37

Open Jibun-no-Kage opened 2 years ago

Jibun-no-Kage commented 2 years ago

I have several TSL2561 sensors that return part number as 4 not 5. Various other scripts and libraries work, some even explicitly test for part number as 4. but the adafruit library fails, stating the part number must be 5. I commented out the test for part number as 5, and the adafruit library works with my TSL2561 sensors. I have also seen references to various TSL2561 ICs that report part number 4, 5, even 6.

Edit is to /usr/local/lib/python3.9/dist-packages/adafruit_tsl2561.py, change illustrated below:

In def init... comment out... if not partno == 5:

insert: if partno not in [4,5]:

This retains of course allows partno to be 4 or 5. Any comments or suggestions?

Jibun-no-Kage commented 2 years ago

After my initial post I found the following code logic...

            part = str(value)[7:4]
            if (part == "0000"):
                    PartNo = "TSL2560CS"
            elif (part == "0001"):
                    PartNo = "TSL2561CS"
            elif (part == "0100"):
                    PartNo = "TSL2560T/FN/CL"
            elif (part == "0101"):
                    PartNo = "TSL2561T/FN/CL"
            else:
                    PartNo = "not TSL2560 or TSL 2561"

So it appears adafruit library is locked to only a single variant of TSL2561 if parno must be 5, or 0101. Also appears that the TSL2561 sensors I have are actually TSL2560 type. The TSL250 are SMBus based versus TSL2561 are true i2c. The library works with SMBus type, interesting, if you do the change above I outlined.

ladyada commented 2 years ago

hiya we don't own that sensor so feel free to do a PR, and we could review it