#include #include #include /* Connexion: VCC -> 3V3 GND -> GND SCL -> D6 */ Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified(10085); /**************************************************************************/ /* Arduino setup function (automatically called at startup) */ /**************************************************************************/ void setup(void) { Serial.begin(9600); /* Initialisation du capteur */ Wire.begin(D5,D6); if(!bmp.begin()) { Serial.print("Erreur : aucun capteur BMP085 detecte"); while(1); } } void loop(void) { /* Récupère les données (événement) du capteur */ sensors_event_t event; bmp.getEvent(&event); /* Affichage des resultats */ if (event.pressure) { /* Display atmospheric pressue in hPa */ Serial.print("Pressure: "); Serial.print(event.pressure); Serial.println(" hPa"); /* Affichage de la temperature */ float temperature; bmp.getTemperature(&temperature); Serial.print("Temperature: "); Serial.print(temperature); Serial.println(" C"); /* Calculating altitude with reasonable accuracy requires pressure * * sea level pressure for your position at the moment the data is * * converted, as well as the ambient temperature in degress * * celcius. If you don't have these values, a 'generic' value of * * 1013.25 hPa can be used (defined as SENSORS_PRESSURE_SEALEVELHPA * * in sensors.h), but this isn't ideal and will give variable * * results from one day to the next. * * * * You can usually find the current SLP value by looking at weather * * websites or from environmental information centers near any major * * airport. * * * * For example, for Paris, France you can check the current mean * * pressure and sea level at: http://bit.ly/16Au8ol */ /* Calcul de l'altitude en fonction de la pression et de la temperature */ float seaLevelPressure = SENSORS_PRESSURE_SEALEVELHPA; Serial.print("Altitude: "); Serial.print(bmp.pressureToAltitude(seaLevelPressure, event.pressure)); Serial.println(" m"); Serial.println(""); } else { Serial.println("Sensor error"); } delay(1000); }