BMP280 and SHT21 don't work correct together

Hi experts,
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.

The BMP280 has address 0x76 or 0x77 depending on the connection of SDO (pin 5) to GND or Vcc.
If your's is listening on 0x40 you have not that type. Provide a link to your product.

I2C address scanner reports for the SHT21 : ‘I2C Scanner
Scanning…
I2C device found at address 0x40 !
done’

when I take the SHT21 away and put the BMP280 in place, it reports:
I2C Scanner
Scanning…
I2C device found at address 0x40 !
I2C device found at address 0x76 !
done

when I connect both sensors to the Uno, I get:
I2C Scanner
Scanning…
I2C device found at address 0x40 !
I2C device found at address 0x76 !
done

the BMP280 is a breakout with as indication only ‘GY21P’ and of course the four pin labels VCC, GND, SCL and SDA

The SHT21 also carries the label ‘SI7021’. I assume this is the temperature part of this sensor
(see attachments- pictures)

BMP_280_up.jpg

BMP_280_down.jpg

SHT21_top.jpg

Is there an address jumper on the back of the module?

photoncatcher:
when I take the SHT21 away and put the BMP280 in place, it reports:
I2C Scanner
Scanning...
I2C device found at address 0x40 !
I2C device found at address 0x76 !
done

This can't be right. A single sensor won't have two I2C addresses.

Strange things sometimes happen

I now seem to have the sensors under control, via a trick. I think it is an address conflict where both sensors have address 0x40 with the SHT21 screwing things.

After some experimentation the obnoxious sensor (SHT21) now receives power from pin D5 (reduced to 3.3V via a voltage regulator).

The sketch is straightforward:

  1. when sketch starts, pin 5 is set HIGH.
  2. the SHT21 is read
  3. pin 5 is set LOW
  4. the BMP280 is read
  5. pin 5 is set HIGH
  6. loop completed - back to 1.
    :slight_smile:

