I was trying out the code :
Learn ESP32 with Arduino IDE V1_4 > Module 7 -ESP32 with MQTT > ESP32_Client_2_LCD_PUSHBUTTON
The Raspberry Pi mosquittoe is running ( & ESP#1 ).
On the ESP#2 LCD I see the temperature displayed, so I know that is working.
The problem is the LCD Displays fine, then adds random characters, then returns to normal.
I am using a 20×4 LCD and changed the code for the 20×4 display.
const int lcdColumns = 20; const int lcdRows = 4;
I tested the hardware and connections with a working Arduino Uno display code and the static display worked fine on the ESP32.
I ran the RandomNerd scrolling text code, and that worked fine.
I changed the MQTT messageTemp to a fixed string and that had random display too.
I am at a loss unless there is a different LiquidCrystal_I2C.h?
Hi Robert.
We use the same LCD I2C library in all projects. So, the library shouldn’t be the issue.
When you print the message on the serial monitor, does it have jibberish? Or it’s only on the LCD display?
In which part of the LCD are you getting those random characters? How are you powering your display?
Regards,
Sara
NO, the serial monitor looks good and the messages.
I see the temperature on the serial monitor.
ONLY THE LCD has issues and just with this program ?
The display usually looks good with the only the first 2 rows used.
I added a setup lcd.print on all 4 rows which always looks good.
Then the entire display shows random characters along with a random mix of the sent characters.
Then it comes back after awhile and repeats the cycle.
Hi Robert.
So this happens when you write to the 4 rows?
I’ve read some similar issues and didn’t find a clear answer. It can be for example:
- some loose connections: which doesn’t seem the case;
- writing to the LCD too fast: you may try adding a small delay between printings;
- not enough power supply. The display needs 5V. But I’m not sure if trying to write to the 4 rows will required you to have a separated supply for the display. For example, if you’re powering it through a USB port from your computer, it may not have enough power – I haven’t experimented with that display (20×4).
Let me know if this helps.
Regards,
Sara
Added the delay 100mS & 1000mS after each lcd.print .
No improvement?
Here is the LCD jibberish:
https://snipboard.io/TeG032.jpg
Here is a good display:
https://snipboard.io/0J8Xi5.jpg
Here is the Serial Monitor :
https://snipboard.io/M35ouI.jpg
Added the delay 100mS & 1000mS after each lcd.print .
No improvement?
Here is the LCD jibberish:
https://snipboard.io/TeG032.jpg
Here is a good display:
https://snipboard.io/0J8Xi5.jpg
Here is the Serial Monitor :
https://snipboard.io/M35ouI.jpg
Hi Robert.
Thank you for sending those images.
I’ve searched on many forums for similar issues and I still haven’t found a clear answer.
What everyone says is something about the speed you write to the display or interference with I2C communication.
I’m out of ideas on how to solve this :/ I’m sorry that I can’t help much.
Do you have another LCD to experiment?
Regards,
Sar
Hello, I came here looking to solve the identical issue. During the MQTT lessons everything works as described above and I get the same issues. Several cycles will be great, then turns to jibbersih and then repeats. I have also tried the 20X4 display and two different 16×2 units with the same issues. I do get a warning during the compilation to the effect that the “library claims to function with this device” etc. I have not tried any other libraries because I don’t know which one would be better. I also reversed the two NodeMcu 32S devices with the same results.
Moving on
KentM
Hi.
I’m sorry you’re getting that issue. Honestly, I don’t know how to solve that.
If that issue crashes your project completely, maybe it is a good idea to use another type of display like an I2C OLED display.
I’m sorry that I can’t help much.
Regards,
Sara
This (random jibberesh ) is working perfectly now with another brand of LCD. I purchased it from ebay. The link is:
https://www.ebay.com/itm/2-Pack-1602-LCD-16×2-HD44780-Character-I2C-Serial-Interface-Module-Blue-USA/391683768799?ssPageName=STRK%3AMEBIDX%3AIT&_trksid=p2057872.m2749.l2649
Hope this helps everyone having the same problem.
After a few hours, even using the lcd module I recommended above, the random jibberish appeared again. By using RUI’s example from his “Home Automation Using 8266, Project 6, Unit 4 (which uses an ESP8266 instead of ESP32, I no longer get jibberish.
Steve
Hi Steve.
Thanks for sharing that.
The issue can be a certain brand of LCD, you’re right.
I’ll keep that in mind when someone comes across the same problem.
Regards,
Sara
I have been struggling for days with the same issue. what did help me getting rid of the “random gibberish” is to put 10k pullup resistors to VCC on both the data and clock lines
The gibberish is now gone, but ever so often some of the temperature digits would not display
Also create a sketch that uses the 10K pullups using the same libraries, LCD and sensor with MQTT, in other words just reading the temperature and displaying it to the LCD and then it works.
Not sure if there are timing issues using MQTT
Hi Brian.
Until now, I still don’t know what might be causing the issue.
Thanks for sharing that solution with us. I’ll keep that in mind.
Regards,
Sara
Hi Brian,
I am having a similar issue and Sara pointed me to your solution. Can you advise exactly how to wire in these resistors?
Many thanks
Paul
Hi Paul.
I think you need to connect a resistor from the data pins (SDA and SCL) to 3V3.
Regards,
Sara
I replicated the Mqtt project that uses a LCD display (20×4) and got a lot of this problem… Characters changing places, werids characters, etc…
After a good amount of research i could finally find the problem and an answer…
- The LCD is slow and cannot keep up the updates.
- lcd.clear() is very slow, and inside it it already have a delay(2000)
So the solution was to avoid lcd.clear() and slow down the speed for I2C to keep up. Solutions;
- In place of lcd.clear(), use lcd.setCursor(0, row) where row is the row you want to clear, than fill it with spaces ” ” like this: lcd.print(std::string(” “, lcdColumns).c_str()). After go back to the init of the row with setCursor and write what you want.
- For slow down and not have bad characters use this before print in lcd: Wire.setClock(10000), i tried only in setup() but it not worked, maybe because of rtos task in the example. you need to #include <Wire.h> for this.
New code example for MQTT, part2 (that uses LCD), with no LCD problems:
https://gist.github.com/dsantiago/653957dee1a8c12c664f97331405f067
Hi Diogo.
Thanks for sharing this solution. It might be usefuk for our readers.
At the moment, I’m out of the office, but when I get back, I’ll test the example and update the code of the eBook.
Thanks again.
Regards,
Sara
Great Sara, yeah there’s the book too, even though i am following the course “Learn ESP32 with Arduino IDE – 2nd Edition“.
The lcd.clear() can still be use it’s just slow… but the real trick was to use the Wire.setClock(10000)
Found in this video: