Skip to content

Instantly share code, notes, and snippets.

@elktros
Created March 29, 2021 10:34
Show Gist options
  • Save elktros/19e4b9ce209c42bbf6534fdc1d7b67b5 to your computer and use it in GitHub Desktop.
Save elktros/19e4b9ce209c42bbf6534fdc1d7b67b5 to your computer and use it in GitHub Desktop.
Code for ESP32 BMP180 I2C LCD.
#include <Adafruit_BMP085.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
/Adafruit_BMP085 bmp;
LiquidCrystal_I2C lcd(0x3F, 16, 2);
byte degree_symbol[8] =
{
0b00111,
0b00101,
0b00111,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000
};
void setup()
{
lcd.init();
lcd.backlight();
lcd.setCursor(0,0);
lcd.print(" BMP180 with ");
lcd.setCursor(0,1);
lcd.print(" ESP32 DevKit ");
lcd.createChar(0, degree_symbol);
if (!bmp.begin())
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" BMP180 Sensor ");
lcd.setCursor(0,1);
lcd.print(" not found ! ! !");
while (1)
{
}
}
delay(2000);
lcd.clear();
}
void loop()
{
lcd.setCursor(0,0);
lcd.print("Pressure=");
lcd.setCursor(9,0);
lcd.print(bmp.readPressure());
lcd.setCursor(13,0);
lcd.print("hPa");
lcd.setCursor(0,1);
lcd.print(" Temp = ");
lcd.setCursor(9,1);
lcd.print(bmp.readTemperature());
lcd.write(0);
lcd.print("C");
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment