Problems with the blue pill and a LCD 16x2

Post here first, or if you can't find a relevant section!
Post Reply
losingmymind01
Posts: 3
Joined: Sun Apr 11, 2021 11:59 pm

Problems with the blue pill and a LCD 16x2

Post 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 4725 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 4725 times
Regards,
losingmymind01
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

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

Post by stevestrong »

viewtopic.php?f=2&t=301

Which core and which LCD library do yo use?
losingmymind01
Posts: 3
Joined: Sun Apr 11, 2021 11:59 pm

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

Post 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
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

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

Post 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.
losingmymind01
Posts: 3
Joined: Sun Apr 11, 2021 11:59 pm

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

Post 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 4648 times
And the link to the library is: https://github.com/arduino-libraries/Li ... dCrystal.h
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

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

Post 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
fredbox
Posts: 125
Joined: Thu Dec 19, 2019 3:05 am
Answers: 2

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

Post 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.
Attachments
16x2_LCD_With_Library-210413a.zip
(4.42 KiB) Downloaded 316 times
oliviega
Posts: 1
Joined: Tue Jun 22, 2021 10:07 pm

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

Post 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,
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

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

Post 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/
Post Reply

Return to “General discussion”