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

Picture of 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

Picture of 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

Picture of 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

Picture of 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.

Comments

elmusico101 (author)2016-08-11

Hi, I'm trying to use i2c with a dev board nodemcu Lolin v3. Yours is a v2 if I'm not wrong. Can you confirm that you have pull-up resistors on the board on the pins you are using for the sda, scl? Thanks!

timolor (author)2016-07-29

Hi, i have an LCD without and i2c module. Can you share your lcd connection without using the i2c module ?

AndyMardell (author)2016-05-23

Thankyou so much for sharing this. I have struggled to find info on this at all. One change to the code and it worked:

lcd.begin();

Needed to be changed to

lcd.init();

Guessing it's just a newer version of the library?

Thanks again

Max_LaChat (author)2016-04-05

Thanks for your Instructable. When you have some time, it would be interesting to see an Instructable on how you set up your entire system with the remote temperature NodeMCU nodes and the MQTT broker.

padeath (author)Max_LaChat2016-04-05

I'm working on this for an Instructable coming soon.

wold630 (author)2016-04-04

Thanks for sharing this!

padeath (author)wold6302016-04-04

No probs, I hope it was informative enough for my first Instructable. :)

About This Instructable

30,345views

95favorites

License:

Add instructable to: