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 5:03 pm

Hello,
I have the same problem.
My hardware:
-16x2 HD44780 Character LCD with IIC/I2C Serial Interface Adapter Module
-NodeMcu ESP8266 V3 (with the latest micropython firmware)

I can scan LCD on I2C.
>>> from machine import Pin, I2C
>>> i2c = I2C(scl=Pin(5), sda=Pin(4), freq=100000)
>>> i2c.scan()
[63]

Is there any way to write "Hello World" to LCD using I2C from NodeMCU?
Thanks.

I can't find I2C support for NodeMCU on https://github.com/dhylands/python_lcd

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 5:12 pm

I guess we need to establish which i2c backpack you're using (there are quite a few).

None of the ones I've used have an address of 63?

If you disconnect the LCD and repeat the scan does 63 still show up?

sequel
Posts: 14
Joined: Wed Aug 03, 2016 1:52 pm

Re: I2C LCD Library... Help!

Post by sequel » Sat Mar 18, 2017 6:33 pm

raspi3ua, did you try the code (esp8266_i2c_lcd.py and lcd.py) that i have posted on this thread on Sat Oct 01, 2016 2:36 am?

NodeMCU is basically an esp8266 board so the code shall work.

When using the two files mentioned above, you could try something like this (adjust the pins to your setup) :

Code: Select all

from machine import Pin, I2C
from esp8266_i2c_lcd import I2cLcd
i2c = I2C(scl=Pin(5), sda=Pin(4), freq=100000)
lcd = I2cLcd(i2c, 0x63, 2, 16)

lcd.clear()
lcd.putstr('Hello World!')
But like dhylands said, 0x63 seems odd for an I2C LCD backpack address.

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 6:38 pm

Note that i2c.scan reports addresses in decimal so 63 = 0x3F not 0x63

sequel
Posts: 14
Joined: Wed Aug 03, 2016 1:52 pm

Re: I2C LCD Library... Help!

Post by sequel » Sat Mar 18, 2017 6:45 pm

Oh yeah! i've missed that one :)

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 7:55 pm

[quote="dhylands"] I guess we need to establish which i2c backpack you're using (there are quite a few).

None of the ones I've used have an address of 63?

If you disconnect the LCD and repeat the scan does 63 still show up? [/quote]

My hardware is from Aliexpress :-) This one:
https://www.aliexpress.com/item/1602-16 ... 0.0.CZ7EC3

https://www.aliexpress.com/item/V3-4M-b ... 0.0.CZ7EC3


I disconnect LCD and scan. Same number 63
>>> i2c.scan()
[63]

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 8:05 pm

I can read numbers on I2C Backpack chip: "PCF8574AT L21521"
I think this one https://www.nxp.com/documents/data_sheet/PCF8574.pdf
Last edited by raspi3ua on Sat Mar 18, 2017 8:40 pm, edited 1 time in total.

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 8:39 pm

sequel wrote:raspi3ua, did you try the code (esp8266_i2c_lcd.py and lcd.py) that i have posted on this thread on Sat Oct 01, 2016 2:36 am?
NodeMCU is basically an esp8266 board so the code shall work.
Connect NodeMCU ->I2C Backpack ->LCD

All LCD is white.

>>> from esp8266_i2c_lcd import I2cLcd
>>> from machine import Pin, I2C
>>> i2c = I2C(scl=Pin(5), sda=Pin(4), freq=100000)
>>> lcd = I2cLcd(i2c, 63, 2, 16) <--- Just LCD blink
>>> lcd.clear() <--- nothing
>>> lcd.putstr('Hello World!') <--- nothing

>>> i2c.scan()
[63]

>>> lcd = I2cLcd(i2c, 0x63, 2, 16)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "esp8266_i2c_lcd.py", line 26, in __init__
OSError: [Errno 19] ENODEV

>>> lcd = I2cLcd(i2c, 0x3F, 2, 16) <--- Just LCD blink


>>> i2c.writeto(63, '1') <--- All LCD is black now
1
>>> i2c.writeto(63, '8') <--- All LCD is while now
1

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 8:51 pm

raspi3ua wrote:
dhylands wrote: I guess we need to establish which i2c backpack you're using (there are quite a few).

None of the ones I've used have an address of 63?

If you disconnect the LCD and repeat the scan does 63 still show up?
My hardware is from Aliexpress :-) This one:
https://www.aliexpress.com/item/1602-16 ... 0.0.CZ7EC3

https://www.aliexpress.com/item/V3-4M-b ... 0.0.CZ7EC3


I disconnect LCD and scan. Same number 63
>>> i2c.scan()
[63]
That tells me that your device isn't being seen by the scan then. Check to make sure you haven't swapped SDA and SCL. Also make sure that vcc and ground are hooked up.

The PCF8574 has an I2C address of 0x20 thru 0x27 (32 thru 39). Device 63 is something else on the i2c bus and not your LCD backpack.

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:15 pm

dhylands wrote:That tells me that your device isn't being seen by the scan then. Check to make sure you haven't swapped SDA and SCL. Also make sure that vcc and ground are hooked up.

The PCF8574 has an I2C address of 0x20 thru 0x27 (32 thru 39). Device 63 is something else on the i2c bus and not your LCD backpack.
Very strange. Tried to swap SDA and SCL, tried to change cables, tried to disconnect any cable - always results []

>>> i2c.scan()
[]
>>> i2c.scan()
[]
>>> i2c.scan()
[]
>>> i2c.scan()
[]
>>> i2c.scan()
[63]
>>> i2c.scan()
[]
>>> i2c.scan()
[]
>>> i2c.scan()
[]


I have 63 when pins connected like this:
https://www.losant.com/hs-fs/hubfs/Blog ... wiring.jpg

Post Reply