I want to read with an Arduino Uno barometric pressure, temperature and relative humidity. For this purpose I have two I2C sensors: a BMP280 (address: 0x40) returns pressure and temp) and a SHT21 (address also 0x40) returns temp and relative humidity)
Each of the sensors does perfectly what it is supposed to do when it is connected as standalone, standard I2C way, to the Uno: SDA to A4, SCL to A5, GND to GND and VCC to 3.3V (doesn't matter with or without 10k pull up between SDA and VCC and SCL and VCC)
The BMP 280 is read with a sketch including the BMP280.h library
The SHT21 is read with a sketch including the SparkFunHTU21D.h library. I also used the SHT2x.h library, with success.
Conclusion: as standalone sensors, both sensors work.
Now, when I combine the BMP280 and the SHT21 (SDA+SDA to A4, 10k pull up; SCL+SCL to A5, 10k pull up ) a strange thing happens. When I run the BMP280 sketch I get correct temperature and pressure. However when I run the SHT21 sketch I get correct temperature but nonsense humidity (999%).
When in this situation I disconnect VCC and GND of the BMP280, then the SHT21 sketch returns normal temperature and humidity. If I now reconnect the BMP280, then the returned humidity of the SHT21 promptly jumps back up to 999%.
Apparently the SHT21 signal and the BMP signal interfere because they both use address 0x40
I welcome suggestions to get the two sensors working together in unity, e.g. how I can force addresses in I2C.