16x2 LCD

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
iz2rpn
Posts: 7
Joined: Thu Feb 20, 2020 9:35 pm

Re: 16x2 LCD

Post by iz2rpn » Fri Feb 21, 2020 6:58 pm

shaoziyang wrote:
Fri Feb 21, 2020 8:11 am
I have modify the LCD1602 drive, add autoaddress() function add print() function.

Image

https://github.com/micropython-Chinese- ... 2C_LCD1602

Code: Select all

from machine import I2C, Pin
from mp_i2c_lcd1602 import LCD1602
from time import sleep_ms

i2c = I2C(1, sda=Pin(9), scl=Pin(10))

LCD = LCD1602(i2c)

LCD.puts("I2C LCD1602")

Code: Select all

LCD = LCD1602(i2c)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "mp_i2c_lcd1602.py", line 20, in __init__
  File "mp_i2c_lcd1602.py", line 61, in autoaddr
Exception: I2C address detect error!

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: 16x2 LCD

Post by jimmo » Fri Feb 21, 2020 11:59 pm

What does i2c.scan() return?

If it doesn't return anything, then check wiring and pull-ups.

shaoziyang
Posts: 363
Joined: Sun Apr 17, 2016 1:55 pm

Re: 16x2 LCD

Post by shaoziyang » Sat Feb 22, 2020 3:12 am

Please note, most I2C LCD1602 module use 5V, but ESP32/STM32 use 3.3V, and I2C will not work in this case.

Fortunately, I2C LCD1602 module may work under 3.3V, but contrast needs to be adjusted with a potentiometer. Or you need a level conversion board for I2C signal.

iz2rpn
Posts: 7
Joined: Thu Feb 20, 2020 9:35 pm

Re: 16x2 LCD

Post by iz2rpn » Sat Feb 22, 2020 5:00 am

jimmo wrote:
Fri Feb 21, 2020 11:59 pm
What does i2c.scan() return?

If it doesn't return anything, then check wiring and pull-ups.
i2c.scan() return 39

iz2rpn
Posts: 7
Joined: Thu Feb 20, 2020 9:35 pm

Re: 16x2 LCD

Post by iz2rpn » Sat Feb 22, 2020 5:02 am

shaoziyang wrote:
Sat Feb 22, 2020 3:12 am
Please note, most I2C LCD1602 module use 5V, but ESP32/STM32 use 3.3V, and I2C will not work in this case.

Fortunately, I2C LCD1602 module may work under 3.3V, but contrast needs to be adjusted with a potentiometer. Or you need a level conversion board for I2C signal.
the link is right because i2c.scan () sees the contrast I don't write

iz2rpn
Posts: 7
Joined: Thu Feb 20, 2020 9:35 pm

Re: 16x2 LCD

Post by iz2rpn » Sun Feb 23, 2020 1:10 pm

It works thanksImage

Inviato dal mio CLT-L09 utilizzando Tapatalk


Roberto.cadena
Posts: 1
Joined: Fri Apr 10, 2020 10:20 pm

Re: 16x2 LCD

Post by Roberto.cadena » Sun May 17, 2020 6:47 am

How do you solve the problem? Thanks

duettra
Posts: 1
Joined: Fri Jul 03, 2020 7:41 am

Re: 16x2 LCD

Post by duettra » Fri Jul 03, 2020 7:50 am

How did you solve the issue?

I receive address 39 for i2c.scan(). Code modified accordingly and uploaded:

Code: Select all

LCD_I2C_ADDR=const(39)
Still, I receive I2C address detect error:

>>> from machine import I2C, Pin
>>> from mp_i2c_lcd1602 import LCD1602
>>> from time import sleep_ms
>>>
>>> i2c = I2C(1, sda=Pin(12), scl=Pin(14))
>>>
>>> i2c.scan()
[39]
>>> LCD = LCD1602(i2c)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "mp_i2c_lcd1602.py", line 20, in __init__
File "mp_i2c_lcd1602.py", line 102, in autoaddr
Exception: I2C address detect error!

---------------------------
UPDATE: I tested out ESP8266 library from Dave Hylands published here: https://github.com/dhylands/python_lcd . Works perfectly! I just had to ensure to connect my LCD VIN to 5V, and adjust contrast with the potentiometer on the backside.

shaoziyang
Posts: 363
Joined: Sun Apr 17, 2016 1:55 pm

Re: 16x2 LCD

Post by shaoziyang » Sat Jul 04, 2020 2:10 am

If you not set addr parameter in LCD1602, it will auto detect address. You may try

i2c = I2C(1, sda=Pin(12), scl=Pin(14))
LCD = LCD1602(i2c, 39)

User avatar
HexVitor
Posts: 6
Joined: Sat Dec 28, 2019 2:11 am
Location: Brazil

Re: 16x2 LCD

Post by HexVitor » Sun Jul 05, 2020 2:45 pm

Hi, I have this code that I developed. Feel free to test it out: https://github.com/HexVitor/ESP32/tree/ ... CD%20(I2C)

Post Reply