#include #include #include #define SEALEVELPRESSURE_HPA (1013.25) Adafruit_BME280 bme; // I2C const int bmeVinPin = 12;// 5V pin for BME280 #include // Set the LCD address to 0x27 or 0x3F for a 16 chars and 2 line display LiquidCrystal_I2C lcd(0x27, 16, 2); void setup() { pinMode(bmeVinPin, OUTPUT);// set pin as output digitalWrite(bmeVinPin,HIGH);// always keep it high (5V) for BMB280 module bool status; status = bme.begin(); if (!status) { Serial.println("Could not find a valid BME280 sensor."); while (1); } lcd.begin(); lcd.backlight(); lcd.print("0123456789!@#$%^"); lcd.setCursor (0,1); // go to start of 2nd line lcd.print("ABCDEFGHIJKLMNOP"); delay(500); } void loop() { String str; lcd.clear(); lcd.setCursor(0,0); str = "Temp.: " + String(bme.readTemperature()) + (char)223 + "C"; lcd.print(str); // Fahrenheit = value * 9 / 5 + 32 // Kelvin = value + 273.15 lcd.setCursor(0,1); str = "Humidity:" + String(bme.readHumidity()) + "%"; lcd.print(str); delay(5000); lcd.clear(); lcd.setCursor(0,0); str = "Pressure:" + String(bme.readPressure() / 100.0F) + "hPa"; lcd.print(str); lcd.setCursor(0,1); str = "Altitude:" + String(bme.readAltitude(SEALEVELPRESSURE_HPA)) + "m"; lcd.print(str); delay(5000); }