create new tag
view all tags

The 2 line LCD display.

A 2 line LCD display can be used to display simple information. When using an ADC to read voltages it can be used to show the results implementing like this a simple voltmeter.

The display is driven by a HD44780 display driver from Hitachi. The data sheet explains all the details of this controller. The controller can be directly accessed through GPIO lines, which however requires quite a bit of cabling. The other possibility is to pass through a pcf8574 I2C I/O expander, in which case only the I2C connections SCL, SDA, Vcc and GND are needed.

2linedisplay.png i2c_pcf8574.png
The 2 line LCD display Its I2C interface
The blue potentiometer you see on the I2C interface is used to control the display contrast.
When developing the access library I saw that the programs failed in ~ 20% of the cases, while re-running the same binary again would make it work. The contrast was very bad also and I had to turn the contrast potentiometer to maximum in order to see the text.

When switching from 3.3V power to 5V power however, all these problems went away.

The HD44780 can operate in 2 modes:

  • a 8-bit mode in which all 8 interface bits are used as data and additional I/O lines are used as backlight control, R/W, strobe and register select lines.
  • a 4-bit mode where the data bits are transferred in 2 successive cycles on the upper 4 data lines (D4-D7) while the lower 4 bits are used to drive the control lines
Our I2C interface uses the 4-bit mode and is connected as follows:


The display can be used in a multitude of applications. When running with the realtime clock for example it may display date and time while when running with the PCF8591 ADC it may show an input voltage and in this way transform our Raspberry Pi into a simple voltmeter. The left value is an 8 bit hex value directly read from the ADC while the second is the value converted into Volts under the condition that the PCF8591 is connected to Vcc=3.3V.


The source code of the library allowing access to the hd44780 via the pcf8574 is attached to this page (hd44780.tar.gz)

-- Uli Raich - 2017-02-01


Topic attachments
I Attachment History Action Size Date Who Comment
PNGpng 2linedisplay.png r1 manage 873.1 K 2017-02-01 - 12:38 UnknownUser  
PNGpng hd44780-pcf8574circuit.png r1 manage 66.4 K 2017-11-16 - 17:45 UnknownUser  
Unknown file formatgz hd44780.tar.gz r1 manage 256.0 K 2017-10-09 - 12:19 UnknownUser  
PNGpng i2c_pcf8574.png r1 manage 1014.0 K 2017-02-01 - 12:38 UnknownUser  
PNGpng pcf8574ifce.png r1 manage 63.7 K 2017-02-01 - 13:59 UnknownUser  
PNGpng voltmeter.png r1 manage 659.7 K 2017-02-04 - 13:21 UnknownUser  
Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r6 - 2017-11-16 - uli
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback