Zonnestroompanelen in Nederland

duurzaamheid achter de meter

(40) ESP8266 and ST7920 powered 128*64 Liquid Crystal Display in a test bench

Floris Wouterlood – June 9, 2020

In this paper the construction of a test bench is described whose main components are a Wemos D1 mini ESP8266 family microprocessor board and a 128*64 graphical LCD. Both components are placed on dedicated pin headers. Additional pin headers on the test bench support sensor signal input, output, communication and power for devices being tested.

After a period of fiddling with breadboards, jumper wires and various displays it is sometimes opportune to convert a promising contraption into a less fragile, more permanent and, most of all, stable environment. The ‘test bench’ thus assembled can be used to focus completely on display behavior, library options, sensors, external output devices and communication. Here we discuss the construction of a test bench platform centered around a ESP8266 family microcontroller board: the Wemos D1 mini. I like the D1’s small footprint and its compatibility with the Lolin NodeMCU. It is also fully supported by the Arduino IDE.

Figure 1: The Wemos D1 mini 128*64 LCD test bench platform, completed and up and running. The two main components are positioned on pin headers soldered onto a 70×90 mm double-sided universal PCB. The extra pin headers are connected to unoccupied pins of the Wemos.

The test platform (figure 1) is equipped with a 128*64 LCD controlled by a ST7920 chip. These displays have relatively large pixels. In addition they are extremely robust and easy to program. They require only three wires (SPI protocol). This makes remaining pins of the Wemos D1 available for sensors, leds and other external equipment. A superior advantage of the 128*64 LCD compared with a 20*4 LCD is that the ST7920 controller allows graphical functions such as circles, rectangles, triangles, lines and graphs. Combined with Oliver Kraus’ powerful <U8g2lib.h> library we have an Arduino-compatible platform ready for testing a range of devices and sketches. Such an ESP8266 – 128*64 LCD test bench will be a valuable addition to the previously constructed Arduino Nano – 128*64 LCD test bench*.

Required electronic parts

All the parts of the 128*64 Arduino Wemos D1 mini test bench are positioned on a 70×90 mm universal prototyping board (PCB) (schematic layout in figure 2).

Figure 2: Design of the test bench PCB with its main pin headers. Left: top view. The ‘support’ adds mechanical stability to the LCD breakout board. The hole drilled gives after completion access to the contrast trimming potentiometer on the back of the LCD. Right: bottom view with all the wiring planned here. Having a bottom view at hand during the soldering of the wires can be quite helpful.

  • 1x 70×90 mm double-sided universal Printed Circuit Board (PCB)
  • 2x 8 pin female pin header: ‘Wemos D1 mini support pin headers’
  • 1x 20 pin female pin header: ‘128*64 LCD pin header’
  • 1x 6 pin female pin header: ‘Wemos remaining pin header-1’
  • 1x 4 pin female pin header: ‘’Wemos remaining pin header-2’
  • 2x 3 pin male pin header: ‘power (red) and GND (black) pin headers’
  • 1x 3 pin female header: serves as mechanical support for the LCD
  • 4x nylon spacer with nylon bolt and screw
  • 1x Wemos D mini
  • 1x 128×64 ST7920 Liquid Crystal Display breakout board (20-pin)

Wiring and pin connectivity
A comprehensive wiring diagram that includes extra pin headers is presented in figure 2. The essential wiring (Wemos to LCD) is presented in detail in figure 3.This set of wires connects specific pins of the Wemos pin headers with their corresponding pins of the display pin header. Additional sets of wires run between the Wemos pin header and the two test bench pin headers. Finally, a set of wiring concerns the auxiliary 3.3V and GND power pins.

Wemos D1 mini to 128*64 LCD pin header
ST7290 graphical LCD breakout boards for the Arduino (that is the breakout on which the actual 128*64 display is mounted) have 20 pins, usually marked 1 through 20, or GND, VCC, V0, RS, RW, E, DB0, DB1, DB2, DB3, DB4, DB5, DB6, DB7, PSB. NC, RST, Vout, BLA and BLK. Because we work via serial communication (SPI) the parallel interface will not be used. To effectuate this, pin 15 of the pin header needs to be connected with GND. Because of SPI communication the LCD pin header requires only three wires: RS (chip select – sometimes called CS) to pin 4, Data (R/W – sometimes called MOSI) to pin 5 and Clock (CLK) to pin 6.

LCD breakout board pin number table

As can be seen in Figure 3 we need to solder the wires on the Wemos pin header side such that the chip select wire connects to pin D5, the data wire to pin D7 and the clock wire to pin D8 (figure 3).

5V, 3.3V and GND
In addition to the SPI wires the LCD needs 5V on pin 2, 3.3V on pin 19 and GND on pins 1, 15 and 20. The LCD controller chip needs 5V and won’t do much on 3.3V. The LCD backlight needs 3.3V, or 5V via a 220 ohm resistor in series. As the Wemos D1 supplies both 5V and 3.3V the wiring to the LCD backlight can be drawn directly from the 3.3V pin (figure 3)
Connecting pin 15 of the LCD breakout board to GND is necessary to set the LCD into SPI mode. If this pin is not set LOW or not connected to GND the parallel interface (pins DB0 through DB7) are expected to carry signal while SPI communication is disabled.

Pins for real test bench work
A Wemos D1 mini has a total of 16 pins of which four are dedicated SPI pins. The hardware mapped SPI pins are D5 (clock), D6 (MISO), D7 (MOSI) and D8 (register select). Because there is a single slave in the current design the D6 pin is not used for SPI here. This frees the following Wemos pins for all kinds of useful application: D0, D1, D2, D3. D4, D6, A0, TX and RX. These pins are wired to two separate female pin headers placed on accessible spots on the test platform (see figures 2 and 4). Extra 3.3V and GND male pin headers complete the bench.

Figure 3: Wiring diagram to connect the 128*64 LCD with the Wemos D1 mini. The LCD breakout board is made partially visible in the bottom part of the diagram.

Thus the test bench has multiple pin headers to supply power and GND to external devices, e.g., sensors. Male pin headers were chosen intentionally to physically separate the ‘power’ pin headers from the ‘sensor’ pin headers. Different colors signal ‘power’ and ‘GND’.

Here we use the ‘Dino Demo’ sketch that has been published before**. The purpose of this sketch is to test an 128*64 ST78920 LCD on a Wemos with text and a bitmapped image, no more. The sketch can be downloaded from the link at the bottom of this page.

Figure 4: Top and bottom view of the completed test bench running the ‘Dino_demo’ sketch.

The sketch attached to this paper is called ‘LCD_128x64_wemos_dino_demo.ino’. In order to compile it for this specific LCD you will need the library <U8g2lib> created by Oliver Kraus. This library is available at https://github.com/olikraus/u8g2. The ‘constructor’ for this particular LCD is as follows:

U8G2_ST7920_128X64_F_SW_SPI u8g2(U8G2_R2, 14, 13, 15, U8X8_PIN_NONE);

Image: The sketch uses a c-array prepared from a monochrome, 112 pixels wide and 64 pixels high ‘dino’ image. Because the Wemos has plenty of dynamic memory compared with an Arduino this c-array can reside in dynamic memory. In void setup this array is called via the instruction:

u8g2.drawBitmap (0, 0, 14, 64, dino_demo);

where 0,0 is the position on the LCD where the first pixel of the image is positioned. The ‘14’ stands for the number of bytes in horizontal direction (multiple of 8; because there are 112 pixels, the number of bytes is 112/8 = 14). The ‘64’ is the number of pixels in vertical direction. ‘dino_demo’ is the name of the c-array (a const unsigned char).
The letters ‘D’, ‘I’, ‘N’ and ‘O’ are placed vertically to the right of the bitmap representation as individual letters
Because the call for the c-array and the letters are instructions stored in void setup, void loop remains empty and the bitmap is written to screen once (and for all).

After completion and check we have a fully workable and robust test bench available (figure 4) on which we can test external sensors and other devices and that can be used to develop software. In future papers such software projects will be reported. As far as the 128*64 LCD concerns, ‘tinker time’ is over, that is, repeated fiddling with breadboards and unreliable jumper wires will no longer exist and distract from the real work!
In order to protect the relative vulnerable underside of the platform where all the wires are located the platform is mounted with nylon spacers and nylon screws on a flat piece of cardboard. This also enables proper and safe storage when not in use.


LCD_128x64_wemos_dino_demo.ino (unzip and open in Arduino IDE)

referred projects:
*Arduino 128*64 Liquid Crystal Display ST7920 test bench
Floris Wouterlood – May 8, 2020

**Connecting a Wemos D1 mini and a 128*64 Liquid Crystal Display
Floris Wouterlood – June 3, 2020