Display mph on lcd 1602a using neo 6m gps

i am very new to programming, i am trying to get a lcd screen to display gps calculated mph output. can someone look at my code and tell me what i am missing?

#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include <LiquidCrystal.h>

static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 9600;
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

// The TinyGPS++ object
TinyGPSPlus gps;

// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);

void setup(){
  Serial.begin(9600);
  ss.begin(GPSBaud);
  lcd.begin(16, 2);
}

void loop(){
 
  while (ss.available() > 0){
    gps.encode(ss.read());
    if (gps.location.isUpdated()){
  
      // Speed in miles per hour (double)
      Serial.print("Speed in miles/h = ");
      Serial.println(gps.speed.mph());
      lcd.setCursor(0, 0);
      lcd.print("Speed in mile/h = ");
      lcd.setCursor(6, 0);
      lcd.print(gps.speed.mph());
      delay (500); 
     
    }
  }
}

To debug your code, you can test your wiring connection first by running code for LCD only, and for GPS module only. If one of them does not work, fix it. If code for individual works, debug your combined code.

1 Like

You will have trouble squeezing this text into 16 characters:

lcd.print("Speed in mile/h = ");
           123456789012345678
2 Likes

what is the significance of the 18 digits? Is it that the lcd i have only supports 16 characters?

So you are saying i should verify that my lcd code displays characters from a different input? Then verify that the gps data shows up on the serial plotter? I have already tested both programs separately in similar scenarios but when i combine them, successfully compile, and upload to my porotype the gps is receiving and transmitting signal yet the lcd does not display my output.

yes, just need to verify the basic operation to determine if your individual components was wired correct or not.

  • For LCD, just show "Hello world", see Arduino LCD tutorial
  • For GPS, just print the data out on Serial Monitor.

If you are using breadboard, the wiring connection is not steady. it may be changed over time.

A possible reason is that, when you combine, the LCD does not have enough power, you can consider to add extra power source to the LCD display.

Sending extra characters to the LCD will not break it but you do not know if it will display them or not. Example: you have a bucket that will hold 10 items, but you have 11. They will not fit but if you have a bucket that will hold 10 no problem.

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