photoncatcher:
Strange things sometimes happen
[/quote

True

I now seem to have the sensors under control, via a trick. I think it is an address conflict where both sensors have address 0x40 with the SHT21 screwing things.

And that’s provable wrong as the BMP280 is not at I2C address 0x40 but at 0x76 or 0x77 - see datasheet. I’m assuming here you have the real thing - and your I2C scan indeed confirmed that by finding a sensor at 0x76.

You didn’t post a complete schematic of your setup, so it’s still a bit of guesswork on what’s going on there. I didn’t realise you’re working on 5V, I’m too used to 3.3V all the way myself.

The photos you posted of the BMP280 breakout module show something that looks like a regulator and a set of level shifters:

photoncatcher:
f2fabc4332387bd8c85fc6f20c64ca2498ebda8a.jpg
cac5695508ac95005b87c53fa2836b5c30d8cae4.jpg

Now you say you are connecting the other sensor to 3.3V using a separate regulator - but no level shifters for the I2C bus for the SHT21. Putting a 3.3V device on a 5V I2C bus without level shifters is a bad idea, it may kill the device (probably not 5V tolerant), and the device has it’s pull-up resistors to 3.3V not 5V (you did mention something about pull-up resistors there, the image you posted of the sensor is only one side, but the vias suggest there are components on the other side of the PCB as well).

Again without complete schematics it’s hard to say what is going on there really, but mixing voltages is never a good idea.

The SHT21 also carries the label 'SI7021'. I assume this is the temperature part of this sensor

That means it's not an SHT21 but a SI7021, a kind of cheaper clone of the SHT21.

the BMP280 is a breakout with as indication only 'GY21P' and of course the four pin labels VCC, GND, SCL and SDA

That board seems to include an SHTx1 chip (the one with the white cover). The picture is not very sharp so I cannot say which type it is. This explains why the board is answering on two addresses: it has two chips.

pylon:
That board seems to include an SHTx1 chip (the one with the white cover). The picture is not very sharp so I cannot say which type it is. This explains why the board is answering on two addresses: it has two chips.

I think you're completely correct. I just did a search on "GY-21P" and quickly found an e-bay ad with this headline:

Details about BMP280 SI7021 GY-21P I2C & SPI Humidity Temperature Atmospheric Sensor Breakout

That means that OP has two sensors on the same address (the SI7021 and the SHT21 - assuming the second one is the real deal). That indeed will cause problems, even with the switch on/off trick - which of the two sensors on address 0x40 is responding?.

Thanks for your comments!

I took better pictures of the top and bottom of the sensosr that were advertised as being, respectively, a SHT21 and a BMP280.

The ‘trick’ wiring is as follows.

----> The BMP280 pins are connected to the Uno as follows: VIN: 3.3V, GND: GND, SCL: A5, SDA: A4

10k ohm resistor between SCL and 3.3V, and another one between SDA and 3.3V

—> The SHT21 pins are connected to the Uno as follows: GND: GND, SCL: A5, SDA: A$

10k ohm resistor between SCL and 3.3V, and another one between SDA and 3.3V

the trick is that pin D5 of the Uno is connected to a 10k trim pot meter. The wiper of this pot meter is connected to VIN of the SHT21. The pot meter has been trimmed so that the wiper delivers 3.3V.

As pin D5 can be set HIGH or LOW in software the SHT21 can be deprived from power, say ‘switched off’ while the BMP280 is read.

Do I do anything wrong with voltages? Hopefully not. I don’t smell frying sensors (yet).

It’s more convenient if you post your images in the message than requiring us to download to view:

photoncatcher:
182a831bd8d506dc865fe5bd5aefbcc95f63df1c.png
f75e377673375a0156a2654a7ac524e0bf4e5e23.png

OK well looking at those images you see the bottom is awfully similar, without being able to read actual component numbers (and do check with the seller!) these both appear to have a regulator and level shifters on board. That would explain why they all still work. No need to mess around with the 3.3V if so.

Then your schematic: not much that’s right about it. I think it’s this:
schematic.png

The SCL/SCA pins are connected to both 3.3V and 5V with fixed resistors, that’s effectively a pull-up to 4.15V.
The pot RV1 is not a regulator. You can’t draw any voltage from it without affecting the output voltage, which will drop rapidly.
I’m surprised this works at all - especially that the SHT21 works this way, unless the capacitors on board are more than filtering and can provide the power needed for long enough for the sensor to do its job. It may also be drawing some power from the I2C bus, which would be wrong, too.

Hi wvmarle,

Your wiring scheme is what I had put together, except that the BMP280 is powerd by 3.3V and that in my wiring all (4) pull ups are against 3.3V.

Per your comment on my pictures I tested both sensors with 5V at VIN. That works without problems, no sparks or pungent smoke. As a rank amateur in breakout board realms I lack te experience to determine whether a breakout has a voltage regulator on board, so I take precautions to protect my precious sensors against voltage dangers.

I took away the pot meter and connected the VIN pin of the BMP280 to 5V and VIN of the SHT21/SI7021 to D5, powering this sensor on and off when necessary. The BMP280 continuously receives 5V. Now I get two temperature measurements, one relative humidity and one pressure value. The BMP280 temperature differs 0.5 degrees centigrade from that reported by the SI7021.

Thanks ! Floris

photoncatcher:
Per your comment on my pictures I tested both sensors with 5V at VIN. That works without problems, no sparks or pungent smoke. As a rank amateur in breakout board realms I lack te experience to determine whether a breakout has a voltage regulator on board, so I take precautions to protect my precious sensors against voltage dangers.

Mind I never said with certainty it has, just that it looks like it has, mostly based on the part count.
Better ways to determine this is to know whether the breakout is rated for 5V, and when in doubt to check the numbers written on the components to figure out what they really are (or even to draw the schematics if you want to know how level shifters work).

For your sensors, I think you're looking at the following components.

  • the large three-pin looks like a regulator (it's connected to a.o. Vcc and GND).
  • the six-pin component I guess to be a dual MOSFET.
  • the 8-pin component marked "103" is likely 4x 10k resistor bank.
  • the four brown things are probably capacitors (the usual colour of capacitors, goes both ways), for decoupling.
    That would explain all components in a sensible way, largely based on the duck test (if it looks like a duck, swims like a duck, and quacks like a duck, then it probably is a duck) and what you can expect for such a PCB.

Hi wvmarle,

Thanks enormously for your help in this matter.
Spotting waterfowl and identifying ducks has much in common with identifying beakout boards: they come in all kinds of brands, and they may surprise you.

see https://flyways.us/duck-identification-resources

I took away the pot meter and connected the VIN pin of the BMP280 to 5V and VIN of the SHT21/SI7021 to D5, powering this sensor on and off when necessary. The BMP280 continuously receives 5V. Now I get two temperature measurements, one relative humidity and one pressure value. The BMP280 temperature differs 0.5 degrees centigrade from that reported by the SI7021.

You did realize that you don't need the second board (SI7021) as the BMP280 board has both sensors onboard, didn't you?
I'm asking just because I got the impression that you missed that detail.

pylon:
You did realize that you don’t need the second board (SI7021) as the BMP280 board has both sensors onboard, didn’t you?
I’m asking just because I got the impression that you missed that detail.

Yes, I knew, but it is the challenge to get multiple sensors working for me.

Yes, I knew, but it is the challenge to get multiple sensors working for me.

But in your case you should not connect the second board because it has the same sensor. The SHT21 (and probably the SI7021 too) isn't able to change the I2C address. If you have two sensors with the same address on one I2C bus you will always have problems sooner or later.