Skip to content

Commit

Permalink
GPS doesn't wanna work with pi pico Fuc
Browse files Browse the repository at this point in the history
  • Loading branch information
WonITKorea committed Mar 25, 2024
1 parent 35a77fb commit 67fcdb5
Show file tree
Hide file tree
Showing 4 changed files with 183 additions and 56 deletions.
4 changes: 2 additions & 2 deletions .vscode/arduino.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"sketch": "code\\Testing_Crate\\GPS_uBlox\\GPS_uBlox.ino",
"sketch": "code\\Testing_Crate\\GPSTest\\GPSTest.ino",
"board": "rp2040:rp2040:rpipico",
"port": "COM6",
"output": "../build",
"intelliSenseGen": "global",
"programmer": "esptool",
"configuration": "flash=2097152_0,freq=133,opt=Optimize,rtti=Disabled,stackprotect=Enabled,exceptions=Enabled,dbgport=Disabled,dbglvl=None,usbstack=picosdk,ipbtstack=ipv4only,uploadmethod=default"
"configuration": "flash=2097152_0,freq=133,opt=Small,rtti=Disabled,stackprotect=Disabled,exceptions=Enabled,dbgport=Disabled,dbglvl=None,usbstack=picosdk,ipbtstack=ipv4only,uploadmethod=default"
}
5 changes: 1 addition & 4 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,13 @@
"-mthumb",
"-ffunction-sections",
"-fdata-sections",
"-fexceptions",
"-fstack-protector"
"-fexceptions"
],
"intelliSenseMode": "gcc-x64",
"includePath": [
"C:\\Users\\user\\AppData\\Local\\Arduino15\\packages\\rp2040\\hardware\\rp2040\\3.7.2\\include",
"C:\\Users\\user\\AppData\\Local\\Arduino15\\packages\\rp2040\\hardware\\rp2040\\3.7.2\\cores\\rp2040",
"C:\\Users\\user\\AppData\\Local\\Arduino15\\packages\\rp2040\\hardware\\rp2040\\3.7.2\\variants\\rpipico",
"C:\\Users\\user\\AppData\\Local\\Arduino15\\packages\\rp2040\\hardware\\rp2040\\3.7.2\\libraries\\Wire\\src",
"C:\\Users\\user\\AppData\\Local\\Arduino15\\packages\\rp2040\\hardware\\rp2040\\3.7.2\\libraries\\SPI\\src",
"c:\\users\\user\\appdata\\local\\arduino15\\packages\\rp2040\\tools\\pqt-gcc\\2.2.0-d04e724\\arm-none-eabi\\include\\c++\\12.3.0",
"c:\\users\\user\\appdata\\local\\arduino15\\packages\\rp2040\\tools\\pqt-gcc\\2.2.0-d04e724\\arm-none-eabi\\include\\c++\\12.3.0\\arm-none-eabi\\thumb",
"c:\\users\\user\\appdata\\local\\arduino15\\packages\\rp2040\\tools\\pqt-gcc\\2.2.0-d04e724\\arm-none-eabi\\include\\c++\\12.3.0\\backward",
Expand Down
33 changes: 33 additions & 0 deletions code/Testing_Crate/GPSTest/GPSTest.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <SoftwareSerial.h>

// Choose two Arduino pins to use for software serial
int RXPin = 5;
int TXPin = 4;

// Default baud of NEO-6M is 9600
int GPSBaud = 9600;

// Create a software serial port called "gpsSerial"
SoftwareSerial gpsSerial(RXPin, TXPin);

void setup()
{
// Start the Arduino hardware serial port at 9600 baud
Serial.begin(9600);

// Start the software serial port at the GPS's default baud
gpsSerial.begin(GPSBaud);
}

void loop()
{
// Displays information when new sentence is available.
while (gpsSerial.available() > 0)
{
Serial.write(gpsSerial.read());
}
while (Serial.available() > 0)
{
gpsSerial.write(Serial.read());
}
}
197 changes: 147 additions & 50 deletions code/Testing_Crate/GPS_uBlox/GPS_uBlox.ino
Original file line number Diff line number Diff line change
Expand Up @@ -5,90 +5,187 @@
It requires the use of SoftwareSerial, and assumes that you have a
4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx).
*/
static const int RXPin = 4, TXPin = 3;
static const int RXPin = 3, TXPin = 4;
static const uint32_t GPSBaud = 9600;

