Serial IIC/I2C/TWI 2004 204 20X4 not displaying

Hi guys,

I purchased a 20x4 serial LCD like the one in the link bellow:
http://www.ebay.ca/itm/271711496582?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649

I connected the SDA to analog 4 and SCL to analog 5, GND to GND and VCC to 5V. It seems like the address of the device is 0x27.

The backplate of the LCD looks like this:

No matther if I try this:

LiquidCrystal_I2C lcd(0x20, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
or this
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

I cannot get the damn LCD to display anything with lcd.print. I can only turn the light on/off. I do not what I am doing wrong, but I am sure I got the LCD that I indicated in the picture. Maybe I am using the wrong library?.. Any ideas?

Any ideas?

There have been so many recent threads dealing with this topic that it is hard to believe that you did not find any, or did you not look?

Put the terms I2C LCD into the search box at the upper right and stand back.

Don

As much as I would like to agree, I did search quite a bit and since none of the libraries work, I do NOT know how to make it work. If I would, I would not be asking for sure. As I mentioned before, the device responds to the 0x27 address since this is the only one that I can make the backlight work with.

The LCD has a board saudered to the back of it that has no ID whatsoever, so I cannot tell what kind of LCD this is, but I provided the link from e-bay and it is 20x4 for sure. The LCD is connected to analog PINs 4&5. I do not know how to control these ports and I think the library would do this for me. I cannot control the LCD over the digital ports since I need them all.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DHT11.h>
#define sensorPIN 0
DHT11 sensor(sensorPIN);

int switchPin = 1; // switch auto/manual input
int motorBW1Pin1 = 2; // pin 2 on L293D1
int motorBW1Pin2 = 3; // pin 7 on L293D1
int enablePinBW1 = 4; // pin 1 on L293D1
int motorBW2Pin1 = 5; // pin 2 on L293D2
int motorBW2Pin2 = 6; // pin 7 on L293D2
int enablePinBW2 = 7; // pin 1 on L293D2

int motorTW1Pin1 = 8; // pin 15 on L293D1
int motorTW1Pin2 = 9; // pin 10 on L293D1
int enablePinTW1 = 10; // pin 9 on L293D1
int motorTW2Pin1 = 11; // pin 15 on L293D2
int motorTW2Pin2 = 12; // pin 10 on L293D2
int enablePinTW2 = 13; // pin 9 on L293D2
//LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
//LiquidCrystal_I2C lcd(0x20, 4, 5, 6, 0, 1, 2, 3, 7, NEGATIVE); // Set the LCD I2C address
LiquidCrystal_I2C lcd(0x27,20,4);
/-----( Declare Variables )-----/

int automode; //auto mode variable
int manual; //manual mode variable
int tw; //top windows open/close variable
int bw; //bottom windows open/close variable
int twarn; //temperature warning variable
int hwarn; //humidity warning variable
float temp; //temperature
float humid; //humidity
float tempa; //previous temperature
float humida; //previous humidity

double dewPoint(double celsius, double humidity)
{
double RATIO = 373.15 / (273.15 + celsius);
double RHS = -7.90298 * (RATIO - 1);
RHS += 5.02808 * log10(RATIO);
RHS += -1.3816e-7 * (pow(10, (11.344 * (1 - 1/RATIO ))) - 1) ;
RHS += 8.1328e-3 * (pow(10, (-3.49149 * (RATIO - 1))) - 1) ;
RHS += log10(1013.246);
double VP = pow(10, RHS - 3) * humidity;
double T = log(VP/0.61078); // temp var
return (241.88 * T) / (17.558 - T);
}

double dewPointFast(double celsius, double humidity)
{
double a = 17.271;
double b = 237.7;
double temp = (a * celsius) / (b + celsius) + log(humidity*0.01);
double Td = (b * temp) / (a - temp);
return Td;
}

void topWclose() {
digitalWrite(enablePinTW1, HIGH);
digitalWrite(motorTW1Pin1, LOW); // set pin 15 on L293D low
digitalWrite(motorTW1Pin2, HIGH); //set pin 10 on L293D high
digitalWrite(enablePinTW2, HIGH);
digitalWrite(motorTW2Pin1, LOW); // set pin 15 on L293D low
digitalWrite(motorTW2Pin2, HIGH); //set pin 10 on L293D high
delay(3000);
digitalWrite(enablePinTW1, LOW);
digitalWrite(motorTW1Pin1, LOW); // set pin 15 on L293D low
digitalWrite(motorTW1Pin2, LOW); //set pin 10 on L293D high
digitalWrite(enablePinTW2, LOW);
digitalWrite(motorTW2Pin1, LOW); // set pin 15 on L293D low
digitalWrite(motorTW2Pin2, LOW); //set pin 10 on L293D high
tw=0;
lcd.setCursor(19,2); //notify on the screen
lcd.print(“C”);
delay(1000);
}

void topWopen() {
digitalWrite(enablePinTW1, HIGH);
digitalWrite(motorTW1Pin1, HIGH); // set pin 15 on L293D low
digitalWrite(motorTW1Pin2, LOW); //set pin 10 on L293D high
digitalWrite(enablePinTW2, HIGH);
digitalWrite(motorTW2Pin1, HIGH); // set pin 15 on L293D low
digitalWrite(motorTW2Pin2, LOW); //set pin 10 on L293D high
delay(3000);
digitalWrite(enablePinTW1, LOW);
digitalWrite(motorTW1Pin1, LOW); // set pin 15 on L293D low
digitalWrite(motorTW1Pin2, LOW); //set pin 10 on L293D high
digitalWrite(enablePinTW2, LOW);
digitalWrite(motorTW2Pin1, LOW); // set pin 15 on L293D low
digitalWrite(motorTW2Pin2, LOW); //set pin 10 on L293D high
tw=1;
lcd.setCursor(19,2); //notify on the screen
lcd.print(“O”);
delay(1000);
}

void bottomWopen() {
digitalWrite(enablePinBW1, HIGH);
digitalWrite(motorBW1Pin1, HIGH); // set pin 15 on L293D low
digitalWrite(motorBW1Pin2, LOW); //set pin 10 on L293D high
digitalWrite(enablePinBW2, HIGH);
digitalWrite(motorBW2Pin1, HIGH); // set pin 15 on L293D low
digitalWrite(motorBW2Pin2, LOW); //set pin 10 on L293D high
delay(3000);
digitalWrite(enablePinBW1, LOW);
digitalWrite(motorBW1Pin1, LOW); // set pin 15 on L293D low
digitalWrite(motorBW1Pin2, LOW); //set pin 10 on L293D high
digitalWrite(enablePinBW2, LOW);
digitalWrite(motorBW2Pin1, LOW); // set pin 15 on L293D low
digitalWrite(motorBW2Pin2, LOW); //set pin 10 on L293D high
bw=1;
lcd.setCursor(8,2);
lcd.print(“O”);
delay(1000);
}

void bottomWclose() {
digitalWrite(enablePinBW1, HIGH);
digitalWrite(motorBW1Pin1, LOW); // set pin 15 on L293D low
digitalWrite(motorBW1Pin2, HIGH); //set pin 10 on L293D high
digitalWrite(enablePinBW2, HIGH);
digitalWrite(motorBW2Pin1, LOW); // set pin 15 on L293D low
digitalWrite(motorBW2Pin2, HIGH); //set pin 10 on L293D high
delay(3000);
digitalWrite(enablePinBW1, LOW);
digitalWrite(motorBW1Pin1, LOW); // set pin 15 on L293D low
digitalWrite(motorBW1Pin2, LOW); //set pin 10 on L293D high
digitalWrite(enablePinBW2, LOW);
digitalWrite(motorBW2Pin1, LOW); // set pin 15 on L293D low
digitalWrite(motorBW2Pin2, LOW); //set pin 10 on L293D high
bw=0;
lcd.setCursor(8,2); //notify on the screen
lcd.print(“C”);
delay(1000);
}

void setup () {
Serial.begin(9600); // Used to type in characters
lcd.clear();
lcd.begin(20,4); // initialize the lcd for 20x4
lcd.noBacklight(); //turn backlight off
automode=1;
manual=0;
tw=0;
bw=0;
twarn=0;
hwarn=0;
lcd.setCursor(0,0); //display main screen
lcd.print(“CTRL:AUTO DEWC: 0.00”);
lcd.setCursor(0,1);
lcd.print(“TC: 0.0 - H%: 0.0 -”);
lcd.setCursor(0,2);
lcd.print(“BWINDOW:C RWINDOW:C”);
lcd.setCursor(0,3);
lcd.print(“TWARN:OFF HWARN:OFF”);
digitalWrite(enablePinBW1, LOW);
digitalWrite(enablePinBW2, LOW);
digitalWrite(enablePinTW1, LOW);
digitalWrite(enablePinTW2, LOW);
}

void loop() {
int sensorread = sensor.read(temp, humid);
lcd.setCursor(9,1);
if(tempa<temp)
{
lcd.print("^");
}
else
{
if(tempa=temp)
{
lcd.print("-");
}
else
{
lcd.print(“v”);
}
}
lcd.setCursor(19,1);
if(humida<humid)
{
lcd.print("^");
}
else
{
if(humida=humid)
{
lcd.print("-");
}
else
{
lcd.print(“v”);
}
}
tempa=temp;
humida=humid;
lcd.setCursor(0,1);
lcd.print(“TC: H%:”);
lcd.setCursor(3,1);
lcd.print((float)temp,2);
lcd.setCursor(14,1);
lcd.print(humid);
lcd.setCursor(15,0);
lcd.print(dewPoint(temp,humid));
if (digitalRead(switchPin) == HIGH) {
automode=0;
manual++;
switch (manual) {
case 1:{
lcd.setCursor(0,0);
lcd.print(“CTRL:MANU”);
}
case 2:{
if (tw==1)
{
topWclose();
}
if (bw==1)
{
bottomWclose();
}
}
case 3:{
topWopen();
}
case 4:{
bottomWopen();
}
case 5:{
automode=1;
manual=0;
lcd.setCursor(0,0);;
lcd.print(“CTRL:AUTO”);
if (tw==1)
{

topWclose();
}
if (bw==1)
{
bottomWclose();
}
delay(1000);
}
}
}
if (temp>=24)
{
if ((automode==1) && (tw==0))
{
topWopen();
}
}
if (temp>=28)
{
if ((automode==1) && (bw==0))
{
bottomWopen();
}
if ((temp>=25) && (automode==0))
{
lcd.setCursor(6,3);
lcd.print("ON ");
twarn=1;
}
if ((temp>=28) && (automode==0))
{
lcd.setCursor(0,0);
lcd.print(“CTRL:AUTO”);
lcd.setCursor(6,3);
lcd.print(“OFF”);
automode=1;
manual=0;
twarn=0;
}
if ((temp>=32) && (automode==1) && (twarn==0))
{
twarn=1;
lcd.setCursor(6,3);
lcd.print("ON ");
}
if ((temp<32) && (automode==1) && (twarn==1))
{
twarn=0;
lcd.setCursor(6,3);
lcd.print(“OFF”);
}
}
if (temp<=26)
{
if ((automode==1) && (bw==1))
{
bottomWclose();
}
}
if (temp<=22)
{
if ((automode==1) && (tw==1))
{
topWclose();
}
if ((temp<10) && (twarn==0))
{
twarn=1;
lcd.setCursor(6,3); //notify on the screen
lcd.print("ON ");
}
if ((temp>=10) && (twarn==1))
{
twarn=0;
lcd.setCursor(6,3); //notify on the screen
lcd.print(“OFF”);
}
if ((humid>=50) && (automode==1) && (hwarn==0))
{
hwarn=1;
lcd.setCursor(17,3);
lcd.print("ON ");
}
if ((humid<50) && (automode==1) && (hwarn==1))
{
hwarn=0;
lcd.setCursor(17,3);
lcd.print(“OFF”);
}
}
delay(5000);
}

OK, two important things:

  • Start by reading the forum instructions, specifically number 7, go back and modify your post above so that we can look at the code properly.
  • I'll tell you the secret. You need to use bperrybap's I2Cguesser script to find the correct descriptor for the display. And you really need to have installed fmalpartida's library instead of the original LCD library (that is, you need to remove the original)

.

OK. I did remove the original libraries from /usr/share/arduino/libraries and this is the code. The code compiles with no error. If I load another library, I can use the LiquidCrystal_I2C lcd(0x27,20,4), but it still behaves the same. Nothing to display. Just the light on/off and that’s it.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
//LiquidCrystal_I2C lcd(0x20, 4, 5, 6, 0, 1, 2, 3, 7, NEGATIVE); // Set the LCD I2C address
//LiquidCrystal_I2C lcd(0x27,20,4);

void setup () {
Serial.begin(9600); // Used to type in characters
lcd.clear();
lcd.begin(20,4); // initialize the lcd for 20x4
lcd.backlight();
delay(5000);
lcd.noBacklight(); //turn backlight off
lcd.setCursor(0,0); //display main screen
lcd.print(“Hey! Nothing?”);
delay(5000);
}

void loop() {
}

OK, perhaps now you should do what I just explained.

I ran the guesses script and I get this:

i2c device found at address 0x27
Device found: PCF8574

Trying: lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE) - blinks three times and keeps the LCD ON

