arduino/libraries/I2C-Sensor-Lib_iLib/examples/i2c_MPL3115A2/i2c_MPL3115A2.ino

50 lines
815 B
Arduino
Raw Normal View History

2018-11-03 20:21:33 +00:00
#include <Wire.h>
#include "i2c.h"
#include "i2c_MPL3115A2.h"
MPL3115A2 mpl3115;
void setup()
{
Serial.begin(115200);
Serial.print("Probe MPL3115A2: ");
if (mpl3115.initialize()) Serial.println("Sensor found");
else
{
Serial.println("Sensor missing");
while (1) {}
}
// onetime-measure:
mpl3115.setEnabled(0);
mpl3115.triggerMeasurement();
}
void loop()
{
mpl3115.awaitMeasurement();
float altitude;
mpl3115.getAltitude(altitude);
float temperature;
mpl3115.getTemperature(temperature);
mpl3115.triggerMeasurement();
Serial.print(" Height: ");
Serial.print(altitude);
Serial.print(" Temp: ");
Serial.print(temperature);
Serial.println("");
}
/**<
Program size:
A1.0.5:
A1.5.7: 6980b
A1.6.3: 6890b / 495b
*/