I2C LCD Library... Help!

Discuss development of drivers for external hardware and components, such as LCD screens, sensors, motor drivers, etc.
Target audience: Users and developers of drivers.
User avatar
raspi3ua
Posts: 21
Joined: Sat Mar 18, 2017 4:49 pm
Location: Kiev, Ukraine
Contact:

Re: I2C LCD Library... Help!

Post by raspi3ua » Sat Mar 18, 2017 9:28 pm

One of comments from Aliexpress:
"3f address. there is written about it. put the address 0х3f i2c module and start-everything works. https://ae01.alicdn.com/kf/UT8QpQBXNNaXXagOFbXQ.jpg"

So adress 63 is OK.


"The part number of the 0x3F chip will be PCF8574. i.e.0x38-0x3F
The part number of the 0x27 chip will be PCF8574A i.e. 0x20-0x27"
http://forum.arduino.cc/index.php?topic=369998.60


picture: https://cdn.instructables.com/FVV/YTFX/ ... .LARGE.jpg
0x3F - my code.
PCF8574AT - my backpack.

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

Re: I2C LCD Library... Help!

Post by dhylands » Sat Mar 18, 2017 10:09 pm

SDA and SCL both need pullup resistors. Some boards have them and some don't. I'd try adding 10K ohm pullups between 3.3v and SDA and also between 3.3v and SCL.

User avatar
raspi3ua
Posts: 21
Joined: Sat Mar 18, 2017 4:49 pm
Location: Kiev, Ukraine
Contact:

Re: I2C LCD Library... Help!

Post by raspi3ua » Mon Mar 20, 2017 8:30 am

I soldered all pins from LCD to backpack and now all is ok. :-)
Thanks for troubleshuting.
LED_front1.jpg
LED_front1.jpg (185.53 KiB) Viewed 27278 times
>>> from esp8266_i2c_lcd import I2cLcd
>>> from machine import Pin, I2C
>>> i2c = I2C(scl=Pin(5), sda=Pin(4), freq=100000)
>>> i2c.scan()
[63]
>>> lcd = I2cLcd(i2c, 63, 2, 16)
>>> lcd.clear()
>>> lcd.putstr(' Thanks from Ukraine :-) ')

haks
Posts: 1
Joined: Thu Apr 06, 2017 9:58 pm
Location: Auckland

Re: I2C LCD Library... Help!

Post by haks » Thu Apr 06, 2017 10:07 pm

Help: <ImportError: no module named 'esp8266_i2c_lcd'> trying to load the same code:

from esp8266_i2c_lcd import I2cLcd
from machine import Pin, I2C
i2c = I2C(scl=Pin(5), sda=Pin(4), freq=100000)
i2c.scan()
lcd = I2cLcd(i2c, 63, 2, 16)
lcd.clear()
lcd.putstr(' Thanks from Ukraine :-) ')

User avatar
raspi3ua
Posts: 21
Joined: Sat Mar 18, 2017 4:49 pm
Location: Kiev, Ukraine
Contact:

Re: I2C LCD Library... Help!

Post by raspi3ua » Sat Apr 08, 2017 7:52 am

haks wrote:Help: <ImportError: no module named 'esp8266_i2c_lcd'> trying to load the same code:

from esp8266_i2c_lcd import I2cLcd
There is no 'esp8266_i2c_lcd' library installed by default. You need to load 'esp8266_i2c_lcd' and 'lcd_api.py' on your NodeMCU. I use "ampy" util to load files to Node MPU.

Code: Select all

C:\>set AMPY_PORT=COM10
C:\>ampy put lcd_api.py 
C:\>ampy put esp8266_i2c_lcd.py esp8266_i2c_lcd.py
Then check if library loaded correctly:

Code: Select all

>>> with open('esp8266_i2c_lcd.py') as f:
            for line in f:
                print(line, end='')

User avatar
raspi3ua
Posts: 21
Joined: Sat Mar 18, 2017 4:49 pm
Location: Kiev, Ukraine
Contact:

Re: I2C LCD Library... Help!

Post by raspi3ua » Fri Apr 14, 2017 7:27 am

Question: Can we tune "Brightness" and "Contrast" using I2C LCD Library?

I ask this question because of next problem...
When I use wrong connection and power LCD Backpack (5V) from NodeMCU VU pin (5V) - all is ok with "Brightness" and "Contrast". See my picture above. But such connection may faulted I2C pin on NodeMCU (not 5V tolerant).

When I power LCD Backpack (5V) from NodeMCU 3V3 pin (3.3V) - LCD is working BUT "Brightness" and "Contrast" too low. I set potentiometer on Bacpack to max position. I can lcd.putstr('hi") but it very hard readable.

So is it any way to tune "Brightness" and "Contrast"?

User avatar
raspi3ua
Posts: 21
Joined: Sat Mar 18, 2017 4:49 pm
Location: Kiev, Ukraine
Contact:

Re: I2C LCD Library... Help!

Post by raspi3ua » Fri Apr 14, 2017 7:44 am

Test.
Power LCD Backpack (5V) from NodeMCU 3V3 pin (3.3V).
>>> i2c = I2C(scl=Pin(5), sda=Pin(4), freq=100000)
>>> lcd = I2cLcd(i2c, 63, 2, 16)
>>> lcd.putstr(' Thanks from Ukraine :-) ')
"Brightness" and "Contrast" too low.
low_Brightness.jpg
low_Brightness.jpg (106.48 KiB) Viewed 27180 times

Than I disconnect 3V3 pin and connect it again to 3V3 pin

>>> lcd.putstr(' Thanks from Ukraine :-) ')
ok_Brightness_wrong_char.jpg
ok_Brightness_wrong_char.jpg (112.79 KiB) Viewed 27180 times
"Brightness" and "Contrast" is ok but Char is wrong.

When I reinitialize LCD+Backpack
>>> i2c = I2C(scl=Pin(5), sda=Pin(4), freq=100000)
>>> lcd = I2cLcd(i2c, 63, 2, 16)
Char is good but "Brightness" and "Contrast" is too low again . :D

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: I2C LCD Library... Help!

Post by Roberthh » Fri Apr 14, 2017 12:50 pm

The LCD requires 5V for proper brightness & contrast. You could try to run the LCD at 5V, and the NodeMCU at 3.3V with the pull-up resistors connected to 3.3 V. Or use a level converter for SDA & SCL, with pull-up resistors at both sides.

User avatar
mcauser
Posts: 507
Joined: Mon Jun 15, 2015 8:03 am

Re: I2C LCD Library... Help!

Post by mcauser » Wed Apr 19, 2017 2:28 am

There are some 16x2 LCDs which are designed for 3V, but they are hard to find and often 5-10x the price.
Most require 5V for reasonable contrast. Don't forget to adjust the potentiometer on the back.

Yellow/green LCDs are more readable in daylight without the backlight on, compared to blue/white.

User avatar
raspi3ua
Posts: 21
Joined: Sat Mar 18, 2017 4:49 pm
Location: Kiev, Ukraine
Contact:

Re: I2C LCD Library... Help!

Post by raspi3ua » Sat Apr 29, 2017 12:33 pm

Receive TXS0108E "I2C Logic Level Converter Bi-Directional Module 5V to 3.3V".
Connect LCD (5V) to NodeMCU (3.3V) through TXS0108E.
Now all is Ok.
I2C_Converter_5V_to_3.3V_TXS0108E .jpg
I2C_Converter_5V_to_3.3V_TXS0108E .jpg (167.76 KiB) Viewed 27100 times

Post Reply