Even simplest LCD I2C dispalys garbage

Trying to test a new 20x4 LCD but getting garbage. The LCD is wired onto the board directly and I chose very simple display code. I installed the Liquidcrystal_i2c library.

Code:

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 20 chars and 4 line display

void setup() {
lcd.init();
lcd.clear();
lcd.backlight(); // Make sure backlight is on

// Print a message on 2 lines of the LCD.
lcd.setCursor(2,0); //Set cursor to character 2 on line 0
lcd.print("Hello world!");

lcd.setCursor(2,1); //Move cursor to character 2 on line 1
lcd.print("LCD Tutorial");
}

void loop() {
}

Does the garbage change if you change what is printed?

Please remember to use code tags when posting code

What happens when you run the sketch you copied from?
https://github.com/johnrickman/LiquidCrystal_I2C/blob/master/examples/HelloWorld/HelloWorld.pde

Sorry, am a noob and don't know what you mean by code tags?

Yes, the displayed text does change if i change the text in the code. It also seems to cycle between two types of garbage if is just re-upload the same code again.

You have mixed 3.3V and 5V logic.

I still get garbage.

It sometimes changes what it shows if i re-upload the same code.

You might need I2C 3.3V-5V level converters. Can you try it with an UNO or Mega or some 5V board?

This board has a 5V pin though?

That's the external supply voltage. Doesn't help with the I/O pin difference. Please answer my question!

Sorry. I don't have other Arduino boards to try. I do have a pi3 B+ which i could try but need to hunt the code for that

You may need this (I couldn't find the 2 channel version, this is the 4 channel):
https://www.sparkfun.com/products/12009
but I strongly advise you to try the display with an UNO or Nano etc. first...
I haven't played with the pi3 yet, but I thought it was also 3.3V.

Ah, yes, I have a level shifter. will see if i can figure that out. thx

1 Like

...and hope you haven't blown the Leo pins...

Well i was following the basic 4 wire connection schemes that are all over the internet. +5v, ground, SDA and SCL -why would that blow something?

Because everything you read on the internet is true. :slight_smile:

1 Like

You don't need any level shifters. Just connect to 5V, GND, SCL, SDA pins on the Leo.

LiquidCrystal_I2C libraries are suspect. We don't know which LiquidCrystal_I2C library you have installed or where you got it from.

I strongly advise installing Bill Perry's hd44780.h library via the IDE Library Manager.
There is a diagnostic sketch in the examples.
C:\Users\ .. \Documents\Arduino\libraries\hd44780\examples\ioClass\hd44780_I2Cexp\I2CexpDiag\I2CexpDiag.ino

David.

Thanks, i will try that

Are you thinking, because there is no MOSFET pull up on the 5V side? What about the logic thresholds? Long term reliability?

Consider:
" Since the I2C bus lines are used bidirectionally, interfacing I2C devices with different voltages is not straightforward, special level-shifting devices are necessary for this purpose."
http://www.i2c-bus.org/voltage-level/

OK, so I tried a different library as this is a PCF8574 adaptor. With my 2 line display it now works but not the 4 line display (both are PCF8574).
As I have something working now, i will try and expand out form there.
Thx for your assistance

1 Like

Run the diagnostic sketch on the 16x2 and on the 20x4. Copy-Paste from the Serial Terminal to your message. (we only need to the 20x4 output)

When we see that, we can determine whether your display is faulty or not. The sooner you know, the sooner you can ask the shop for a refund.

David.