Barometer on an Arduino Uno
A BMP180 read with the Adafruit BMP085 library: temperature to a tenth of a degree, pressure to a pascal, and the altitude that pressure means. The whole build, an Arduino Uno and 1 more part, runs here in your browser on the firmware below; open it in the editor to change the wiring or the code and run it again.
Teaching? Assign it to your class in one click.
Intermediate Runs in your browser. Free, and no account needed.
The parts retail for about $32. On Mokxi they're free.
Step by step, with the wiring and the common mistakes: Arduino BMP180: Pressure, Altitude and Code
The code
The firmware exactly as the editor opens it. Change a line there and press Run: it compiles in the browser.
// Barometer: a BMP180 read with the Adafruit BMP085 library, which drives the
// BMP180 too: temperature, pressure and altitude.
//
// BMP180 (GY-68) SDA -> A4 SCL -> A5 VCC -> 5 V GND -> GND
//
// The sensor does not hand over degrees and pascals. It gives raw counts and
// eleven calibration words, and the library runs the datasheet's integer
// arithmetic to turn them into a temperature to a tenth of a degree and a
// pressure to a pascal. The altitude is the barometric formula against
// standard sea-level pressure, 101325 Pa, so it is only right on a day when
// the sea-level pressure is standard: weather moves it by tens of meters.
//
// Drag the two sliders on the breakout.
#include <Wire.h>
#include <Adafruit_BMP085.h>
Adafruit_BMP085 bmp;
void setup() {
Serial.begin(9600);
if (!bmp.begin()) {
Serial.println("Could not find a valid BMP085 sensor, check wiring!");
while (1) {
}
}
Serial.println("Barometer ready");
}
void loop() {
Serial.print("Temperature = ");
Serial.print(bmp.readTemperature(), 1);
Serial.print(" *C Pressure = ");
Serial.print(bmp.readPressure());
Serial.print(" Pa Altitude = ");
Serial.print(bmp.readAltitude(), 0);
Serial.println(" meters");
delay(500);
}
Parts list
3 parts, plus the jumper wires. They retail for about $32; on Mokxi they're free.
How it is wired
4 connections, pin by pin, read from the circuit itself. Each line is one set of pins joined together, by a jumper wire or a breadboard strip.
- Arduino Uno R3 pin 5V; BMP180 pressure sensor pin VCC
- Ground: Arduino Uno R3 pin GND; BMP180 pressure sensor pin GND
- Arduino Uno R3 pin A4; BMP180 pressure sensor pin SDA
- Arduino Uno R3 pin A5; BMP180 pressure sensor pin SCL
Change it and keep it
Open it in the editor, change the circuit or the code, and keep your version in a free account.