Introduction: Nodemcu Devkit (esp8266) Display Temperature on an I2c Lcd Display

In this Instructable I will show how I setup an esp8266 to control an i2c 20x4 lcd screen to display data from several sources which is collected by other esp8266 devices around my home.

I started off by getting the lcd display to work with the esp8266 without using the i2c module, this used 6 data lines from the esp, which obviously wouldn't leave a lot else left. So going the i2c module route was on the cards.

So I got myself an i2c module and soldered it to the lcd display and looked into how to get the esp to display data using the i2c library.

Step 1: Connect Up the Display

First of all up need to connect the display to the esp, I used ping D3 (GPIO0) and D4 (GPIO2). These go to the SDA and SCL on the i2c module which is soldered to the lcd display.

Then connect the power from Vin and GND from the esp to the VCC and GND on the i2c module.

Pretty straight forward really and as soon as I powered up the esp the lcd display lit up, obviously with no text being displayed though.

The fritzing diagram actually shows the wires going from the esp to the lcd display, this isn't actually how you need to connect this up, you need to use the i2c module which converts from the serial output from the SDA and SCL to the parallel that the lcd display needs to display the text.

Step 2: Programming

Just a very simple 'Hello, World!' script to start with to make sure things are working.

If this works then we'll all good to do something more with it.

https://github.com/build-stuffandthings/lcd_i2c_hello_world/blob/master/lcd_i2c_hello_world.pde

Step 3: Using MQTT to Display Data From Other Devices on the LCD Display

Now that the display is actually working we can display anything we want on it (text based anyway).

We can also use buttons to switch between 'menus' so that we can display more than 4 lines of data.

Connect a couple of buttons up to a couple of GPIO pins, I used D8 (GPIO15) and D2 (GPIO4). These buttons allow you to 'enter' a menu and also exit it, and scroll down the menu options.

My code is far from pretty but it does at least work:

https://github.com/build-stuffandthings/lcd_i2c_hello_world/blob/master/lcd_menu.pde

The fritzing diagram actually shows the wires going from the esp to the lcd display, this isn't actually how you need to connect this up, you need to use the i2c module which converts from the serial output from the SDA and SCL to the parallel that the lcd display needs to display the text.

Step 4: Sending Data From Other ESP8266 Devices to the MQTT Broker

The most important part of this project is to get the data from somewhere to send to the MQTT broker.

I run my own broker on my ubuntu server and I send the data from my other esp devices every minute, which the esp with the lcd display attached to it is then subscribed to and displays the data.

If anyone would like details on how I did this please comment and I'll make an Instructable about it.