-
Notifications
You must be signed in to change notification settings - Fork 0
/
BMP180_Pressure_Sensor.ino
60 lines (52 loc) · 1.18 KB
/
BMP180_Pressure_Sensor.ino
1
2
3
4
5
6
7
8
9
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
BMP180/BME180 Pressure sensor with Arduino!
https://www.clevertronics.blogspot.com
Used Hardware : Arduino UNO
Used IDE : Arduino IDE 1.8.12
Interphase : I2C [SDA-->A4, SCL-->A5]
*/
#include <SFE_BMP180.h>
#include <Wire.h>
SFE_BMP180 pressure;
void setup()
{
Serial.begin(9600);
if (pressure.begin())
Serial.println("BMP180 initialised");
else
{
Serial.println("BMP180 initialisation failed \n\n");
while(1);
}
}
void loop()
{
char status;
double T,P;
status = pressure.startTemperature();
if (status != 0)
{
delay(status);
status = pressure.getTemperature(T); //getting pressure value.
if (status != 0)
{
Serial.print("Temperature: ");
Serial.print(T);
Serial.println(" *C, ");
status = pressure.startPressure(3);
if (status != 0)
{
delay(status);
status = pressure.getPressure(P,T); //getting temperature value.
if (status != 0)
{
Serial.print("Absolute pressure: ");
Serial.print(P);
Serial.println(" mb ");
Serial.println("");
}
}
}
}
delay(1000);
}