How to use LCD 16x2 ?!?!

Post here first, or if you can't find a relevant section!
Post Reply
mandarino
Posts: 5
Joined: Thu Jun 27, 2024 6:53 am

How to use LCD 16x2 ?!?!

Post by mandarino »

Hello expert,
sorry for the inconvenience but I just can't drive a common 16x2 LCD (the one we can find on the web for a few euros).
The interface is I2C and the board in use is the F401RE.
Although the I2C scanner correctly detects the hardware address of the LCD (0x27) and although the backlight/nobackLight command of the library in use works, I just can't write a test.

The simple example I'm using is this one:

Code: Select all

#include <LCD_I2C.h>
#include <Wire.h>

LCD_I2C lcd(0x27, 16, 2); // Default address of most PCF8574 modules, change according

#define PIN_SDA PC_9
#define PIN_SCL PA_8

void setup()
{

  Wire.setSDA(PIN_SDA);
  Wire.setSCL(PIN_SCL);
  //Wire.begin();
  lcd.begin(); // If you are using more I2C devices using the Wire library use lcd.begin(false)
                 // this stop the library(LCD_I2C) from calling Wire.begin()
          
  lcd.backlight();
}

void loop()
{
    lcd.print(" Hello"); // You can make spaces using well... spaces
    delay(5000);
    lcd.noBacklight();
    lcd.clear();
    delay(1000);
    lcd.backlight();
}
Where am I doing wrong?
I connected the SDA/SCL pins to two 100Kohm pullup resistors with the +5V power supply of the LCD (taken from the Nucleo).

I'm desperate because I can't understand where I'm going wrong. Suggestions?
thank you all so much for the help!
STM32ardui
Posts: 142
Joined: Mon May 06, 2024 1:46 pm
Answers: 1
Location: Germany

Re: How to use LCD 16x2 ?!?!

Post by STM32ardui »

STM32 works with 3,3 V (even some pins can withstand 5 V).
100 kOhm pullup is like nothing. Normal you should use 4.7 kOhm (or less) - to 3,3 V of course!!!
Without a link I only can guess: your display (it has a addition board for I²C-connection?) is made for 5 V and logic level of STM32 is not high enough?

BTW: I don't see a command for cursor positioning in you code. Is cursor always at (0,0) after start?
mandarino
Posts: 5
Joined: Thu Jun 27, 2024 6:53 am

Re: How to use LCD 16x2 ?!?!

Post by mandarino »

Hello thanks for your feedback.
ok I'll try with 3.3V and with 4.7Kohm pullup.
unfortunately I don't see any cursor in my test :-(.

anyway I'll let you know.
thanks and regards
STM32ardui
Posts: 142
Joined: Mon May 06, 2024 1:46 pm
Answers: 1
Location: Germany

Re: How to use LCD 16x2 ?!?!

Post by STM32ardui »

mandarino wrote: Thu Jun 27, 2024 8:57 am unfortunately I don't see any cursor in my test :-(.
It long time ago, I uses such a display at ArduinoUNO.

If you don't see a cursor, may be you have to set it to position (0,0)?
Is there no such function in your library?
Normally a library comes with examples ...
mandarino
Posts: 5
Joined: Thu Jun 27, 2024 6:53 am

Re: How to use LCD 16x2 ?!?!

Post by mandarino »

Hello guys, I tried with 4.7Khom pullup resistors and 3.3V (or +5V) but nothing...
it does not work ... let's say: backlight/nobacklight commands work fine but no cursor and no text.
:-(

Can anyone help me please?
thanks and regards
mandarino
Posts: 5
Joined: Thu Jun 27, 2024 6:53 am

Re: How to use LCD 16x2 ?!?!

Post by mandarino »

one bit more: of course I added lcd.setCursor(0,0); but
...nothing

:-(
mandarino
Posts: 5
Joined: Thu Jun 27, 2024 6:53 am

Re: How to use LCD 16x2 ?!?!

Post by mandarino »

[SOLVED] !!!!!!

Sorry I found the issue! NO comment !!!

I had a doubt, since the connections are all correct and then I tried to adjust the contrast with the potentiometer on the back of the display...
and the writing appeared! incredible that by default the setting was wrong!!

Thank you all so much for your help!

regards
STM32ardui
Posts: 142
Joined: Mon May 06, 2024 1:46 pm
Answers: 1
Location: Germany

Re: How to use LCD 16x2 ?!?!

Post by STM32ardui »

For the moment i don't know how to help ...
1. Which library you use?
2. Do you have a link to your display?
3. Do you possess another piece of that display, that you can test, if the first one is not working?
Or - if display is made for 5 V - and you have an Arduino UNO, you can test, if display works at Arduino.

UM10204 is "I2C-bus specification and user manual". HIGH-level must be 0,7 x VDD. If display is 5V-type, it must be 3,5 V. A STM32 can't deliver this voltage.
So you bought wrong display?
Do you have a level shifter module?
mandarino wrote: Thu Jun 27, 2024 11:34 am [SOLVED] !!!!!!
incredible that by default the setting was wrong!!
OK, that's a really crazy reason. :lol:
Post Reply

Return to “General discussion”