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.
User avatar
mcauser
Posts: 507
Joined: Mon Jun 15, 2015 8:03 am

Re: LCD 1602 - Library

Post by mcauser » Sat Jan 14, 2017 3:09 pm

Most PCF backpacks have a potentiometer for adjusting the display contrast. It may appear the display isn't working when the contrast is extreme.

ZKDMun
Posts: 42
Joined: Thu Nov 24, 2016 2:34 pm
Location: Hamburg

Re: LCD 1602 - Library

Post by ZKDMun » Sat Jan 14, 2017 3:42 pm

Found it - but after adjusting the potentiometer the problem was not solved :/
After turning the potentiometer high, the display shows me just a single row on the lcd:
Image

ZKDMun
Posts: 42
Joined: Thu Nov 24, 2016 2:34 pm
Location: Hamburg

Re: LCD 1602 - Library

Post by ZKDMun » Sat Jan 14, 2017 4:00 pm

i2c.scan() delivers me a list of the values 8 to 119...

>>>i2c.scan()
[8,9,10,11,12,13,14,15,16 - and so on - 117,118,119]

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

Re: LCD 1602 - Library

Post by Roberthh » Sat Jan 14, 2017 5:36 pm

me just a single row on the lcd
That's the typical power-on & not-cleared-yet state.

ZKDMun
Posts: 42
Joined: Thu Nov 24, 2016 2:34 pm
Location: Hamburg

Re: LCD 1602 - Library

Post by ZKDMun » Sat Jan 14, 2017 6:42 pm

Roberthh wrote:
me just a single row on the lcd
That's the typical power-on & not-cleared-yet state.
But I just need to power on the LCD - there is no connection to REPL necessary, the row appears every time the LCD get some power.

How can I solve this problem and clear the display?

I have tried the code from mcausers post:

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.clear()
but nothing changed :/

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 » Sat Jan 14, 2017 6:58 pm

ZKDMun wrote:i2c.scan() delivers me a list of the values 8 to 119...

>>>i2c.scan()
[8,9,10,11,12,13,14,15,16 - and so on - 117,118,119]
Seeing this suggests that the pullup resistors aren't wired in properly.

ZKDMun
Posts: 42
Joined: Thu Nov 24, 2016 2:34 pm
Location: Hamburg

Re: LCD 1602 - Library

Post by ZKDMun » Sun Jan 15, 2017 2:38 pm

Found the problem:

The wiring with the 4.7k ohm resistors like the wiring on my sketch I posted before was ok...
but I am using a long breadboard and I am a newbie - my lesson of the day was that the Vcc- and die GND-Line of these long breadboards are interrupted at the middle of the boards - that was my mistake, without any voltage the pullup-resistor can not work.
Many apologies for this mistake - I am ashamed of myself. :/
Now it works perfectly - thank you guys :)

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

Re: LCD 1602 - Library

Post by mcauser » Sun Jan 15, 2017 8:27 pm

Best part about making mistakes is that you learn from them :)

ZKDMun
Posts: 42
Joined: Thu Nov 24, 2016 2:34 pm
Location: Hamburg

Re: LCD 1602 - Library

Post by ZKDMun » Thu Jan 19, 2017 3:46 pm

dhylands wrote: Did you add pullups on the SDA and SCL lines? I2C requires them.
Another question:
Is it necessary to use Pin.PULL_UP?
Can I replace the resistors with Pin.PULL_UP, or is this no replacement for the resistors?
Noob question :/, but I can not understand the meaning behind the Pin.PULL_UP-method...

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 » Thu Jan 19, 2017 5:57 pm

When you use Pin.PULL_UP this enables the internal weak pullups which are on the order of 30-50K ohms (40K typical).

I2C prefers to have strong pullups (I normally pick 4.7K ohms or lower).

You can use weak pulllups if you have a small number of devices on the bus and the wires aren't long, and you can live with lower bus frequencies.

It basically boils down to the larger the value of the pullup, the slower the rising edge to create a 1 bit. The speed of this edge is affected by bus capacitance (which increases each time you add a device) and ultimately determines the max speed you can run the bus at.

There are so many factors that can affect this that the only way to know if it will work for you, is for you to experiment and see it it works reliably enough for you with your particular setup.

Post Reply