Last active
February 3, 2019 09:33
-
-
Save tg44/747ed7aca638d667d07f7b5d62cbef79 to your computer and use it in GitHub Desktop.
Wemos D1 mini with BME280 test
This file contains hidden or 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_Sensor.h> | |
#include <SPI.h> | |
#include <Adafruit_BME280.h> | |
#define SEALEVELPRESSURE_HPA (1013.25) | |
Adafruit_BME280 bme; // I2C | |
void setup(void) { | |
Serial.begin(9600); | |
Serial.println(""); | |
Serial.println("BME280 Sensor Test"); | |
Serial.println(""); | |
Wire.begin(0, 2); | |
if (!bme.begin(0x77)) { | |
Serial.println("Could not find a valid BME280 sensor, check wiring!"); | |
while (1); | |
} | |
} | |
void loop(void) { | |
Serial.print("Temperature = "); | |
Serial.print(bme.readTemperature()); | |
Serial.println(" *C"); | |
Serial.print("Pressure = "); | |
Serial.print(bme.readPressure() / 100.0F); | |
Serial.println(" hPa"); | |
Serial.print("Approx. Altitude = "); | |
Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA)); | |
Serial.println(" m"); | |
Serial.print("Humidity = "); | |
Serial.print(bme.readHumidity()); | |
Serial.println(" %"); | |
Serial.println(); | |
delay(2000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment