Arduino Uno

Header

Corner
-->

Barometric pressure

Photo

pressure sensor

Sample code

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// load the BMP085 library
#include <BMP085.h>
// load the WIRE library
#include <Wire.h>

// define the BMP085 sensor
BMP085 bmp = BMP085();
// ... and it's return variables

long Temperature = 0, Pressure = 0;
void setup()
{
  // open te serial output with 115200 baud  
  Serial.begin(115200);
  Serial.println("Starting");
  
  // init the BMP085 sensor
  bmp.init(MODE_STANDARD, 25000, true);
}

void loop()
{
  // get temperature and pressure
  bmp.getTemperature(&Temperature);
  bmp.getPressure(&Pressure);
  // convert them
  float temperatureC = Temperature*0.1;
  float pressure = Pressure*0.01;
  
  // print it on the serial output
  Serial.print("Temperature = ");
  Serial.println(temperatureC);
  Serial.print("Pressure = ");
  Serial.println(pressure);
 
  // wait a second
  delay(1000);
}