/**************************************************************************/
/*!
@file Adafruit_MPL3115A2.cpp
@author K.Townsend (Adafruit Industries)
@license BSD (see license.txt)
Example for the MPL3115A2 barometric pressure sensor
This is a library for the Adafruit MPL3115A2 breakout
----> https://www.adafruit.com/products/1893
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
@section HISTORY
v1.0 - First release
*/
/**************************************************************************/
#include <Adafruit_MPL3115A2.h>
Adafruit_MPL3115A2 baro;
void setup() {
Serial.begin(9600);
while(!Serial);
Serial.println("Adafruit_MPL3115A2 test!");
if (!baro.begin()) {
Serial.println("Could not find sensor. Check wiring.");
while(1);
}
// use to set sea level pressure for current location
// this is needed for accurate altitude measurement
// STD SLP = 1013.26 hPa
baro.setSeaPressure(1013.26);
}
void loop() {
float pressure = baro.getPressure();
float altitude = baro.getAltitude();
float temperature = baro.getTemperature();
Serial.println("-----------------");
Serial.print("pressure = "); Serial.print(pressure); Serial.println(" hPa");
Serial.print("altitude = "); Serial.print(altitude); Serial.println(" m");
Serial.print("temperature = "); Serial.print(temperature); Serial.println(" C");
delay(250);
}
I am not sure on this module, but some modules (DHT, for example) need a two-seconds gap between readings. Your delay is 1/4 of one second. As an experiment, increase the gap to two seconds ( delay (2000); ).