My lcd works just fine but after several minutes, it prints like this. Why is this happening?
Post your code and circuit diagram.
The problem is likely to be in the wiring, or the code you forgot to post.
Post a picture from the hardware set up.
Especially the connections of the LCD.
The lcd is connected to A4 and A5
It's pretty hard to understand. But, I wanna know what are the factors why this is happening.
I have a feeling that it is because of the power supply. Whenever I unplug the power supply, it works just fine.
Post a big picture of these connections.
I tested all the continuity, it's fine.
D5 and D6 looks shorted.
The best way is to resolder all connection correctly.
It appears to me that the host (the arduino board) and the lcd have lost nibble sync.
The symptom of this is that everything works for a while, then the display goes bonkers.
The issue you are likely seeing is some sort of voltage or noise creating signal corruption that causes the host and the LCD to lose nibble sync.
The hd44780 has two modes, 8 bit and 4 bit.
When in 4 bit mode, each nibble is sent. There is no synchronization.
I.e. once the chip is put into 4 bit mode, the host and the LCD must remain in sync with each other, If they get out of nibble sync, it will not recover on its own and the LCD will see garbage instructions since it is seeing nibble from one instruction combined with a nibble from the next instruction, which creates garbage instructions / data.
The only way to get back into nibble sync is to either power cycle the LCD and re-initalize the LCD, or have the host go back through the 4 bit initialization sequence.
The 4 bit initialization sequence puts the LCD into 8 bit mode regardless of what mode or state the LCD is in, and then it puts the LCD into 4 bit mode.
So the question becomes how do the host and the LCD get out of nibble sync.
This happens when a nibble is lost or an extra nibble sent.
In your case you are using a backpack with an i2c i/o expander chip, so the question becomes how does a nibble get lost or a fake nibble get sent?
This can be caused by signal or voltage noise.
There i2c bus is not very robust and often does not detect noise issues that causes data corruption.
Noise on the i2c bus can cause data to be corrupted or even lost depending on what bits got corrupted on the bus.
The AVR Wire library does report errors that are detected but most libraries like the LiquidCrystal_I2C library don't ever look at the return values from sending data to the LCD backpack and don't report any errors back to the sketch.
The hd44780 library does look at Wire library return values and does report status back to the sketch.
Neither library does retries on failed attempts to write to the i2c slave.
(I don't see this as an issue as a retry is unlikely to resolve the issue)
That said, there are many i2c issues that can go undetected to create data corruption so it is not uncommon to see the LCD issues you are seeing.
The best way check for noise issues would be hook a scope up to the power signals and and i2c signals to see what they look like.
Barring that, you can kind of go through a process of elimination in that things that commonly cause issues like noisy power supplies, and relays cause power issues.
And then induced noise into i2c signals from relays, weak i2c pullups, or i2c signal wires being too long or too close to other noisy signals.
--- bill
ok, looking closer at your photo it looks like your wiring could create some i2c signal issues.
i2c is meant for very short wires.
It looks like you are tapping the signals for the LCD and RTC at two different places.
This can cause potentially cause ringing issues or even ground loops on the signals.
Also, it looks like you are routing the a5/a5 signals through a hole in the box and then off to the backpack.
How long are the wires, and is that lamp cord being used for the wires?
And those wires looks like they are right up against some other wires which might create some noise issues.
--- bill
I see two potential issues:
- the soldering of the I2C is not good enough
- you are using I2C over long wires which are picking up noise from the environment
I2C is not a "wire bus". If you need a separate display, consider to use something like RS232, RS485, CAN, between your Controller and the display.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.