Trying: lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, NEGATIVE) - blinks three times turns the LCD OFF

The other steps just blink the LCD… So what should I try now?

I suggest you write another program, just for testing the LCD, without all that other stuff.

When you have figured out how the LCD works, then incorporate it into your project.

Well, I did as you can tell from the above post.

None of these work:

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, NEGATIVE);
LiquidCrystal_I2C lcd(0x27,20,4);

They all behave the same way - there is no text on the LCD.

This does not display anything:

#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

void setup () {
Serial.begin(9600);
lcd.clear();
lcd.begin(20,4);
lcd.setCursor(0,0);
lcd.print(“Hey! Nothing?”);
delay(5000);
}

void loop() {
}

You are still ignoring my advice to read the forum posting instructions and correct how you are posting code in all your previous submissions.

Why?

And you have not explained - when you run the "guesser" sketch, does the descriptor appear on the display itself?

If not, your display is unusable - for whatever reason.

Except that - blunderingly obvious things first - do you actually know how to set the contrast control?

Connect only Vcc and Ground, adjust the contrast control until you can see a row of blocks on the first line only. The setting will be near one end of the potentiometer travel. Once that is set, proceed to the guesser.

It was the potentiometer... Face palm...

Muggins us - should have been obvious from the first enquiry. Basic things first.

How about going back and just tidying up your code postings?