BMP180 barometric pressure sensor example for STM32 Nucleo using the Arduino IDE

OK we are now going to look at various sensors attached to the STM32 Nucleo and all development will be done on the Arduino IDE – Install STM32 support in the Arduino IDE

The BMP180 is the new digital barometric pressure sensor of Bosch Sensortec, with a very high performance, which enables applications in advanced mobile devices, such as smartphones, tablet PCs and sports devices. It follows the BMP085 and brings many improvements, like the smaller size and the expansion of digital interfaces.

The ultra-low power consumption down to 3 μA makes the BMP180 the leader in power saving for your mobile devices. BMP180 is also distinguished by its very stable behavior (performance) with regard to the independency of the supply voltage.

More information at https://www.bosch-sensortec.com/bst/products/all_products/bmp180

Here is a typical module

bmp180
bmp180

Here is a quick wiring diagram, the critical thing here is that VCC is 3.3v

stm32 and bmp180
stm32 and bmp180

Code

You need to add support for the Adafruit BM085 library via the Manage Libraries in the Arduino IDE

#include <Wire.h>
#include <Adafruit_BMP085.h>
 
// Connect VCC of the BMP180 sensor to 3.3V
// Connect GND to Ground
// Connect SCL to i2c clock  thats A5
// Connect SDA to i2c data  thats A4
 
Adafruit_BMP085 bmp;
 
void setup() 
{
  Serial.begin(9600);
  if (!bmp.begin()) 
  {
	Serial.println("BMP180 sensor not found");
	while (1) {}
  }
}
 
void loop() {
    Serial.print("Temperature = ");
    Serial.print(bmp.readTemperature());
    Serial.println(" *C");
 
    Serial.print("Altitude = ");
    Serial.print(bmp.readAltitude(101500));
    Serial.println(" meters");
 
    Serial.println();
    delay(1000);
}

Output

This was the reading from the serial monitor

Temperature = 21.30 *C
Altitude = 47.65 meters

Temperature = 24.60 *C
Altitude = 43.14 meters

Temperature = 26.70 *C
Altitude = 35.97 meters

Temperature = 28.10 *C
Altitude = 36.22 meters

To see how accurate this was I went to http://elevationmap.net and typed in my address, the stated elevation was 99m. Given that there was probably an additional couple of metres where the device was located in my house that’s not too bad accuracy wise

 

Links
1PCS GY-68 BMP180 Replace BMP085 Digital Barometric Pressure Sensor Module For Arduino