Tasmota: Connect a lcdproc/LCDd compatible HD44780 i2c Display

Hi,

I already owned a HD44780 I2C Display, which is compatible to LCDd/lcdproc, and want to get this running with Tasmota.

Problem: The LCD 2004 or LCD 1602 Display, for which the Tasmota LCD driver was written, uses a different wiring between the i2c expander (PCF8574) and the HD44780 Display.

So 3 there are options:

  • Buy a new one
  • Develop and construct a new board
  • Or write a patch and build a new Tasmota firmware with support for the LCDd compatible HD44780 device, and build a custom firmware.

I decided to create a patch 🙂

So first setup the build environment.

The wiring differs in the following:
The Tasmota builtin driver (LCD 1602) expects (first line are the PCF8574 Pins, second line are the HD44780 Pins)


P7  P6  P5  P4  P3  P2  P1  P0
DB7 DB6 DB5 DB4 BL  EN  RW  RS

The LCDd expects this wiring


P7  P6  P5  P4  P3  P2  P1  P0
BL  EN  RW  RS  DB7 DB6 DB5 DB4

What is to alter?

  • The header file LiquidCrystal_I2C.h. Here are the defintitons of the Enable, Read/Write, RegisterSelect and background light pins
  • The init sequence in LiquidCrystal_I2C.c
  • The LiquidCrystal_I2C::send() function where highnib and lownib are splited off from the data and the Data byte sended to the i2c bus is generated
  • In LiquidCrystal_I2C::write4bits() function the RW bit must set, because it is connect to P1
  • I uses a PCF8574A where the address lines are set to 0, so I also have to patch the LCD_ADDRESS2 i2c bus address in xdsp_01_lcd.ino from 0x3F to 0x38.
  • In my_user_config.h enable USE_I2C, USE_DISPLAY_LCD, USE_DISPLAY, USE_DISPLAY_MODES1TO5 and comment all i2c devices which uses the same i2c address. Otherwise a i2c address conflict could happened which prevent Tasmota from recognizing the Display (i2cscan returns an error). I also activate Script expressions and if statements.
  • I defined a custom firmware name tasmota-hd44780-i2c in my_user_config.h so the fimware is quickly recognized as a custom one
  • And set a generic template USER_TEMPLATE in my_user_config.h where SDA and SCL are preset to GPIO4 and GPIO5
  • Edit my_user_config.h if you need some further sensors or modules
  • If you want to build a localized version edit platformio.ini and comment out tasmota-DE for example. Localization can also be done in my_user_config.h

Ok, time to build the firmware. Get tasmota and the patch (created with git format-patch HEAD~1 –stdout). Patch is written for 9.3.1 (cmmmit 92c0eb000) but if there are no breaking changes it should also run on newer versions.

michael@debdev ~ # mkdir tasmota-build
michael@debdev ~ # cd tasmota-build
michael@debdev ~/tasmota-build # wget https://michlstechblog.info/blog/download/electronic/hd44780-i2c-LCDd-diff-v9.3.1.patch
michael@debdev tasmota-build # git clone https://github.com/arendst/Tasmota Tasmota
michael@debdev tasmota-build # cd Tasmota
michael@debdev tasmota-build # git checkout v9.3.1
michael@debdev Tasmota # git apply --whitespace nowarn ~/tasmota-build/hd44780-i2c-LCDd-diff-v9.3.1.patch
michael@debdev Tasmota # pio run

Flash the fireware tasmota.bin to the esp8266.

Setup the basic config (WiFi, MQTT..), open the Webfrontend and go to the (web) console. If the LCD display is recognized there should be such an entry:

00:00:00.050 CFG: Loaded from flash at F7, Count 125
00:00:00.055 QPC: Count 1
00:00:00.060 I2C: LCD found at 0x38
00:00:00.150 Project tasmota-hd44780-i2c Tasmota Version 9.3.1(tasmota)-2_7_4_9(2021-04-13T22:37:42)

Setup your display by the following commands and see if the text appears.

DisplayModel 1
DisplayCols 16
DisplayRows 2
DisplayText Test Test

Michael

Patch for Tasmota to support LCDd i2c HD44780 devices
Patch for Tasmota to support LCDd i2c HD44780 devices
hd44780-i2c-LCDd-diff-v9.3.1.patch
Version: 1.00
14.6 KiB
655 Downloads
Details...

Leave a Reply