// The TinyGPSPlus object
TinyGPSPlus gps;

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

// For stats that happen every 5 seconds
unsigned long last = 0UL;

void setup()
{
Serial.begin(115200);
ss.begin(GPSBaud);
delay(1000);

Serial.println("DeviceExample.ino");
Serial.println("A simple demonstration of TinyGPSPlus with an attached GPS module");
Serial.print("Testing TinyGPSPlus library v. "); Serial.println(TinyGPSPlus::libraryVersion());
Serial.println("by Mikal Hart");
Serial.println(F("KitchenSink.ino"));
Serial.println(F("Demonstrating nearly every feature of TinyGPSPlus"));
Serial.print(F("Testing TinyGPSPlus library v. ")); Serial.println(TinyGPSPlus::libraryVersion());
Serial.println(F("by Mikal Hart"));
Serial.println();
}

void loop()
{
// This sketch displays information every time a new sentence is correctly encoded.
// Dispatch incoming characters
while (ss.available() > 0)
if (gps.encode(ss.read()))
displayInfo();
gps.encode(ss.read());

if (millis() > 5000 && gps.charsProcessed() < 10)
if (gps.location.isUpdated())
{
Serial.println(F("No GPS detected: check wiring."));
while(true);
Serial.print(F("LOCATION Fix Age="));
Serial.print(gps.location.age());
Serial.print(F("ms Raw Lat="));
Serial.print(gps.location.rawLat().negative ? "-" : "+");
Serial.print(gps.location.rawLat().deg);
Serial.print("[+");
Serial.print(gps.location.rawLat().billionths);
Serial.print(F(" billionths], Raw Long="));
Serial.print(gps.location.rawLng().negative ? "-" : "+");
Serial.print(gps.location.rawLng().deg);
Serial.print("[+");
Serial.print(gps.location.rawLng().billionths);
Serial.print(F(" billionths], Lat="));
Serial.print(gps.location.lat(), 6);
Serial.print(F(" Long="));
Serial.println(gps.location.lng(), 6);
}
}

