Freitag, 27. Juli 2018

LCD 1602 I2C connected to ESP8266

In this post I will show you a quick tutorial how to use lcd 1602 with ESP8266 via I2C connection.

Illustration 1: LCD 1602 connected via I2C to ESP8266

Setup Arduino IDE 

First we need to install LiquidCrystal-I2C-library.


  1. Download lib as .zip from link above
  2. Install it (without unzipping) manually.
    1. 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.

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.

Illustration 3: I2C Module




Code



//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...
}
view raw gistfile1.txt hosted with ❤ by GitHub

Keine Kommentare:

Kommentar veröffentlichen

Post Top Ad

Your Ad Spot