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:
- SoftwareSerial Library: http://www.arduino.cc/en/Reference/SoftwareSerial
- GPS Tutorial: http://www.arduino.cc/playground/Tutorials/GPS
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);
}