Multiple I2C sensors + LCD shield


I am attempting to connect 2 TSL2561 sensors along with my 16x2 LCD (also I2C) from Adafruit.

I am unsure on the voltage levels and use of pullup resistors. I know that the TSL2561's have built in pullup resistors. I don't know if the LCD does. Can I just connect the SCL and SDA lines of each in parallel? Some literature has told me to disable all but one of the pullups if there are more than one sensor, but since everything will be in parallel I'm not sure why.

P.S. The wires connecting the light sensors are 35 and 40 feet long, respectively (tested working).

Thank you!

Hello nicobux,

I'm assuming that the 2 TSL2561 sensors are built in breakout boards, right? In this case, you're right, the boards probably have their own pullup resistors. But in the case of your LCD display, there is a quick way to find out if it has pullup resistors.

Take a multimeter, and with the LCD display unplugged, measure the resistance between the SCL and the VCC, or between the SDA and the VCC. Adafruit usually uses 10K resistors, so you should measure something in that ballpark. You can also measure between both SCL and SDA, in this case you should measure both resisors at once (20K).

Check out this short video about the I2C bus:

It gives the answer you're looking for! :slight_smile:

Great thanks for the info. Everything has a breakout board.

Do I not have to worry about the logic voltage level of the LCD, in case it differs from the light sensors?

Edit: looking at the LCD wiring diagram it appears that it uses 5V logic

Well, it depends on the breakout boards of your light sensors.

The TSL2561 runs on 3.3V, which means that not only the power supply must be at 3.3V, but the I2C communication must use this voltage level as well.

The breakout board from Adafruit does that for you.

If you plug 5V from your arduino on the Vin pin of the TSL2561 board, the signals on the SDA and SCL are converted to 3.3V before reaching the sensor chips, and it works backwards too. The signal from the sensor chip is converted back from 3.3V to 5V before leaving the breakout board.

If you were only using the two light sensors, you could connect its power supply directly to the 3.3V from the arduino. In this case, the voltage regulator from the sensor board would just transfer the signals without any conversion.

BUT the LCD needs 5V, not only for the power supply, but probably for the I2C communication as well.

So you have to use 5V for all your devices. Summing up, if the breakout boards from your light sensors have buit-in voltage regulators, you're fine! :slight_smile:

They do not have built in voltage regulators. In fact, they have a new board that does (TSL2591). I own some of both boards, but the new one with regulators has only one I2C address which means you can only run one on the same Arduino. The reason I bought the older version is because I need to run 2 sensors.

Would it be easier to add voltage regulators to the old boards or use software to run mutliple I2C slaves with the same address (I think this is possible)?

Thank you,

I don’t think it is possible to run multiple I2C slaves with a single address. The addresses are hardwired to each sensor chip. When more than one chip is connected to the I2C bus, and you send a command with that I2C address, both sensors will try to answer. At the same time! I wouldn’t say, it’s not possible, but it’s not worth the effort.

So using voltage regulators for the light sensors would be the way to go, but instead of changing your existing boards, I would simply use another board with a level shifter, like this one from Adafruit. It’s quite cheap and if you’re not on a hurry to put this to work, it would be the best solution for you.

hope that helped!

PS: Are you using the TSL2561 from Adafruit? Because I have one of those, and they do have voltage regulators buit in!

The only problem with the board from Adafruit listed above is the statement on the page for that board that “Only thing that doesn’t work well with this chip is i2c” There are other level shifters out there too but I have not had a chance to play with them yet like the one from Sparkfun (also on ebay etc.) : I have some of them and plan to use them, but have not had a chance to wire my project up yet.

Yeah, you're right! Apparently the TXB0104 needs pullup resistors over 50K to work! :stuck_out_tongue:
Though I never used myself, I belive this one from Sparkfun should work, because the BSS138 are the same transistors that are built in most breakout boards.

I'm using the Adafruit breakout for the TSL2591 but the Sparkfun breakout for the TSL2561.

My current work around will be to supply the power to my TSL2591's via GPIO pins, and turn on sensor just when I want to read its value.