Include Edit BMP
Include Edit BMP
Include Edit BMP
Adafruit_BME280 BME280;
void setup() {
Serial.begin(9600);
Serial.println(F("Arduino + BME280"));
if (!BME280.begin(BME280_I2C_ADDRESS))
{
Serial.println("Could not find a valid BME280 sensor, check
wiring!");
while (1);
}
lcd.setCursor(0, 0);
lcd.print("Temp:");
lcd.setCursor(0, 1);
lcd.print("Pres:");
}
char text[14];
// main loop
void loop()
{
// get temperature, pressure and altitude from library
float temperature = BME280.readTemperature(); // get temperature
float pressure = BME280.readPressure(); // get pressure
float altitude_ = BME280.readAltitude(1013.25); // get altitude
(this should be adjusted to your local forecast)
}
Edit
// 1: print temperature
lcd.setCursor(0, 0);
lcd.print("Temp:");
sprintf(text, "%d.%02u %cC ", (int)temperature, (int)(temperature *
100)%100,223);//%sebelum "cC" menunjukkan simbol derajat pada lcd, "223" untuk
mempertahankan simbol degree
lcd.setCursor(6, 0);//"(6, 0)" angka 6 menunjukkan posisi awal angka yang akan muncul di
lcd, 0 merupakan baris pertama
lcd.print(text);
// 2: print pressure
lcd.setCursor(0, 1);
lcd.print("Pres:");
sprintf(text, "%u.%02u hPa ", (int)(pressure/100), (int)((uint32_t)pressure % 100));
lcd.setCursor(5, 1);
lcd.print(text);
lcd.clear ();
delay (2000);
edit
lcd.clear ();
delay(2000);
lcd.clear ();
delay (2000);
lcd.setCursor(0, 0);
lcd.print("Alt:");
lcd.setCursor(0, 1);
lcd.print("Klbb:");
// 3: print Altitude
sprintf(text, "%d.%02u %cC ", (int)temperature, (int)(temperature *
100)%100,223);//%sebelum "cC" menunjukkan simbol derajat pada lcd, "223" untuk
mempertahankan simbol degree
lcd.setCursor(6, 0);//"(6, 0)" angka 6 menunjukkan posisi awal angka yang akan muncul di
lcd, 0 merupakan baris pertama
lcd.print(text);
// 4: print Humidity
sprintf(text, "%u.%02u hPa ", (int)(pressure/100), (int)((uint32_t)pressure % 100));
lcd.setCursor(5, 1);
lcd.print(text);
lcd.clear ();
delay(2000);