Introduction: NODEMCU LUA ESP8266 With I2C LCD 128 X 64 OLED Display
Driving an I2C 128 x 64 OLED display is relatively easy with an ESP8266 as the library is already built into NodeMCU. As only 2 outputs are required, it is possible for the ESP01 to drive this display as well. On the ESP8266 the I2C is configurable to any I/O pins. I have used GPIOs 0 and 2 to keep compatibility with all the boards.
Step 1: Graphics Test
This program shows some of the features built into NodeMCU Lua from u8g and a way of using the tmr.alarm(). More information can be found here.
Step 2: Display a Bitmap Image
This program shows how to load bitmaps and display them on screen. The bitmaps need to be loaded into the ESP8266 as shown.
The images were converted with this image editor. Select MONO from the drop down box and click "Select Format" button. On the next screen "Choose file" and then "Convert and Download". The files come back with the .MONO extension - change this to xbm. I used png files already at 128 x 64 pixels (This can be done with Microsoft's paint program).
NOTE for completeness, I have included the original .png files in the compressed file, they are not needed for the Lua program (use the .xbm files for this)
Step 3: Scroll Text
This program scrolls the text "Hello World" from the top left to bottom right of the screen. Changing the timer setting to anything much lower than 250 causes the program to hang and the ESP to reset. You need to set a font before you try and print to screen otherwise you get one of those errors which don't seem to have a good description of what is wrong. (e.g. disp:setFont(u8g.font_6x10) ).
Step 4: More Information
There are now more and more Lua programs appearing these days. I have written my programs from bits and pieces found on the web and from trial and error. These might not be the most elegant programs around, but they do work and hope that they will help others with their ideas.
Another program that might be useful can be found here.