Modifications

Sauter à la navigation Sauter à la recherche
3 040 octets ajoutés ,  18 avril 2013 à 11:12
aucun résumé de modification
Ligne 3 : Ligne 3 :  
{{traduction}}
 
{{traduction}}
   −
{{bloc-etroit|text=x}}
+
{{bloc-etroit|text=To use this sensor and calculate the altitude and barometric pressure, there's a lot of very hairy and unpleasant math. You can check out the math in the datasheet but really, its not intuitive or educational - its just how the sensor works. So we took care of all the icky math and wrapped it up into a nice Arduino library. You can [http://learn.adafruit.com/bmp085/downloads download the library from github]]
   −
[[Fichier:BMP085--00.jpg|640px]]
+
Pour installer la librairie:
 +
* To download the library click the DOWNLOADS button in the top right corner.
 +
* rename the uncompressed folder '''Adafruit_BMP085'''. Check that the '''Adafruit_BMP085''' folder contains Adafruit_BMP085.cpp and '''Adafruit_BMP085.h'''
 +
* Place the BMP085 library folder yourarduinosketchfolder/libraries/ folder. You may need to create the libraries subfolder if its your first library.
 +
* Restart the IDE.
 +
 
 +
Now you can run this first example sketch.
 +
}}
 +
 
 +
<nowiki>    #include "Wire.h"
 +
    #include "Adafruit_BMP085.h"
 +
    Adafruit_BMP085 bmp;
 +
    void setup() {
 +
    Serial.begin(9600);
 +
    bmp.begin();
 +
    }
 +
    void loop() {
 +
    Serial.print("Temperature = ");
 +
    Serial.print(bmp.readTemperature());
 +
    Serial.println(" *C");
 +
    Serial.print("Pressure = ");
 +
    Serial.print(bmp.readPressure());
 +
    Serial.println(" Pa");
 +
    Serial.println();
 +
    delay(500);
 +
    }/<nowiki>
 +
 
 +
Then open up the serial monitor at 9600 baud. The sketch will continuously print out the temperature in '''°C''' and pressure in '''Pa''' (Pascals). You can test that the sensor is measuring variations in temperature and pressure by placing your fingertip over the open port hole in the top of the sensor. The temperature and pressure will increase as you can see here:
 +
 
 +
[[Fichier:BMP085-Utiliser-00.jpg|640px]]
 +
 
 +
== Altitude Measurements ==
 +
Since we know that pressure drops as we gain altitude (that's why air is so thin on mountain-tops) we can compute the current altitude knowing the pressure and temperature. Again, there's a bit of hairy math involved, [http://en.wikipedia.org/wiki/Barometric_pressure you can read about the calculations on wikipedia] (where this graph is from).
 +
 
 +
[[Fichier:BMP085-Utiliser-01.png|640px]]<br />
 +
<small>Source: [http://en.wikipedia.org/wiki/Barometric_pressure Wikipedia]</small>
 +
 
 +
With the Arduino library, we take care of that for you! Simply run this sketch which will return the current altitude based on the pressure.
 +
 
 +
<nowiki>    #include "Wire.h"
 +
    #include "Adafruit_BMP085.h"
 +
    Adafruit_BMP085 bmp;
 +
    void setup() {
 +
    Serial.begin(9600);
 +
    bmp.begin();
 +
    }
 +
    void loop() {
 +
    Serial.print("Temperature = ");
 +
    Serial.print(bmp.readTemperature());
 +
    Serial.println(" *C");
 +
    Serial.print("Pressure = ");
 +
    Serial.print(bmp.readPressure());
 +
    Serial.println(" Pa");
 +
    // Calculate altitude assuming 'standard' barometric
 +
    // pressure of 1013.25 millibar = 101325 Pascal
 +
    Serial.print("Altitude = ");
 +
    Serial.print(bmp.readAltitude());
 +
    Serial.println(" meters");
 +
    Serial.println();
 +
    delay(500);
 +
    }</nowiki>
 +
 
 +
Run the sketch to see the calculated altitude.
    
{{BMP085-TRAILER}}
 
{{BMP085-TRAILER}}
29 917

modifications

Menu de navigation