WemosD1 R1 board is now  the most preferred IOT WIFI Board .As the hardware resembles Arduino , it is most sought out  board for any IOT project , than NODEMCU.

To add a display I prefer to use the SERIAL LCD WITH I2C BACKPACK  .

The serial LCD is built on PCF8574 &  works on I2C Bus ,thus requires only 2 wires SCL & SDA apart from the power pins.

The LCD works on 5V & it can be sourced from D1 board itself.

 

IMG_20180416_130653

For more detailed information on this Serial LCD you can read my previous blog here :

https://alselectro.wordpress.com/2016/05/12/serial-lcd-i2c-module-pcf8574/

 

The connection between D1 board & LCD is simple .

Wemos D1      LCD

5v           —–  Vcc

Gnd        —- Gnd

SCL  D15  (GPIO5)  —    SCL

SDA  D14   (GPIO4)   — SDA

To start with download the latest Library from this link :

https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads

From Arduino IDE  Sketch –> Include library –> Add ZIP Library

Browse to the location of the downloaded ZIP file & select it

Image 2

Now the Library for Serial LCD is installed.

Image 3

 

Under Tools selectthe board as WEMOS D1 R1 , upload speed as 115200, port is the one allotted  in Device manager &programmer USBASP.

Image 4

Read this previous blog post of getting started with D1 board, on how to install Arduino core using Boards Manager

https://alselectro.wordpress.com/2018/04/14/wifi-esp8266-development-board-wemos-d1/

 

Now we need to know the I2C Address of the LCD board connected to D1.

For this upload the following Scanner sketch.

http://www.alselectro.com/files/Library_codeexamples.zip

 

Image 5

 

Once uploaded,Open the serial monitor with 9600 baud setting.

The I2C HEX Address of the device is displayed .Here it is 0x27 .

Note that this address varies according to the manufacturer and the jumper solder on A0 A1 A2 pins on the backpack pcb.

 

Image 6

Now open the first example lcd_test.

In this example 2 header files are used

One is the Wire.h ,which is the I2C library that is built in already with IDE.

Second  is the LiquidCrystal_I2C.h which we installed initially.

Then we create an instance  lcd with parameters I2C Address  , EN , RW , RS , D4,D5,D6,D7

I2C address is the ine we got from the scanner code –0x27

EN,RW,RS are the pins of I2C board connected to LCD Enable ,Read/Write & Register Select respectively.

D4 to D7 are Data pins

 

Image 3

lcd,begin(16,2) initializes the 16 x 2 LCD

Then we set the backlight ON for the LCD

lcd.home()moves the cursor to Home position

lcd.print(“,,,,”) prints the message on 1st row.

lcd.setCursor(0,1) moves the cursor to second line.

 

Image 7

 

Upload the code to see the result on LCD.

The Contrast to LCD can be adjusted by the preset on the back.

 

IMG_20180416_164802

 

Here is the second example which prints the message typed on the Serial monitor.

 

Image 8

 

Image 9

VIDEO  :

blog_image

Advertisements