BMP280 GY - does it always need logical level shifting?

BMP280 GY on Arduino nano, I2C.

From internet, some say level shifting is mandatory, some say it might be the case, some say - no need.

I am very confused. I mounted BMP280 without any level shifting, using Senzor I2C library (the one dedicated to BMP280 from Adafruit refused to compile, despite changing the I2C adress and modifying cpp as well). The readings seems ok.

The question is: is it needed the level shifting in the of this sensor?

Is it the need for level shifting related to the wiring and/or the code or is just a matter of sensor type or board?

Thank you very much!

They are all right, it is all those things together (mandatory, might be the case, no need) :grin:

A level shifter can connect the voltage levels of SDA and SCL of a 5V I2C bus to a 3.3V I2C bus. Since data on the I2C bus is going in both directions, the level shifter makes a 5V signal from a 3.3V signal and a 3.3V signal from a 5V signal.

This BME280 has a voltage regulator for VCC and level shifters for SDA and SCL: 【SIMPLE ROBOT】3In1 BME280 GY BME280 Digital Sensor SPI I2C Humidity Temperature and Barometric Pressure Sensor Module 1.8 5V DC |spi i2c|spi sensormodule dc - AliExpress. That makes it fully compatible with 3.3V and 5V.

When your Arduino Nano is powered with an external power supply, it runs at 5.0V, and you are operating outside the datasheet specifications when using the BMP280. That is not very bad, but you might get into troubles later.

When you power your Arduino Nano with a USB cable, it runs at 4.5V, and you are (barely) within the specifications.

On the other hand, the BMP280 and BME280 are very sensitive for high voltages at the SDA and SCL pins. The Wire library enables the internal pullup resistors, and that raises the SDA and SCL voltage levels.

If you have connected the 5V accidently to the VCC of your BMP280 module, the BMP280 is probably already broken (if your module is like the picture in the link you gave, that picture does not match the description below it).

If you want to keep the sensor happy, use a level shifter.
If you want to avoid troubles in the future, use a level shifter.
If you want to do what's right, buy a 3.3V Arduino board.

There are a lot of troubles with the BME280 and BMP280 libraries from Adafruit lately. I tried the Adafruit BME280 library and got too much troubles, so I had to change to another library as well.

@Koepel - Thank you!
You really saved me. I was planning to go feed the A Nano on external power (that is the next phase of my project). So far I run it on PC USB, on a 2 m cable (now I found that was a good thing).
today I am going to buy level shifters (few types, as the Sparkfun one is indencently expensive).

For a buck (see Tom Waits :-)))

or this one:

This one is around 3 USD:

They all claimed to be biderctional and looks like woirking on I2C. But I am not very convinced.

+++

I was thinking to 3.3 boards as well. But I have to build external 3.3 V sources, which are not so usual. On the other hand, I can - perhaps - go down to 3.3. V from one 3.7 LiIon 18650 unit, which would be nice.

Another point is that I love the Arduino nano! Is a little piece of engineering genius: matches mini breadbord, it is large enough to read the pins (by special glasses but anyway).

In the bar above the text field is an icon to insert a link.
For example Tom Waits "for a buck" : Tom Waits - "God's Away On Business" - YouTube 8)

All your links are to I2C level shifters, and they all work.
The most common I2C level shifter is with mosfets. They work good. Some have 2 channels, some have 4 channels.
The special chips might be better, but I'm not sure about it. As far as I know, the mosfets are good enough.

Adafruit has both types, Sparkfun has both types.

I have the 2-channel modules with the 3.3V voltage regulator on the module. That can be useful, since the Arduino Pro Micro does not have a 3.3V pin.

I shall see how to make sure I have a common ground. Sounds trivial, but I had difficult time in the past after mounting sensors on two different board pins marked GND.

Koepel:
On the other hand, the BMP280 and BME280 are very sensitive for high voltages at the SDA and SCL pins. The Wire library enables the internal pullup resistors, and that raises the SDA and SCL voltage levels.

interesting, i would like to use the BMP280 because its cheaper than the BME280-5v and i need a 5v arduino board because i'm on an RC airplane with 5V electronics. if i want to run without level shifter, is there a way to tweek the wire library not to enable the pullups? thanks

You need pull-ups somewhere, or I2C doesn't work.

The BMP280 sensor is a 3.3V device, no way around that. You're going to need a 3.3V regulator and level shifters. Easiest of course is to simply get a breakout board with those installed already, they don't cost much more than the barebones breakout boards (and are definitely available for both the BME280 and BMP280).

wvmarle:
You need pull-ups somewhere, or I2C doesn't work.

The BMP280 sensor is a 3.3V device, no way around that. You're going to need a 3.3V regulator and level shifters. Easiest of course is to simply get a breakout board with those installed already, they don't cost much more than the barebones breakout boards (and are definitely available for both the BME280 and BMP280).

i'm new to arduino but i think the 5v uno and nano boards come with 3.3v outputs right? can i just add my own I2C pullups to 3.3v?

True - and hacking the Wire library may even be possible.

Lots of effort and serious risk of a broken sensor just to avoid spending a few cents on a board with level shifters and regulators.

wvmarle:
True - and hacking the Wire library may even be possible.

Lots of effort and serious risk of a broken sensor just to avoid spending a few cents on a board with level shifters and regulators.

i don't care about a few bucks for prototypes but when i go into production, every dollar counts

Why don't you get it working first, then?

You're a VERY long way from any mass production if you're still considering Nano and even Uno boards... it sounds like you have a year or more of learning ahead of you. When you really understand what you're doing (and from your questioning I don't really get the feeling you do) it's going to be a lot easier to get your custom boards and so done.

i got a 3.3V BMP280 and a 5V MPU650 working on the same i2c bus without level shifters

i copied the Wire library and made my own version NoPUWire and patched out the internal pullup enables like this
void NoPUtwi_init(void)

{
 // initialize state
 twi_state = TWI_READY;
 twi_sendStop = true; // default value
 twi_inRepStart = false;
 
 // activate internal pullups for twi.
 //digitalWrite(SDA, 1);
 //digitalWrite(SCL, 1);

 ...
}

then i power the BMP from 3.3V and put 10K pullups to 3.3V on A3 and A4, both BMP and MPU are working fine

steveh2112:
i got a 3.3V BMP280 and a 5V MPU650 working on the same i2c bus without level shifters

[...]

then i power the BMP from 3.3V and put 10K pullups to 3.3V on A3 and A4, both BMP and MPU are working fine

A quick look at the MPU6050 (there's no MPU650) data sheet page 8 showed me how poorly you did your homework, and how little you know about the products you're trying to work with:

VDD = 2.375V-3.46V

So it's actually a 3.3V device. That means whatever breakout board you have this sensor on must have level shifters and a regulator built in.

So get a 8 MHz Arduino, and you can power the whole thing from two AA or AAA batteries without the use of level shifters or regulator. Or you can power it off a 3.7V LiPo with LDO regulator.

i'm using a nano, it has a 3.3V supply on it, i tested it and it is 3.3V and powers the BMP board fine

interesting about the MPU6050, i guess the circuit board its on has 5v level shifters. anyhow, i have a 3.3V i2c bus now and both devices are working

steveh2112:
i'm using a nano, it has a 3.3V supply on it, i tested it and it is 3.3V and powers the BMP board fine

interesting about the MPU6050, i guess the circuit board its on has 5v level shifters. anyhow, i have a 3.3V i2c bus now and both devices are working

Remember that whilst the Nano (and Uno) have a 3.3V supply on them, the logic pins are still at 5V level.

So your I2C bus will still be operating at 5V, even if the MPU6050 has its own logic level shifters on it.

What is very confusing, is that some breakout boards are referred to by the name of the particular IC on them. A BME280 or MPU6050 is a bare IC, it has no other components.

A BME280 breakout board is not the same thing, its a board, which may or may not have a regulator on it and may or not have voltage level shifters on it, with a BME280 on it.

i actually started to notice that the MPU board sometimes failed to initialize or run for a long time, and i wondered if it was the change, so i disconnected the BMP and went back to the standard wire library with the internal pullup, but same problem, flaky operation.

so anyhow, a poke around revealed it was my crappy soldering again!

so now its reliable on 5V and haven't tried 3.3V again

however, i already bought some level shifters, 5 for a $1 i think, so i think maybe i'll just use them with the BMP
. just a few extra wires i guess, no big deal, then at least its all running at spec

The Arduino's internal pull-ups are also too weak for I2C use - they're about 20-30k, while the spec says no more than 10k.

Now most of these breakout boards have 10k pull-ups on board, so as long as you have the MPU board connected, your I2C bus will be pulled higher than 3.3V. If both breakout boards have 10k pull-ups (as is common), your bus will end up at about 4.15V. The pull-up resistor that's connected to 3.3V effectively becomes a pull-down...

thanks for the info, if i had a scope i'd check it out, maybe need to look for one on ebay

This you should be able to measure with your multimeter, as in most applications the bus is most of the time idle and pulled high.

wvmarle:
This you should be able to measure with your multimeter, as in most applications the bus is most of the time idle and pulled high.

true, if i don't initialize the i2c devices