Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 9 of 9

Thread: How to use multiple Adafruit TSL2591 light sensors with teensy 3.2?

  1. #1

    How to use multiple Adafruit TSL2591 light sensors with teensy 3.2?

    Hello all,

    Issue: The adafruit TSL2591 light sensor has a I2C address (0x29) which 'cannot' be changed. Is it possible through code (basically not creating a hardware switch on SCL or SDA) to chain x2 of these sensors on a single interface (pins 16/17) without a multiplexer? The reason I ask is because, although the data may be different at different times on the address , or same at same time on the address, the end result in the code is to asses for a change in data and not which sensor saw it......

    I am aware that the T3.2 has wire and wire1....And if I used wire for one TSL2591 and wire1 for the other, would there still be conflict? (i would think not as these are separate interfaces...?)

    I am aware that I can add a multiplexer....

    Thank you for any input!
    Last edited by XRAD; 11-25-2021 at 04:29 PM.

  2. #2
    Senior Member BriComp's Avatar
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    465
    Issue: The adafruit TSL2591 light sensor has a I2C address (0x29) which 'cannot' be changed. Is it possible through code to chain x2 of these sensors on a single interface (pins 16/17) without a multiplexer? The reason I ask is because, although the data may be different at different times on the address , or same at same time on the address, the end result in the code is to asses for a change in data and not which sensor saw it......
    NO!
    Use multiple I2C ports for multiple TSL2591.

  3. #3
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    9,428
    The hardware switch can also be a simple transistor for the clock line, which enables/disables the clock for each sensor... but for two sensors onyl, it makes mores ense to just use the Teensys both i2c interfaces

  4. #4
    THX for replies! but here is the interesting thing, x2 light sensors connected to one I2C port produce 'one' data chain(no mux)..without crashing..... If I light one sensor, or the other, or shade one sensor, or the other, the output remains stable and looks like only 'one' sensor reading.. which is maybe OK for my project..but not sure how it is working.... interesting...

    Frank: Is it better to disable the clock, or the data line?

    bmp description: low numbers are recorded when I shade one sensor, then I shade the other.....they are acting as one sensor....
    Note: three sensors do not work..but two work...

    Click image for larger version. 

Name:	x2 light sensors.jpg 
Views:	10 
Size:	146.4 KB 
ID:	26670
    Last edited by XRAD; 11-26-2021 at 12:02 AM.

  5. #5
    Senior Member
    Join Date
    May 2017
    Posts
    248
    The open collector I2C bus with pullups acts as a wired AND or wired NOR. Each device can turn ones into zero's but cannot change zero's into ones. You will never get the actual correct reading with them both tied together. Any bit low on either sensor will result in that bit being low in your result.

  6. #6
    Quote Originally Posted by rcarr View Post
    The open collector I2C bus with pullups acts as a wired AND or wired NOR. Each device can turn ones into zero's but cannot change zero's into ones. You will never get the actual correct reading with them both tied together. Any bit low on either sensor will result in that bit being low in your result.
    so each slave can pull the data line collector LOW? and thereby causing the master to go LOW...? and then does data pass from both slaves....?
    I have more reading to do..

    Thank you for reply!!

  7. #7
    Senior Member
    Join Date
    May 2017
    Posts
    248
    Quote Originally Posted by XRAD View Post
    so each slave can pull the data line collector LOW? and thereby causing the master to go LOW...? and then does data pass from both slaves....?
    I have more reading to do..
    Yes from the results you are getting, both slaves are responding to the read command at the same time. If it were 8 bit data and the true reading of unit 1 was 0xF1 and the true reading of unit 2 was 0x0F, then when read together you would read 0x01 ( the only bit that is high in both ).

  8. #8
    Quote Originally Posted by rcarr View Post
    Yes from the results you are getting, both slaves are responding to the read command at the same time. If it were 8 bit data and the true reading of unit 1 was 0xF1 and the true reading of unit 2 was 0x0F, then when read together you would read 0x01 ( the only bit that is high in both ).
    Thank you rcarr!! very helpful, yes the LUMINOSITY data is 8 bit....and I did mux the TSL sensors, and the readings are very different (which I guess could be calculated out in the bit changes) , although the data 'change' (not data accuracy) of each each 'EYE' remains similar...

    this should be a cool project. Thanks again for forum's help!

    accurate data now
    Click image for larger version. 

Name:	MUX1.jpg 
Views:	6 
Size:	100.5 KB 
ID:	26690

  9. #9
    Quote Originally Posted by XRAD View Post
    Thank you rcarr!! very helpful, yes the LUMINOSITY data is 8 bit....and I did mux the TSL sensors, and the readings are very different (which I guess could be calculated out in the bit changes) , although the data 'change' (not data accuracy) of each each 'EYE' remains similar...

    this should be a cool project. Thanks again for forum's help!

    accurate data now
    Click image for larger version. 

Name:	MUX1.jpg 
Views:	6 
Size:	100.5 KB 
ID:	26690
    EDIT:
    yes the LUMINOSITY data is 16 bit....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •