LCD 1602 - Library

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
vitalis
Posts: 8
Joined: Fri Nov 29, 2019 6:04 am
Location: Finland

Re: LCD 1602 - Library

Post by vitalis » Sat Nov 30, 2019 10:22 pm

Do you mean that it should be done by implementing similar wrapper class to use FBConsole?
But is it possible for text, non-graphical LCD like 20x4 or 16x2?

Christian Walther
Posts: 169
Joined: Fri Aug 19, 2016 11:55 am

Re: LCD 1602 - Library

Post by Christian Walther » Sun Dec 01, 2019 11:32 am

Yes, the FBConsole class demonstrates how you need to subclass uio.IOBase so that it can be plugged into the REPL using os.dupterm. (Incidentally, is there any documentation for this? Searching for “IOBase” in the docs yields nothing.) Writing the text you get from there out to the display should then be straightforward – even simpler for a text-based display than a bitmapped one, I would assume.

vitalis
Posts: 8
Joined: Fri Nov 29, 2019 6:04 am
Location: Finland

Re: LCD 1602 - Library

Post by vitalis » Sun Dec 01, 2019 3:49 pm

Ok, having REPL on the "old school" type of 20x4 LCD sounds interesting! :)
If I will not succeed with my TFT 320x240, I will try that.

vitalis
Posts: 8
Joined: Fri Nov 29, 2019 6:04 am
Location: Finland

Re: LCD 1602 - Library

Post by vitalis » Sat Dec 07, 2019 4:20 pm

I have got TFT 320x240 working with esp32 and FBconsole (to some extent). But now I'm switching back to 20x4 LCD, it will be really interesting to get os.dupterm() working with it.
Christian Walther wrote:
Sun Dec 01, 2019 11:32 am
Incidentally, is there any documentation for this? Searching for “IOBase” in the docs yields nothing.
It will be good to have some docs about it.

Pitias
Posts: 1
Joined: Thu Nov 26, 2020 9:30 pm

Re: LCD 1602 - Library

Post by Pitias » Thu Nov 26, 2020 9:39 pm

mcauser wrote:
Fri Jan 06, 2017 4:56 pm
@ernitron
1. Yes, using various HD44780s, 08x2, 16x1, 16x2, 16x4, 20x4, blue and yellow.
2. Yes, using both PCF8574 I2C backpacks and GPIO pins (4x data pins).

The 08x2 pin arrangement does not mate with the I2C backpacks as the pins are on 2 rows. You can still use the backpack, but you will need to use some wires instead.

Add these to your ESP8266 build's /modules:
https://github.com/dhylands/python_lcd/ ... lcd/lcd.py

for I2C backpack:
https://github.com/dhylands/python_lcd/ ... i2c_lcd.py
https://github.com/dhylands/python_lcd/ ... cd_test.py

for GPIO:
https://github.com/dhylands/python_lcd/ ... pio_lcd.py
https://github.com/dhylands/python_lcd/ ... cd_test.py

Connections:
WeMos D1 Mini -- PCF8574 I2C backpack
D1 SCL ------------ SCL
D2 SDA ----------- SDA
GND --------------- GND
5V ----------------- VCC

Power consumption:
My blue and green 16x2 LCDs: 21mA with backlight on, 5.4mA with backlight off.
My blue and green 20x4 LCDs: 36mA with backlight on, 5.5mA with backlight off.

Code: Select all

from time import sleep_ms, ticks_ms
from machine import I2C, Pin
from esp8266_i2c_lcd import I2cLcd

i2c = I2C(scl=Pin(5), sda=Pin(4), freq=400000)

lcd = I2cLcd(i2c, 0x27, 2, 16)
lcd.putstr("Hello ernitron\nIt's working!")
lcd.clear()
lcd.putstr("Using dhylands\npython_lcd")

lcd = I2cLcd(i2c, 0x27, 4, 20)
lcd.putstr("WeMos D1 Mini with  PCF8574 I2C backpackWorks with HD44780s:08x2 16x1 16x2 20x4")
lcd.clear()
lcd.putstr("line 1\nline 2\nline 3\nline 4")
Image
Image
http://imgur.com/a/h6UWJ


Hi Friends
I am using ESP6288 with LCD 16X2 I have uploaded both the esp8266_i2c_lcd.py and lcd_api.py to my module

D1 SCL ------------ SCL
D2 SDA ----------- SDA
GND --------------- GND
5V ----------------- VCC

Code: Select all

 microPython
from time import sleep_ms, ticks_ms
from machine import I2C, Pin
from esp8266_i2c_lcd import I2cLcd

i2c = I2C(scl=Pin(5), sda=Pin(4), freq=400000)

lcd = I2cLcd(i2c, 0x27, 2, 16)
lcd.putstr("Hello ernitron\nIt's working!")
lcd.clear()
Quick question:
1: the code is good without errors but the display is blank. I need help ?? Thank you so much
Last edited by jimmo on Fri Nov 27, 2020 1:15 am, edited 1 time in total.
Reason: Fix [code] formatting

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: LCD 1602 - Library

Post by dhylands » Fri Nov 27, 2020 4:38 am

When you power the display on do you see some black squares? If you don't see any black squares then you need to adjust the contrast voltage.

maxim1maxim
Posts: 1
Joined: Fri Feb 19, 2021 6:05 pm
Location: Russia, Saratov

Re: LCD 1602 - Library

Post by maxim1maxim » Fri Feb 19, 2021 8:26 pm

Hi! I do not understand the functionality of the forum yet, but I hope that I will write to the right place. I have LCD2004 with I2c and ESP 12f. In Thonny uploaded lcd_api.py, esp8266_i2c_lcd.py and a short example from the forum posts. I tried to run the code on the ESP for two days, an error occurred (OSError: [errno 19] enodev ), I realized that this is because the LCD is not connected to the ESP board. I figured it out, everything worked, but the problem is that when I turn off my programmer and connect everything to another power source, squares appear on the display. Trying to connect the power for the esp from a 3.3-volt programmer and the display to power from 5 volts with a common GND signal, but without the RX, the TX crashes. I don't understand why it doesn't work separately without RX and TX.

whiterabbit
Posts: 1
Joined: Fri Apr 09, 2021 4:50 pm

Re: LCD 1602 - Library

Post by whiterabbit » Fri Apr 09, 2021 4:53 pm

mcauser wrote:
Fri Jan 06, 2017 4:56 pm

Code: Select all

from time import sleep_ms, ticks_ms
from machine import I2C, Pin
from esp8266_i2c_lcd import I2cLcd

i2c = I2C(scl=Pin(5), sda=Pin(4), freq=400000)

lcd = I2cLcd(i2c, 0x27, 2, 16)
lcd.putstr("Hello ernitron\nIt's working!")
lcd.clear()
lcd.putstr("Using dhylands\npython_lcd")

lcd = I2cLcd(i2c, 0x27, 4, 20)
lcd.putstr("WeMos D1 Mini with  PCF8574 I2C backpackWorks with HD44780s:08x2 16x1 16x2 20x4")
lcd.clear()
lcd.putstr("line 1\nline 2\nline 3\nline 4")
Hi. I tried your code today ... everything works -- besides one thing: the \n doesn't work. I won't get a line break and instead of that "line 1 line2 line 3 line 4" is in one line until there are more than 20 characters ...
What's wrong or how to correct this? Thank you!

Post Reply