Home CodeArduino Due Arduino Due and BMP085 example

Arduino Due and BMP085 example

by shedboy71

In this example we connect a BMp085 sensor to an Arduino Due, you can use this to measure barometric pressure and temperature

This sensor has been replaced by some newer versions but there are still many modules available so here is an example on how to use it

 

Schematics

Easy to connect up, you can see this in the layout below.

Code

I downloaded the library from https://github.com/adafruit/Adafruit-BMP085-Library and installed it

[codesyntax lang=”cpp”]

#include <Wire.h>
#include <Adafruit_BMP085.h>

Adafruit_BMP085 bmp;

void setup()
{
Serial.begin(9600);
if (!bmp.begin())
{
Serial.println("Could not find a BMP085 sensor!");
while (1) {}
}
}

void loop()
{
Serial.print("Temperature = ");
Serial.print(bmp.readTemperature());
Serial.println(" *C");

Serial.print("Pressure = ");
Serial.print(bmp.readPressure());
Serial.println(" Pa");

Serial.print("Altitude = ");
Serial.print(bmp.readAltitude());
Serial.println(" meters");

Serial.print("Real altitude = ");
Serial.print(bmp.readAltitude(101500));
Serial.println(" meters");

Serial.println();
delay(500);
}

[/codesyntax]

Output

Open the serial monitor and you should see something like this

Temperature = 27.30 *C
Pressure = 99058 Pa
Altitude = 190.05 meters
Real altitude = 204.46 meters

Temperature = 27.60 *C
Pressure = 99064 Pa
Altitude = 189.63 meters
Real altitude = 204.29 meters

Temperature = 27.90 *C
Pressure = 99062 Pa
Altitude = 189.54 meters
Real altitude = 203.78 meters

Share

You may also like