![]() |
Illustration 1: LCD 1602 connected via I2C to ESP8266 |
Setup Arduino IDE
First we need to install LiquidCrystal-I2C-library.- Download lib as .zip from link above
- Install it (without unzipping) manually.
- Sketch -> Include Library -> Add .zip Library -> select downloaded LiquidCrystal lib
![]() |
Illustration 2: Arduino IDE Menu |
Wiring
In this example I used a module marked with "MH". For this module the hardware address for lcd is 0x3F. If you have an other module you have to google it.
We use SPI connection to save up some wires.
We use SPI connection to save up some wires.
Now let do the wiring schematic:
Connect the module like the picture below to your display. For detailed wiring information have a look to the pin connection in code comments below. Optional the module is soldered to your lcd so you can continue to wiring to ESP8266.
Connect the module like the picture below to your display. For detailed wiring information have a look to the pin connection in code comments below. Optional the module is soldered to your lcd so you can continue to wiring to ESP8266.
![]() |
Illustration 3: I2C Module |
Code
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
//Author: moayom.blogspot.com | |
//Date: 2018-07-28 | |
//LCD 1602 display ("MH" SPI Module) sample with ESP8266 (Node MCU 1.0 ESP-12E Module) | |
#include <Wire.h> | |
#include <LiquidCrystal_I2C.h> | |
/* | |
wiring: | |
ESP8266 LCD1602 | |
D1 (GPIO5) --- SCL | |
D2 (GPIO4) --- SDA | |
VCC --- VCC (3.3 - 5.0V) | |
GND --- GND | |
*/ | |
// Set the LCD address to 0x27 for a 16 chars and 2 line display | |
LiquidCrystal_I2C lcd(0x3F, 16, 2); | |
void setup() | |
{ | |
// initialize the LCD | |
lcd.init(); | |
// Turn on the blacklight and print a message. | |
lcd.backlight(); | |
lcd.print("Mytechsamples"); | |
lcd.setCursor(0,1); | |
lcd.print(".blogspot.com"); | |
} | |
void loop() | |
{ | |
// Do nothing here... | |
} |
Keine Kommentare:
Kommentar veröffentlichen