16x2 LCD
16x2 LCD
Howdy everyone! I just scooped up an ESP32S (my first ever board) along with a 16x2 LCD (https://www.amazon.com/gp/product/B0711 ... UTF8&psc=1) and was looking for a good place to start. My background is in software development but electronics is a fairly new hobby. For writing to the display should I be looking for a class such as https://github.com/wjdp/micropython-lcd or is there a simple way to write directly using I2C?
I've been looking at the I2C class docs and am able to scan addresses and receive 39 back (21 to SDA, 22 to SLC), but I'm not sure what to do with it. If I attempt to `writeto` it I receive the acks but the display immediately shuts off. Any newbie help is appreciated as everything I've found is either for the 8266 or a different version of the ESP32 and I'm not sure how the pins correlate to my NodeMCU ESP32S.
I've been looking at the I2C class docs and am able to scan addresses and receive 39 back (21 to SDA, 22 to SLC), but I'm not sure what to do with it. If I attempt to `writeto` it I receive the acks but the display immediately shuts off. Any newbie help is appreciated as everything I've found is either for the 8266 or a different version of the ESP32 and I'm not sure how the pins correlate to my NodeMCU ESP32S.
-
- Posts: 363
- Joined: Sun Apr 17, 2016 1:55 pm
Re: 16x2 LCD
[quote=shaoziyang post_id=32524 time=1544427339 user_id=1625]
You may try I2C LCD1602 drive below:
https://github.com/micropython-Chinese- ... 2C_LCD1602
[/quote]
Thanks! That class worked beautifully. As for the display not working, TIL what a potentiometer is
You may try I2C LCD1602 drive below:
https://github.com/micropython-Chinese- ... 2C_LCD1602
[/quote]
Thanks! That class worked beautifully. As for the display not working, TIL what a potentiometer is
Re: 16x2 LCD
I have tried it too but it gives me this error:hamurai wrote: ↑Tue Dec 11, 2018 12:00 amThanks! That class worked beautifully. As for the display not working, TIL what a potentiometer isshaoziyang wrote: ↑Mon Dec 10, 2018 7:35 amYou may try I2C LCD1602 drive below:
https://github.com/micropython-Chinese- ... 2C_LCD1602
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: function takes 2 positional arguments but 1 were given
How can I solve it?
Re: 16x2 LCD
i2c 22 scl and 21 sda. i have an esp32 devkit v1
Code: Select all
import mp_i2c_lcd1602 #this works
l=mp_i2c_lcd1602.LCD1602() #this gives me the error I was telling you about
l.puts('Hello!')
Last edited by iz2rpn on Fri Feb 21, 2020 5:08 am, edited 1 time in total.
Re: 16x2 LCD
It looks like the example code is wrong. Should be:
Code: Select all
import mp_i2c_lcd1602
import machine
i2c = machine.I2C(scl=22,sda=21)
l=mp_i2c_lcd1602.LCD1620(i2c)
l.puts('Hello!')
Re: 16x2 LCD
jimmo wrote: ↑Fri Feb 21, 2020 5:08 amIt looks like the example code is wrong. Should be:
Code: Select all
import mp_i2c_lcd1602 import machine i2c = machine.I2C(scl=22,sda=21) l=mp_i2c_lcd1602.LCD1620(i2c) l.puts('Hello!')
Code: Select all
import mp_i2c_lcd1602
from machine import I2C, Pin
i2c = machine.I2C(scl=Pin(22), sda=Pin(21))
l=mp_i2c_lcd1602.LCD1620(i2c)
#Traceback (most recent call last):
#File "<stdin>", line 1, in <module>
#AttributeError: 'module' object has no attribute 'LCD1620'
l=mp_i2c_lcd1602.LCD1602(i2c)
#Traceback (most recent call last):
#File "<stdin>", line 1, in <module>
#File "mp_i2c_lcd1602.py", line 13, in __init__
#File "mp_i2c_lcd1602.py", line 40, in setcmd
#File "mp_i2c_lcd1602.py", line 34, in send
#File "mp_i2c_lcd1602.py", line 27, in setReg
#OSError: [Errno 19] ENODEV
Re: 16x2 LCD
Looks like another typo in the example code -- as you've realised it should be LCD1602
The ENODEV means that it couldn't communicate over I2C. Can you try adding a scan after constructing the I2C instance, e.g.
If it gives you back an address, then modify the LCD_I2C_ADDR in mp_i2c_lcd1602.py
If not, then check things like power and pull-up resistors.
The ENODEV means that it couldn't communicate over I2C. Can you try adding a scan after constructing the I2C instance, e.g.
Code: Select all
i2c = machine.I2C(scl=Pin(22), sda=Pin(21))
print(i2c.scan())
If not, then check things like power and pull-up resistors.
-
- Posts: 363
- Joined: Sun Apr 17, 2016 1:55 pm
Re: 16x2 LCD
I have modify the LCD1602 drive, add autoaddress() function add print() function.
https://github.com/micropython-Chinese- ... 2C_LCD1602
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")