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);
}
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
//// 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
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?
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: