Well, I ran into a situation where I need to connect 4 SGP30 sensors to a single Arduino.
They all have the same address, meaning I can’t connect all of them to the hardware I2C bus.
But I don’t have SGP30 sensors, thus I use Si7021 just to test if software I2C works. If it works on a single Si7021, then maybe I can conclude that it also works with 4 SGP30s.
The problem is, I came across quite a few software I2C libraries compatible with TwoWire’s interface (and modified Si7021 library to use software implementations, of course), none of them work. All of them fails to read from sensor (all read back 0 or 255).
Can someone help finding a working library or testing multiple SGP30s connected to one board and getting them working? My deadline is on Saturday, any help is greatly appreciated. Need more information, just ask.
Another approach is to connect all Si7021 to the same HW I2C lines but power them from digital pins. So you will be able to have only one active device on I2C bus and then switch to another.
Another approach is to connect all Si7021to the same HW I2C lines but power them from digital pins. So you will be able to have only one active device on I2C bus and then switch to another.
THANK YOU SO MUCH! I just thought about simulating protocol, never had the idea to control the power of each sensors. I think this approach may really do the trick. I will try later.
As for that library, well, actually I have seen it before, but it's not compatible with TwoWire interface and I just don't know how to implement one from it.
45gfg9:
..., never had the idea to control the power of each sensors. I think this approach may really do the trick. I will try later.
Make sure you do not set the heater to anything but the lowest level when you directly power the sensor with an I/O pin. The heater can draw up to 95mA. If you need that feature you will need to use an external transistor.
Without the heater the maximum current of the sensor seems to be during power up and I2C operations (max 4mA).
Hold on... It seems like even if the sensor is not powered, it still interferes with I2C bus. When I connect four to the bus (and only one of them is powered), I can't get any of them initialized. But if it only connects to one sensor it functions normally. Damn, I wish I have an oscilloscope but I don't. I guess maybe there is really no other ways...?