Help with refreshing velocity GPS shield


#1

Hi all, Im trying to use the gps shield to tell me vehicle speed. Unfortunately i cant seem to figure out whats going on. It tells me the speed for a small amount of time, then says 0 mph for a few seconds, then tells me my actual speed again. Im sure its something simple with the library but I cant seem to find any documentation of the functions besides the example code.

Heres the code im running on my arduino duemilanova.

im currently printing to an i2c LCD.

/*
This program demonstrates the dGPS library from Dexter Industries for Arduino

For use with the Dexter Industries GPS Shield. The dGPS can be found here:

This code was originally based on the work of others. You can see the original work here:

See our Arduino GPS Converting Coordinates for information on converting coordinates
from GPS Style Coordinates (ddmm.ssss) to Decimal Style Coordinates (dd.mmssss).

How it works:

  • The dGPS requires the SoftwareSerial.h library.
  • The GPS is initialized in the setup function.
  • The GPS is updated: values for location, time, etc, are updated using the “.update” function.
  • The values are read using their respective calls. These values stay the same until “update” is called again.
    */

#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

#include “string.h”
#include “ctype.h”
#include “SoftwareSerial.h”
#include “dGPS.h”

// Software serial TX & RX Pins for the GPS module
// Initiate the software serial connection

float desLat=0; //Destination Latitude filled by user in Serial Monitor Box
float desLon=0; //Destination Longitude filled by user in Serial Monitor Box
dGPS dgps = dGPS(); // Construct dGPS class

float MPH = 0;

void setup()
{

Serial.end(); // Close any previously established connections
Serial.begin(9600); // Serial output back to computer. On.

dgps.init(); // Run initialization routine for dGPS.
lcd.begin(16,2);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Loading…”);
delay(1000);

}

void loop()
{
dgps.update(desLat, desLon); // Calling this updates the GPS data. The data in dGPS variables stays the same unless
// this function is called. When this function is called, the data is updated.

//Serial.print("Knots: ");
//Serial.print(dgps.Vel(), 6); // Velocity, in knots.

MPH = (dgps.Vel())*1.15;

lcd.clear();
lcd.setCursor(0,0);
lcd.print("MPH: ");
lcd.print(MPH);

lcd.setCursor(0,1);
lcd.print("Knots: ");
lcd.print(dgps.Vel());
delay(100);
}


#2

You may be trying to read this too frequently. The GPS chip operates at 1HZ so it will only update one time per second. There may also be a lag in the update that causes a timeout in your lcd.print function on line 71.

A few quick thoughts and things to try:

Make a new variable “knots” that holds the knots value as such:

MPH = (dgps.Vel())*1.15;
to

KNOTS = dgps.Vel();
MPH = (KNOTS)*1.15;

lcd.clear();
lcd.setCursor(0,0);
lcd.print(“MPH: “);
lcd.print(MPH);

lcd.setCursor(0,1);
lcd.print(“Knots: “);
lcd.print(KNOTS);
delay(100);

You migth also want to try increasing your delay to 2000 and see if it makes a difference.


#3

The delay just held my MPH reading a little longer before reading zero again.

I think this library function has something to do with my problem.
dgps.update(desLat, desLon);

Heres my updated code

#include &lt;Wire.h&gt; 
#include &lt;LiquidCrystal_I2C.h&gt;
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

#include &quot;string.h&quot;
#include &quot;ctype.h&quot;
#include &quot;SoftwareSerial.h&quot;
#include &quot;dGPS.h&quot;

// Software serial TX &amp; RX Pins for the GPS module
// Initiate the software serial connection

float desLat=0;                   //Destination Latitude filled by user in Serial Monitor Box
float desLon=0;                   //Destination Longitude filled by user in Serial Monitor Box
dGPS dgps = dGPS();               // Construct dGPS class

float MPH = 0;
float KNOTS = 0;

void setup() 
{
  
  Serial.end();                  // Close any previously established connections
  Serial.begin(9600);            // Serial output back to computer.  On.
  dgps.init();                   // Run initialization routine for dGPS.
  lcd.begin(16,2);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print(&quot;Loading...&quot;);
  delay(1000);
    

}

void loop() 
{
  
  dgps.update(desLat, desLon);                 
  
  Serial.print(&quot;Knots: &quot;);
  Serial.print(dgps.Vel(), 6);  
  
  KNOTS = dgps.Vel();
  MPH = (KNOTS)*1.15;
  
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print(&quot;MPH: &quot;);
  lcd.print(MPH);
  
  lcd.setCursor(0,1);
  lcd.print(&quot;Knots: &quot;);
  lcd.print(dgps.Vel());
  delay(2000);
}


#4

Nvm, i used the tinyGPS library and got it working.
Thanks