Created
September 28, 2016 20:36
-
-
Save plumbum/d83d17430c1975d79c0e581ac48618ec 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 <LiquidCrystal_I2C.h> | |
#include <Adafruit_Sensor.h> | |
#include <Adafruit_BME280.h> | |
#define SEALEVELPRESSURE_HPA (1013.25) | |
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display | |
Adafruit_BME280 bme; // I2C | |
void setup() | |
{ | |
lcd.init(); // initialize the lcd | |
lcd.init(); | |
// Print a message to the LCD. | |
lcd.backlight(); | |
lcd.setCursor(0,0); | |
lcd.print("Hello, world!"); | |
Serial.begin(9600); | |
Serial.println(F("BME280 test")); | |
if (!bme.begin()) { | |
Serial.println("Could not find a valid BME280 sensor, check wiring!"); | |
while (1); | |
} | |
} | |
void loop() | |
{ | |
/* | |
lcd.setCursor(0,1); | |
lcd.print("Count:" + String(cnt++)); | |
*/ | |
lcd.setCursor(0,0); | |
lcd.print(String(bme.readTemperature()) + "\xef" + "C "); | |
lcd.print(String(bme.readHumidity()) + "% "); | |
lcd.setCursor(0,1); | |
lcd.print(String(bme.readPressure()*0.00750062F) + " mmH "); | |
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(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment