Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*The Adafruit MPL115A2 is a digital barometric pressure sensor that communicates over I2C. Here's an example code in Arduino that reads the pressure and temperature from the sensor:
- Note: This code assumes that the Adafruit MPL115A2 sensor is connected to the I2C bus of the Arduino board. If you're using a different I2C bus or pins, you'll need to modify the mpl115a2 initialization accordingly.
- */
- #include <Wire.h>
- #include <Adafruit_MPL115A2.h>
- Adafruit_MPL115A2 mpl115a2;
- void setup() {
- Serial.begin(9600);
- if (!mpl115a2.begin()) {
- Serial.println("MPL115A2 not found!");
- while (1);
- }
- }
- void loop() {
- // read the pressure and temperature from the sensor
- float pressure = mpl115a2.getPressure();
- float temperature = mpl115a2.getTemperature();
- // print the pressure and temperature
- Serial.print("Pressure: ");
- Serial.print(pressure);
- Serial.println(" Pa");
- Serial.print("Temperature: ");
- Serial.print(temperature);
- Serial.println(" °C");
- // delay before reading from the sensor again
- delay(1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement