Page 1 of 1

Problems with the blue pill and a LCD 16x2

Posted: Mon Apr 12, 2021 12:22 am
by losingmymind01
Hi, I've been struggling with an LCD screen to show simple characters with the STM32F103 [Blue Pill].

1. When i try to print some words (without a delay added), i get random characters instead of what im trying to display. An example is:
In the code, i have at the loop:
lcd.setCursor(0, 0);
lcd.print("misery");
lcd.setCursor(0, 1);
lcd.print("pain");
and what my lcd prints is:
cryin.jpeg
cryin.jpeg (76.06 KiB) Viewed 4950 times
2. And when i try to print the same words to the lcd display with a delay of 1500, i get the same problem with a different presentation. In the code i have:
lcd.setCursor(0, 0);
lcd.print("misery");
delay(1000);
lcd.setCursor(0, 1);
lcd.print("pain");
delay(1000);
and my lcd prints:
agony.jpeg
agony.jpeg (70.35 KiB) Viewed 4950 times
Regards,
losingmymind01

Re: Problems with the blue pill and a LCD 16x2

Posted: Mon Apr 12, 2021 8:08 am
by stevestrong
viewtopic.php?f=2&t=301

Which core and which LCD library do yo use?

Re: Problems with the blue pill and a LCD 16x2

Posted: Mon Apr 12, 2021 5:41 pm
by losingmymind01
stevestrong wrote: Mon Apr 12, 2021 8:08 am viewtopic.php?f=2&t=301

Which core and which LCD library do yo use?
I'm using a STM32F103C8 (20kRAM, 64kFlash) [Blue Pill] and the LiquidCrystal library working on the arduino IDE

Re: Problems with the blue pill and a LCD 16x2

Posted: Tue Apr 13, 2021 11:33 am
by stevestrong
And which core?
If you don't know, then post a picture of the selected board in Arduino IDE.
Please also post a link to the library.

Re: Problems with the blue pill and a LCD 16x2

Posted: Tue Apr 13, 2021 4:59 pm
by losingmymind01
stevestrong wrote: Tue Apr 13, 2021 11:33 am And which core?
If you don't know, then post a picture of the selected board in Arduino IDE.
Please also post a link to the library.
This is what i have in Arduino IDE:
board.jpeg
board.jpeg (21.33 KiB) Viewed 4873 times
And the link to the library is: https://github.com/arduino-libraries/Li ... dCrystal.h

Re: Problems with the blue pill and a LCD 16x2

Posted: Tue Apr 13, 2021 5:17 pm
by ag123
there is a chance that stm32 is too fast for the lcd. Hence, try to insert 'strategic' delay(1) in the code to see if that'd help.
of course 1ms delay is a 'long' time, but at least it'd help locate the problem.
stm32 is capable of toggling pins up to 50mhz

Re: Problems with the blue pill and a LCD 16x2

Posted: Wed Apr 14, 2021 4:45 am
by fredbox
That library seems to work ok without any changes on a blue pill board.
I used PB4-PB9 to connect to the LCD display.

See attached example. It alternates the text on line1 and line2 repeatedly every time the LED blinks.

Re: Problems with the blue pill and a LCD 16x2

Posted: Tue Jun 22, 2021 10:10 pm
by oliviega
Hello,
I had the same problem, and I solved it by setting in tools of the Arduino IDE:

- CPU Speed(MHz): "48Mhz (slow - with USB)"

Best,

Re: Problems with the blue pill and a LCD 16x2

Posted: Tue Jun 22, 2021 10:39 pm
by mrburnette
IF you must use a 1602, the I2C backpack is highly recommended ... just be certain to run the I2C scanner as I had a few with an unusual address.
Image

https://www.electroschematics.com/ardui ... -tutorial/