LiquidCrystal_I2C and Si7021 both on I2C leave the LCD just blocks

I have Googled this one and can't find a solution...

So here's the fundamental understanding - I2C allows for multiple devices basically to use the same pins (SCL & SDA) and it works because the devices have different addresses... it's a bus.

Hardware - MKR1000

I have SunFounder IIC I2C TWI Serial 2004 20x4 LCD Module Shield with the I2C backpack - plugged in to SCL and SDA, v5 and GRD... works great...

I have a HiLetgo Si7021 GY-21 Industrial High Precision Humidity Sensor I2C IIC Interface for Arduino Low Power CMOS IC Module - plugged into the same SCL, SDA and GRD pins... this pulls 3.3V off the VCC pin.

It gets me temp and humidity without any issue - logs to serial wonderfully...

When I have them BOTH plugged in to SCL and SDA... the Si7021 continues to log temp / humidity without issue... the LCD is just 2 rows of black boxes.

When I run a sketch to look at the I2C bus - it sees the 0x60 of the master on the board, and the 0x40 of the Si7021... but the LCD screen is not showing with ti's 0x27...
(this sketch - https://playground.arduino.cc/Main/sourceblock_1/index.txt?action=sourceblock&num=1)

Thing is - even if I run that without the Si7021 plugged in - it never sees the LCD...
But if I use LiquidCrystal_I2C.h I can write to the screen... using address 0x27

So - the question here is - is there something inherently crummy about this LCD board and it's I2C behaviors that it will not share the I2C world with any other device? Is there some trick to making the LCD share the I2C wires with something else?

It sounds like you have incorrectly hooked things up.
I appears that you are attempting to connect two i2c buses together.
A 5v one and a 3v one.

Also, using 5v signals on the MKR1000 could damage the pins as they are not 5v tolerant

You said you are powering your LCD off 5v which creates & expects 5v signals on SDA and SCL.
and that you are powering your sensor off 3v which creates & expects 3v signals on SDA and SCL.

That is effectively creating two different i2c buses (a 5v one and a 3v one) and you can't mix those signals on the same bus.

You will need to use a level shifter for the LCD to run it on a 5v bus separate from the 3v bus for your sensor.
They are not expensive. ~ $1 USD.

.

--- bill

bperrybap:
They are not expensive. ~ $1 USD.

If you buy only one!

Never just buy one!

eBay!

Just ordered some from Amazon...

So - @bperrybap - thank you... but this is testing my opinion of I2C :wink: Clearly I wrongly assumed that a "bus" would be standard output regardless of the voltage of the device... like - ya know - computers on a network all have their own operating specs, but the network and protocol are "common"... or in a car, I'm pretty sure even tho the battery operates at 12V... some systems have different voltages and yet still communicate on the same bus... but - no matters -I think you solve it for me!

I'm also interested to see - when I get the shifter if then - all the sudden - when I run the sketch to return the address - if the LCD, stepped down to 3.3, will now report back!

Also - not understanding why - if the master on the MKR1000 and the Si7021 both report back - they must both be 3.3v... how has / does the LCD work at all - ever...

FWIW - this Si7021 is replacing the worst electronics component on earth... the DHT11 :slight_smile:

Thanks again!

The I2C bus very much is a standard but the signal voltage is not a fixed voltage.

https://www.i2c-bus.org/

I2C is open collector. The master and slaves only drive the LOW low level on the SDA & SCL signals.
The HIGH level on the signals is done/driven by pullups, NOT, the master.
And strictly according to the spec you should only have 1 pullup per signal.
While only 1 is needed, it can work with multiple pullups as long as the overall pullup value does not drop below about 1k as there is a maximum current specified in the spec.

In your case you have different voltages for the two slaves.
And are attempting to use a voltage on one of them that can potentially damage the processor on the MKR1000.

The i2c LCD backpack is running at 5v. Nearly all i2cLCD backpacks have pullups on them.
These pullups will pullup the SDA and SCL signals to 5v since that is what you provided.
So when only the LCD device is wired up the pullups will pull the bus signals up to 5v.
This is not good for a 3v processor that is not 5v tolerant as it can damage the pin logic.
i.e. the pullup on slave is creating a 5v HIGH signal being fed to a pin that is only rated for 3.3v.
In many cases, if it doesn't immediately blow up the processor, it will appear to work, at least with a single slave since the pullup resistor on the slave is a large enough value that the excess voltage (current) doesn't damage the processor.
Add more i2c slaves that have their on pullups and things can get worse for the i2c pins on the 3v processor.

Now toss in a sensor module, which I'm assuming also has pullups on it but those are connected to 3v.
Now you have a funky situation where each i2C signal (SDA and SCL) has a two pullups on it,
One to 5v and one to 3v. You end up with some voltage in the middle, depending on the resistor values.

This ends up creating HIGH signal levels that are outside the spec for all 3 entities
Master, and both slaves.
Still too high for the master, to low for the 5v slave and too high for the 3v slave.
When signals are outside their specified range, behavior is undefined.

For level shifters, I prefer the smaller 2 channel ones with only 8 pins.

--- bill

fishpickfarmer:
Clearly I wrongly assumed that a "bus" would be standard output regardless of the voltage of the device.

It most certainly was a wrong assumption. No such specification. This is not a voltage specification at all, but a protocol.

I refer you FWIW, to Wikipedia.

Typical voltages used are +5 V or +3.3 V, although systems with other voltages are permitted.

The physical layer defines it as open-drain which is in itself a mechanism for ensuring independence of logic voltages. It is not that the system will not work with differing interface voltages as it almost always will, the need for the level shifter is instead to protect the lower voltage logic devices.

fishpickfarmer:
I'm also interested to see - when I get the shifter if then - all the sudden - when I run the sketch to return the address - if the LCD, stepped down to 3.3, will now report back!

The LCD and the PCF8574 will be running at 5v. The level shifter allows the 3v i2c bus signals to connect & talk to the 5v i2c bus signals.

--- bill

bperrybap:
The LCD and the PCF8574 will be running at 5v. The level shifter allows the 3v i2c bus signals to connect & talk to the 5v i2c bus signals.

--- bill

Understood (now) - what I was saying is - I am very interested to see if NOW once I have the level shiftier and the 5V LCD is stepped down / shifted down to 3.3v - if THEN when I run the sketch to get all the !2C addresses - if THEN I'll see the 0x27 of the LCD backpack :slight_smile:

Thanks everyone for all the input... look - I'm a software guy - I can code the #3!! out of stuff... but wires and things that blink... I'm learning this stuff and your assistance is appreciated!

FWIW - I am "cleaning up" the prototype >> production hardware of my green house control module. The DHT11 just would die every few days - no matter what - so I'm switching to a more robust temp / humidity sensor in the Si7021. The MKR1000 talks to WiFi and I'm using Blynk - it monitors temp and humidity. When a threshold is hit - it opens a set of 4 vents (2 on each end of the greenhouse) using RC servos and when another threshold is hit in temp (or humidity in a certain range) it turns on the fans (relays). It understands the concept of "time" (RTC via Blynk) so on sun / cloud / sun / cloud days things don't "flap" - it also has a water valve that will turn on at a scheduled time (and a beeper inside the unit so if you are in the greenhouse when the water is gonna turn on - you get a 30 second warning of beeps). You can control and override most things in Blynk on your phone... and of course - this little LCD in this post is on the sealed unit in the greenhouse - so when you are IN the green house you can see the critical stats w/o digging for your phone.