The LCD1602 can't print on

Hi,
I am testing a Arduino + GPS - 6M + LCD1602 unit, the Serial Monitor can print: 28.xxxxxx; 77.xxxxxx , but the LCD doesn't shown any.
what's wrong?
Thanks

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

/////////////////
#include <SoftwareSerial.h>
#include <TinyGPS.h>

//long   lat,lon; // create variable for latitude and longitude object
float lat = 28.5458, lon = 77.1703; // create variable for latitude and longitude object
SoftwareSerial gpsSerial(3, 4); //rx,tx

TinyGPS gps; // create gps object

///////////////

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

void setup()
{

  Serial.begin(9600); // connect serial
  //Serial.println("The GPS Received Signal:");
  //// gpsSerial.begin(9600); // connect gps sensor
  lcd.begin(16, 2);

  lcd.init();                      // initialize the lcd
  lcd.init();
  lcd.backlight();
}


void loop()
{
  while (gpsSerial.available()) { // check for gps data
    if (gps.encode(gpsSerial.read())) // encode gps data
    {
      gps.f_get_position(&lat, &lon); // get latitude and longitude
      // display position
      lcd.clear();
      lcd.setCursor(1, 0);
      lcd.print("GPS Signal");
      //Serial.print("Position: ");
      //Serial.print("Latitude:");
      //Serial.print(lat,6);
      //Serial.print(";");
      //Serial.print("Longitude:");
      //Serial.println(lon,6);
      lcd.setCursor(1, 0);
      lcd.print("LAT:");
      lcd.setCursor(5, 0);
      lcd.print(lat);
      //Serial.print(lat);
      //Serial.print(" ");

      lcd.setCursor(0, 1);
      lcd.print(",LON:");
      lcd.setCursor(5, 1);
      lcd.print(lon);

    }
  }

  String latitude = String(lat, 6);
  String longitude = String(lon, 6);
  Serial.println(latitude + ";" + longitude);
  delay(1000);

}

Have you tested the LCD on its own? Does it behave as expected?

Have you tested your lcd with the same wiring but a simple hello world code?

Why do you call init() twice?

lcd.init();                      // initialize the lcd
  lcd.init();

You seem to have a 20x4 lcd and not a 16x2

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

its address is likely 0x3F and not 0x27. Don’t keep stupidly confusing comments in the code...

Don’t use the String class esp. when it’s not needed. Don’t do

 String latitude = String(lat, 6);
  String longitude = String(lon, 6);
  Serial.println(latitude + ";" + longitude);

when you simply can do

  Serial.print(lat, 6);
  Serial.write(’;’);
  Serial.println(lon, 6);

for the exact same output and way less memory used by your code

sterretje:
Have you tested the LCD on its own? Does it behave as expected?

Yes, it print 'Hello!' at other code.

laoadam:
Yes, it print 'Hello!' at other code.

Post the code that does that.

J-M-L:
Have you tested your lcd with the same wiring but a simple hello world code?

Why do you call init() twice?

lcd.init();                      // initialize the lcd

lcd.init();




You seem to have a 20x4 lcd and not a 16x2


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



its address is likely 0x3F and not 0x27. Don’t keep stupidly confusing comments in the code...

Don’t use the String class esp. when it’s not needed. Don’t do


String latitude = String(lat, 6);
  String longitude = String(lon, 6);
  Serial.println(latitude + ";" + longitude);



when you simply can do


Serial.print(lat, 6);
  Serial.write(’;’);
  Serial.println(lon, 6);



for the exact same output and way less memory used by your code

Thank you for the detail.
It prints 'hello everyone" and "konichiwaa" , and I corrected the details and try. still no print.

wildbill:
Post the code that does that.

wildbill:
Post the code that does that.

Thanks.
Actually it prints ''hello everyone" and "konichiwaa" as the first post.

//// gpsSerial.begin(9600); // connect gps sensorAs long as there isn't a sketch posted that doesn't have this commented out ://// gpsSerial.begin(9600); // connect gps sensorNothing will happen i think

J-M-L:
Have you tested your lcd with the same wiring but a simple hello world code?

Why do you call init() twice?

lcd.init();                      // initialize the lcd

lcd.init();

In his defense, that goofy double init sequence is in the "HelloWorld" example that comes with the LiquidCrystal_I2C library.

--- bill

Deva_Rishi:

//// gpsSerial.begin(9600); // connect gps sensor

As long as there isn't a sketch posted that doesn't have this commented out :

//// gpsSerial.begin(9600); // connect gps sensor

Nothing will happen i think

Thanks.
I enabled gpsSerial.begin(9600); still nothing improve. The GPS doesn't works in both situations, because it output the wrong data of the GPS Latitude / Longitude compare with what I got on Google map.
my coordinate is 43.xxxxxx / -79.xxxxxxx, the Serial Monitor got: 28.xxxxxx, 77.xxxxxx

BTW: my coordinate is 43.xxxxxx / -79.xxxxxxx, can I add a '-' into it?

Best

bperrybap:
In his defense, that goofy double init sequence is in the "HelloWorld" example that comes with the LiquidCrystal_I2C library.

--- bill

Thanks.
I have deleted one * lcd.init(); I'll try to change another Lib.*

laoadam:
Thanks.
I have deleted one lcd.init(); I'll try to change another Lib.

If you are seeing the expected output on the LCD with an lcd test sketch, the lcd library isn't the issue.
But if you want to try another library, I would suggest using the hd44780 library and use the hd44780_I2Cexp i/o class.
If you do, first run the included I2CexpDiag sketch to test that everything is working.
You can install it directory from the IDE (don't use a zip file)
Documentation can be found in the Documentation sketch.
Here is the github page:

--- bill

Thanks for all helps.
I changed some code like:

while (ss.available() > 0) {
    gps.encode(ss.read());
    if (gps.location.isUpdated()) {
      Serial.print("Latitude= ");
      Serial.print(gps.location.lat(), 6);
      Serial.print(" Longitude= ");
      Serial.println(gps.location.lng(), 6);
    }
  }

It works, and the LCD shown what GPS got.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.