void displayInfo()
{
Serial.print(F("Location: "));
if (gps.location.isValid())
else if (gps.date.isUpdated())
{
Serial.print(gps.location.lat(), 6);
Serial.print(F(","));
Serial.print(gps.location.lng(), 6);
Serial.print(F("DATE Fix Age="));
Serial.print(gps.date.age());
Serial.print(F("ms Raw="));
Serial.print(gps.date.value());
Serial.print(F(" Year="));
Serial.print(gps.date.year());
Serial.print(F(" Month="));
Serial.print(gps.date.month());
Serial.print(F(" Day="));
Serial.println(gps.date.day());
}
else

else if (gps.time.isUpdated())
{
Serial.print(F("INVALID"));
Serial.print(F("TIME Fix Age="));
Serial.print(gps.time.age());
Serial.print(F("ms Raw="));
Serial.print(gps.time.value());
Serial.print(F(" Hour="));
Serial.print(gps.time.hour());
Serial.print(F(" Minute="));
Serial.print(gps.time.minute());
Serial.print(F(" Second="));
Serial.print(gps.time.second());
Serial.print(F(" Hundredths="));
Serial.println(gps.time.centisecond());
}

Serial.print(F(" Date/Time: "));
if (gps.date.isValid())
else if (gps.speed.isUpdated())
{
Serial.print(gps.date.month());
Serial.print(F("/"));
Serial.print(gps.date.day());
Serial.print(F("/"));
Serial.print(gps.date.year());
Serial.print(F("SPEED Fix Age="));
Serial.print(gps.speed.age());
Serial.print(F("ms Raw="));
Serial.print(gps.speed.value());
Serial.print(F(" Knots="));
Serial.print(gps.speed.knots());
Serial.print(F(" MPH="));
Serial.print(gps.speed.mph());
Serial.print(F(" m/s="));
Serial.print(gps.speed.mps());
Serial.print(F(" km/h="));
Serial.println(gps.speed.kmph());
}
else

else if (gps.course.isUpdated())
{
Serial.print(F("INVALID"));
Serial.print(F("COURSE Fix Age="));
Serial.print(gps.course.age());
Serial.print(F("ms Raw="));
Serial.print(gps.course.value());
Serial.print(F(" Deg="));
Serial.println(gps.course.deg());
}

Serial.print(F(" "));
if (gps.time.isValid())
else if (gps.altitude.isUpdated())
{
if (gps.time.hour() < 10) Serial.print(F("0"));
Serial.print(gps.time.hour());
Serial.print(F(":"));
if (gps.time.minute() < 10) Serial.print(F("0"));
Serial.print(gps.time.minute());
Serial.print(F(":"));
if (gps.time.second() < 10) Serial.print(F("0"));
Serial.print(gps.time.second());
Serial.print(F("."));
if (gps.time.centisecond() < 10) Serial.print(F("0"));
Serial.print(gps.time.centisecond());
Serial.print(F("ALTITUDE Fix Age="));
Serial.print(gps.altitude.age());
Serial.print(F("ms Raw="));
Serial.print(gps.altitude.value());
Serial.print(F(" Meters="));
Serial.print(gps.altitude.meters());
Serial.print(F(" Miles="));
Serial.print(gps.altitude.miles());
Serial.print(F(" KM="));
Serial.print(gps.altitude.kilometers());
Serial.print(F(" Feet="));
Serial.println(gps.altitude.feet());
}
else

else if (gps.satellites.isUpdated())
{
Serial.print(F("INVALID"));
Serial.print(F("SATELLITES Fix Age="));
Serial.print(gps.satellites.age());
Serial.print(F("ms Value="));
Serial.println(gps.satellites.value());
}

Serial.println();
delay(100);
}
else if (gps.hdop.isUpdated())
{
Serial.print(F("HDOP Fix Age="));
Serial.print(gps.hdop.age());
Serial.print(F("ms raw="));
Serial.print(gps.hdop.value());
Serial.print(F(" hdop="));
Serial.println(gps.hdop.hdop());
}

else if (millis() - last > 5000)
{
Serial.println();
if (gps.location.isValid())
{
static const double LONDON_LAT = 51.508131, LONDON_LON = -0.128002;
double distanceToLondon =
TinyGPSPlus::distanceBetween(
gps.location.lat(),
gps.location.lng(),
LONDON_LAT,
LONDON_LON);
double courseToLondon =
TinyGPSPlus::courseTo(
gps.location.lat(),
gps.location.lng(),
LONDON_LAT,
LONDON_LON);

Serial.print(F("LONDON Distance="));
Serial.print(distanceToLondon/1000, 6);
Serial.print(F(" km Course-to="));
Serial.print(courseToLondon, 6);
Serial.print(F(" degrees ["));
Serial.print(TinyGPSPlus::cardinal(courseToLondon));
Serial.println(F("]"));
}

Serial.print(F("DIAGS Chars="));
Serial.print(gps.charsProcessed());
Serial.print(F(" Sentences-with-Fix="));
Serial.print(gps.sentencesWithFix());
Serial.print(F(" Failed-checksum="));
Serial.print(gps.failedChecksum());
Serial.print(F(" Passed-checksum="));
Serial.println(gps.passedChecksum());

if (gps.charsProcessed() < 10)
Serial.println(F("WARNING: No GPS data. Check wiring."));

last = millis();
Serial.println();
}
}

0 comments on commit 67fcdb5

Please sign in to comment.