Created
October 4, 2020 11:39
-
-
Save maxpromer/1d1bb84337e2a36c3fe882f4dca7c556 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wire.h> | |
#include <Adafruit_BMP280.h> | |
Adafruit_BMP280 bmp; // I2C | |
void setup() { | |
Serial.begin(115200); | |
Serial.println(F("BMP280 test")); | |
if (!bmp.begin(0x76)) { | |
Serial.println(F("Could not find a valid BMP280 sensor, check wiring!")); | |
while (1); | |
} | |
/* Default settings from datasheet. */ | |
bmp.setSampling(Adafruit_BMP280::MODE_NORMAL, /* Operating Mode. */ | |
Adafruit_BMP280::SAMPLING_X2, /* Temp. oversampling */ | |
Adafruit_BMP280::SAMPLING_X16, /* Pressure oversampling */ | |
Adafruit_BMP280::FILTER_X16, /* Filtering. */ | |
Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */ | |
} | |
void loop() { | |
Serial.print(F("Temperature = ")); | |
Serial.print(bmp.readTemperature()); | |
Serial.println(" *C"); | |
Serial.print(F("Pressure = ")); | |
Serial.print(bmp.readPressure()); | |
Serial.println(" Pa"); | |
Serial.print(F("Approx altitude = ")); | |
Serial.print(bmp.readAltitude(1013.25)); /* Adjusted to local forecast! */ | |
Serial.println(" m"); | |
Serial.println(); | |
delay(2000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment