BMP180 with Pro Mini 3.3V [SOLVED]

Hello everyone. I have a problem with BMP180 pressure sensor and Arduino Pro Mini 3.3V. I'm using SFE_BMP180 library and i noticed, that i have difference in measurements between Pro Mini and Mega2560. Here's the example results:

provided altitude: 220 meters, 722 feet
temperature: 24.97 deg C, 76.94 deg F
absolute pressure: 985.95 mb, 29.12 inHg
relative (sea-level) pressure: 1012.06 mb, 29.89 inHg
computed altitude: 220 meters, 722 feet


provided altitude: 220 meters, 722 feet
temperature: 92.35 deg C, 198.23 deg F
absolute pressure: 747.81 mb, 22.09 inHg
relative (sea-level) pressure: 767.61 mb, 22.67 inHg
computed altitude: 220 meters, 722 feet

Mega's first, Mini's second. What's more, results from BH1750 on both boards are similar, so I think, it's not I2C problem. I've also noticed, that Mega gives results every 5 seconds (delay(5000) on example, so it's correct), but Mini is 2x faster. I have to change also baud rate on Serial Monitor to 19200, because on 9600 I can see only garbage (in code Serial works on 9600). Is it possible, that 3.3V Mini should work with 8MHz? To make it more interesting, it happens, when I select ATmega328(3.3V, 8MHz) board, because on ATmega328(5V, 16MHz) it works fine. Power supply has about 3.3-3.4V.

Probably I don't understand something, so I'd be pleased to show, where I'm thinking in wrong way.

Regards, Jakub

Hi, welcome to the forum.

Please do not connect the BMP180 to the Arduino Mega 2560 board.

The Pro Mini 3.3V 8MHz board runs at 8MHz. That means it should have a 8MHz bootloader and the sketch should be compiled for 8MHz. I don’t care if it runs or not (I really don’t), we have to do it right.

Could you make a sketch that blinks the led at pin 13 every second ? Test it with a stopwatch to check it is okay.

Next step is a good library. Could you try the Adafruit library for the BMP180 ? They maintain the libraries and they are proven to work.

The Arduino Mega 2560 has pullup resistors of 10k on its board for SDA and SCL. That means it has a 5V I2C bus, and a 3.3V sensor should not connect to that I2C bus. You need a I2C level shifter.
With an Arduino Uno, a 3.3V sensor can connect to the I2C bus (in most cases).
A 3.3V sensor connecting to a 3.3V Arduino board is no problem at all of course :slight_smile:

I took a look at the code of SFE_BMP180 from Sparkfun. I spotted two problems. The readBytes() is already a function name in the Arduino library. I don’t know what the compiler will do with two the same names. And after Wire.requestFrom() waiting for the bytes to be available is wrong.

Peter_n: The Pro Mini 3.3V 8MHz board runs at 8MHz. That means it should have a 8MHz bootloader and the sketch should be compiled for 8MHz. I don't care if it runs or not (I really don't), we have to do it right.

I totally agree, that's why I wrote this topic.

Peter_n: Could you make a sketch that blinks the led at pin 13 every second ? Test it with a stopwatch to check it is okay.

It's not ok, it look's like, Mini is running 2x faster.

Peter_n: Next step is a good library. Could you try the Adafruit library for the BMP180 ? They maintain the libraries and they are proven to work.

Tried with Adafruit library, again rubbish at 9600 baud monitor, at 19200 results still wrong.

Temperature = 41.90 *C
Pressure = 70882 Pa
Altitude = 2534.11 meters
Pressure at sealevel (calculated) = 74353 Pa
Real altitude = 2547.73 meters

This is the Adafruit BMP085/BMP180 library : GitHub - adafruit/Adafruit_BMP085_Unified: Unified sensor driver for Adafruit's BMP085 & BMP180 breakouts
I assume that you tried the example from that library and not your own sketch. Is there any error output from the example sketch ? The output that you show is not the output from that example sketch.

However, first the Pro Mini should be running normal. Perhaps you have a 3.3V 8MHz version with a 16MHz crystal. Can you try to read the crystal or resonator with a magnifier ? Sometimes there is vaguely some text that starts with 8… or 16…

Can you be more precise ?
Did you select “Arduino Pro or Pro Mini” and “ATmega328 (3.3V, 8MHz)” ?
And after uploading, the sketch runs twice as fast and the baudrate is twice as high ? Then it must be a 16MHz crystal.

Are you sure the voltage regulator creates 3.3V and not 5V ? Perhaps it is a 5V 16MHz Pro Mini after all.

You could use it as a 5V 16MHz Pro Mini and ignore the fact that it runs at 3.3V. However running a ATmega328P at 3.3V with 16MHz is outside the specifications. You better buy a new Pro Mini from another supplier.

Peter_n: ...a 3.3V sensor should not connect to that I2C bus. You need a I2C level shifter.

That's what I thought too. But it seems that the BMP180 I2C interface pins are 5V tolerant.

I took a look at the code of SFE_BMP180 from Sparkfun. I spotted two problems. The readBytes() is already a function name in the Arduino library. I don't know what the compiler will do with two the same names. And after Wire.requestFrom() waiting for the bytes to be available is wrong.

The readBytes function is a method of the class so there is no namespace conflict. And the Wire.requestFrom() call is exactly the way the Adafruit library does it.

I wonder, could it be that the calibration parameters are not being loaded correctly at initialization on the Mega, perhaps due to some race condition?

I've used this library: https://github.com/adafruit/Adafruit-BMP085-Library

Peter_n: Did you select "Arduino Pro or Pro Mini" and "ATmega328 (3.3V, 8MHz)" ? And after uploading, the sketch runs twice as fast and the baudrate is twice as high ? Then it must be a 16MHz crystal.

In blink example you have delay(1000). On my Mini it works like delay(500). I don't have any magnifier, but there is something, like AX on resonator.

Peter_n: Are you sure the voltage regulator creates 3.3V and not 5V ?

Yes, I'm using external regulator: https://www.pololu.com/product/2122 It's part of bigger project, so I have to use 3.3V.

I've made another test. I gave 5V on RAW input in Mini and connected VCC to analog in Mega. I've got results about 670, so it's about 3.3V, which means it's not 5V 16MHz Pro Mini.

You don't have a multimeter ? You should get one :P

Okay, so the voltage regulator makes 3.3V and the crystal is probably 16MHz. That is a Pro Mini with the wrong component(s) :astonished: If it is a Pro Mini from Ebay, that is possible. Some cheap Pro Mini boards are bad designed and don't work well, other Pro Mini boards don't work at all.

Many use a 16MHz ATmega328P at 3.3V, but I don't advice it. As I wrote, that is outside the specifications of the datasheet. My only conclusion is also what I wrote before : You better buy a new Pro Mini from another supplier.

Peter_n:
You don’t have a multimeter ? You should get one :stuck_out_tongue:

I have multimeter, but I’m studying and left it in home, so I had to do something else to measure voltage. :wink:

Peter_n:
Many use a 16MHz ATmega328P at 3.3V, but I don’t advice it. As I wrote, that is outside the specifications of the datasheet. My only conclusion is also what I wrote before : You better buy a new Pro Mini from another supplier.

Probably that’s, what I’ll have to do. I’ll try to write to seller, maybe it was only bad lot.

And thank you for your help.