Hey guys, I'm very new to the Arduino/DIY circuit board scene.
I saw someone trying to make a GPS Speedometer but I'm unable to get any GPS fix (shown on the LCD) when everything is all connected even when sitting outside for 10min. I have tested the GPS module with a TinyGPS++ code and it works fine.
my power supply input is only from a USB power bank ( not from the circuit board pins as shown on the picture)
The serial monitor show's: ⸮⸮
I'm using the following equipment:
- Arduino Nano 3.0
- U-blox 6M GPS module
- 0.96 Inch 128x64 IIC I2c White / Blue OLED LCD Display Module 3.3/5v For Arduino]
#define Program_Version "V1.2"
#define authorname "Stuart Robinson"
#include <TinyGPS++.h> //get library here > http://arduiniana.org/libraries/tinygpsplus/
TinyGPSPlus gps; //create the TinyGPS++ object
#define RXpin A3 //pin number for GPS RX input into Arduino - TX from GPS
#define TXpin A2 //pin number for GPS TX output from Arduino- RX into GPS
#define GPSPOWER -1 //Pin that controls power to GPS, set to -1 if not used
#define GPSONSTATE HIGH //logic level to turn GPS on via pin GPSPOWER
#define GPSOFFSTATE LOW //logic level to turn GPS off via pin GPSPOWER
#include <SoftwareSerial.h>
SoftwareSerial GPSserial(RXpin, TXpin);
#include <U8x8lib.h> //get library here > https://github.com/olikraus/u8g2
U8X8_SSD1306_128X64_NONAME_HW_I2C disp(U8X8_PIN_NONE); //use this line for standard 0.96" SSD1306
//U8X8_SH1106_128X64_NONAME_HW_I2C disp(U8X8_PIN_NONE); //use this line for 1.3" OLED often sold as 1.3" SSD1306
float GPSLat; //Latitude from GPS
float GPSLon; //Longitude from GPS
float GPSAlt; //Altitude from GPS
uint8_t GPSSats; //number of GPS satellites in use
uint32_t GPSHdop; //HDOP from GPS
float GPSSpeed; //Speed of GPS, mph
uint8_t hours, mins, secs, day, month;
uint16_t year;
uint32_t startGetFixmS;
uint32_t endFixmS;
void loop()
{
if (gpsWaitFix(5))
{
Serial.println();
Serial.println();
Serial.print(F("Fix time "));
Serial.print(endFixmS - startGetFixmS);
Serial.println(F("mS"));
GPSLat = gps.location.lat();
GPSLon = gps.location.lng();
GPSAlt = gps.altitude.meters();
GPSSats = gps.satellites.value();
GPSHdop = gps.hdop.value();
GPSSpeed = gps.speed.mph();
hours = gps.time.hour();
mins = gps.time.minute();
secs = gps.time.second();
day = gps.date.day();
month = gps.date.month();
year = gps.date.year();
printGPSfix(); //print GPS data to serial monitor
displayscreen1(); //print GPS data on display
startGetFixmS = millis(); //have a fix, next thing that happens is checking for a fix, so restart timer
}
else
{
disp.clearLine(0);
disp.setCursor(0, 0);
disp.print(F("No GPS Fix "));
disp.print( (millis() - startGetFixmS) / 1000 );
Serial.println();
Serial.println();
Serial.print(F("Timeout - No GPS Fix "));
Serial.print( (millis() - startGetFixmS) / 1000 );
Serial.println(F("s"));
}
}
bool gpsWaitFix(uint16_t waitSecs)
{
//waits a specified number of seconds for a fix, returns true for good fix
//note that the characters from the GPS are encoded until the location, altitude and date are updated
//this ensures that the GPGGA and GPRMC sentences have both been received and decoded.
uint32_t endwaitmS;
uint8_t GPSchar;
Serial.print(F("Wait GPS Fix "));
Serial.print(waitSecs);
Serial.println(F(" seconds"));
endwaitmS = millis() + (waitSecs * 1000);
while (millis() < endwaitmS)
{
if (GPSserial.available() > 0)
{
GPSchar = GPSserial.read();
gps.encode(GPSchar);
Serial.write(GPSchar);
}
if (gps.location.isUpdated() && gps.altitude.isUpdated() && gps.date.isUpdated())
{
endFixmS = millis(); //record the time when we got a GPS fix
return true;
}
}
return false;
}
void printGPSfix()
{
float tempfloat;
Serial.print(F("New GPS Fix "));
tempfloat = ( (float) GPSHdop / 100);
Serial.print(F("Latitude,"));
Serial.print(GPSLat, 6);
Serial.print(F(",Longitude,"));
Serial.print(GPSLon, 6);
Serial.print(F(",Altitude,"));
Serial.print(GPSAlt, 1);
Serial.print(F("m,Speed,"));
Serial.print(GPSSpeed, 1);
Serial.print(F("mph,Sats,"));
Serial.print(GPSSats);
Serial.print(F(",HDOP,"));
Serial.print(tempfloat, 2);
Serial.print(F(",Time,"));
if (hours < 10)
{
Serial.print(F("0"));
}
Serial.print(hours);
Serial.print(F(":"));
if (mins < 10)
{
Serial.print(F("0"));
}
Serial.print(mins);
Serial.print(F(":"));
if (secs < 10)
{
Serial.print(F("0"));
}
Serial.print(secs);
Serial.print(F(",Date,"));
Serial.print(day);
Serial.print(F("/"));
Serial.print(month);
Serial.print(F("/"));
Serial.print(year);
Serial.println();
Serial.println();
}
void displayscreen1()
{
//show GPS data on display
float tempfloat;
tempfloat = ( (float) GPSHdop / 100);
disp.clearLine(0);
disp.setCursor(0, 0);
disp.print(GPSLat, 6);
disp.clearLine(1);
disp.setCursor(0, 1);
disp.print(GPSLon, 6);
disp.clearLine(2);
disp.setCursor(0, 2);
disp.print(GPSAlt,0);
disp.print(F("m"));
disp.clearLine(3);
disp.setCursor(0, 3);
disp.print(GPSSpeed,0);
disp.print(F("mph"));
disp.clearLine(4);
disp.setCursor(0, 4);
disp.print(F("Sats "));
disp.print(GPSSats);
disp.clearLine(5);
disp.setCursor(0, 5);
disp.print(F("HDOP "));
disp.print(tempfloat);
disp.clearLine(6);
disp.setCursor(0, 6);
if (hours < 10)
{
disp.print(F("0"));
}
disp.print(hours);
disp.print(F(":"));
if (mins < 10)
{
disp.print(F("0"));
}
disp.print(mins);
disp.print(F(":"));
if (secs < 10)
{
disp.print(F("0"));
}
disp.print(secs);
disp.print(F(" "));
disp.clearLine(7);
disp.setCursor(0, 7);
disp.print(day);
disp.print(F("/"));
disp.print(month);
disp.print(F("/"));
disp.print(year);
}
void GPSON()
{
if (GPSPOWER)
{
digitalWrite(GPSPOWER, GPSONSTATE); //power up GPS
}
}
void GPSOFF()
{
if (GPSPOWER)
{
digitalWrite(GPSPOWER, GPSOFFSTATE); //power off GPS
}
}
void setup()
{
if (GPSPOWER >= 0)
{
pinMode(GPSPOWER, OUTPUT);
GPSON();
}
GPSserial.begin(9600);
Serial.begin(115200);
Serial.println();
Serial.print(F(__TIME__));
Serial.print(F(" "));
Serial.println(F(__DATE__));
Serial.println(F(Program_Version));
Serial.println();
disp.begin();
disp.setFont(u8x8_font_chroma48medium8_r);
disp.clear();
disp.setCursor(0, 0);
disp.print(F("Display Ready"));
Serial.println(F("29_GPS_Checker_With_Display Starting"));
Serial.println();
startGetFixmS = millis();
}