Programme BMP180
Mise en oeuvre du capteur avec un écran LCD pour afficheur.
Ce programme est basé sur le programme exemple de la bibliothèque BMP180.
arduino 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <Wire.h> #include <BMP180.h> #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x27,16,2); // Store an instance of the BMP180 sensor. BMP180 barometer; // We are going to use the on board LED for an indicator. int indicatorLed = 13; // Store the current sea level pressure at your location in Pascals. float seaLevelPressure = 101325; void setup() { Serial.begin(9600); // We start the I2C on the Arduino for communication with the BMP180 sensor. Wire.begin(); // Set up the Indicator LED. pinMode(indicatorLed, OUTPUT); // We create an instance of our BMP180 sensor. barometer = BMP180(); // We check to see if we can connect to the sensor. lcd.init(); // initialize the lcd lcd.noBacklight(); if(barometer.EnsureConnected()) { Serial.println("Connected to BMP180."); // Output we are connected to the computer. lcd.print("Connection BMP180 !"); digitalWrite(indicatorLed, HIGH); // Set our LED. // When we have connected, we reset the device to ensure a clean start. barometer.SoftReset(); // Now we initialize the sensor and pull the calibration data. barometer.Initialize(); } else { Serial.println("Could not connect to BMP180."); lcd.print("Pas de connection !"); digitalWrite(indicatorLed, LOW); // Set our LED. } } void loop() { if(barometer.IsConnected) { // Retrive the current pressure in Pascals. long currentPressure = barometer.GetPressure(); // Print out the Pressure. Serial.print("Pressure: "); Serial.print(currentPressure); Serial.print(" Pa"); // Retrive the current altitude (in meters). Current Sea Level Pressure is required for this. float altitude = barometer.GetAltitude(seaLevelPressure); // Print out the Altitude. Serial.print("\tAltitude: "); Serial.print(altitude); Serial.print(" m"); // Retrive the current temperature in degrees celcius. float currentTemperature = barometer.GetTemperature(); // Print out the Temperature Serial.print("\tTemperature: "); Serial.print(currentTemperature,1); Serial.write(176); Serial.print("C"); lcd.clear(); lcd.setCursor(0, 0); lcd.print("P = "); lcd.print(currentPressure);lcd.print(" Pa"); lcd.setCursor(0, 1); lcd.print("T = "); lcd.print(currentTemperature,1); lcd.write(223);lcd.print("C"); Serial.println(); // Start a new line. delay(1000); // Show new results every second. } }