Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Wire.h>
- #include <Adafruit_Sensor.h>
- #include <Adafruit_BME280.h>
- #define SEALEVELPRESSURE_HPA (1013.25) // Change this to your local sea level pressure (hPa)
- Adafruit_BME280 bme;
- void setup() {
- Serial.begin(9600);
- if (!bme.begin(0x76)) {
- Serial.println("Could not find a valid BME280 sensor, check wiring!");
- while (1);
- }
- }
- void loop() {
- Serial.print("Temperature = ");
- Serial.print(bme.readTemperature());
- Serial.println(" *C");
- Serial.print("Humidity = ");
- Serial.print(bme.readHumidity());
- Serial.println("%");
- Serial.print("Pressure = ");
- Serial.print(bme.readPressure() / 100.0F); // hPa to Pa conversion
- Serial.println(" hPa");
- Serial.print("Approx. Altitude = ");
- Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
- Serial.println(" m");
- Serial.println();
- delay(2000); // Delay for 2 seconds (2000 ms) between each reading
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement