Skip to content

Instantly share code, notes, and snippets.

@bavensky
Last active February 13, 2024 13:01
Show Gist options
  • Save bavensky/8cc772149df9e349014b to your computer and use it in GitHub Desktop.
Save bavensky/8cc772149df9e349014b to your computer and use it in GitHub Desktop.
ESP8266 with 20x4 i2c LCD [Arduino IDE]
// ESP8266 with 20x4 i2c LCD
// Compatible with the Arduino IDE 1.6.4
// Library https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library
// Bavensky :3
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x20,20,4);
uint8_t heart[8] = {0x0,0xa,0x1f,0x1f,0xe,0x4,0x0};
void setup() {
#Wire.begin(0, 2); // For ESP-01 device cc.isidorogv
lcd.begin();
lcd.backlight();
lcd.createChar(1, heart);
}
void loop() {
lcd.home();
lcd.print("Welcome to my world!");
lcd.setCursor(2, 1);
lcd.write(byte(1));
lcd.print(" ESP8266 with");
lcd.setCursor(0, 2);
lcd.print(" LiquidCrystal I2C ");
lcd.setCursor(0, 3);
lcd.print("ChiangMai Maker Club");
}
@BCSSOLIVI
Copy link

would it be possible to have the SDA and SCLK lines connected to GPIO9 and GPIO10 on the NodeMCU ?
Problem is that I'm already using all the pins on the other side (excepted TX) and I just want to connect a 2004A LCD display for setup/debug of values read on the ADC. I'm multiplexing 4 inputs for the ADC but need to trim them with a multi-turn potmeter and it would be much easier with the LCD rather then the serial monitor.
Furthermore, #Wire.begin(...) gives "invalid preprocessing directive #Wire" error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment