Real-time bike tracker using Adafruit Ultimate GPS, Huzzah wifi, and Pubnub
Dependencies: MBed_Adafruit-GPS-Library mbed
Revision 6:5bc3eeabdca3, committed 2017-04-23
- Comitter:
- ECE4180
- Date:
- Sun Apr 23 15:24:21 2017 +0000
- Parent:
- 5:786cb04aaecc
- Commit message:
- For Notebook Page
Changed in this revision
Huzzah.cpp | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 786cb04aaecc -r 5bc3eeabdca3 Huzzah.cpp --- a/Huzzah.cpp Fri Apr 21 01:03:26 2017 +0000 +++ b/Huzzah.cpp Sun Apr 23 15:24:21 2017 +0000 @@ -77,7 +77,7 @@ sprintf(cmdbuff, conn.c_str()); send_cmd(); getreply(); - wait(2.0); + wait(1.0); this->socket = true; pc.printf("socket opened\r\n"); @@ -113,11 +113,11 @@ sprintf(cmdbuff, conn.c_str()); send_cmd(); getreply(); - wait(2.0); + wait(0.5); sprintf(cmdbuff, r.c_str()); send_cmd(); - wait(1.0); + wait(0.5); send_cmd(); getreply(); wait(0.5);
diff -r 786cb04aaecc -r 5bc3eeabdca3 main.cpp --- a/main.cpp Fri Apr 21 01:03:26 2017 +0000 +++ b/main.cpp Sun Apr 23 15:24:21 2017 +0000 @@ -4,9 +4,9 @@ #include "PubNub.h" #include "Watchdog.h" -string pubkey("pub-c-f9091d93-c3a8-41a6-80c2-c6e3f840504f"); -string subkey("sub-c-f558e36c-130b-11e7-b59a-02ee2ddab7fe"); -string channel("demo"); +string pubkey("pub-c-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); +string subkey("sub-c-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); +string channel("biketracker"); PubNub pnub(pubkey, subkey, channel, p28, p27); // tx, rx @@ -43,7 +43,7 @@ while ((pnub.huz.esp.readable()) && (((rx_in + 1) % buffer_size) != rx_out)) { rx_buffer[rx_in] = pnub.huz.esp.getc(); // Uncomment to Echo to USB serial to watch data flow - pc.putc(rx_buffer[rx_in]); + //pc.putc(rx_buffer[rx_in]); rx_in = (rx_in + 1) % buffer_size; } return; @@ -64,12 +64,18 @@ int main() { - wdt.kick(8.0); + wdt.kick(7.0); pc.baud(115200); //Set PC baud rate + + //Uncomment Below to set-up new network + /* + //Update SSID and Password pnub.huz.setssid("Verizon-SM-G900V-258B"); pnub.huz.setpwd("trnd533)"); - //pnub.huz.espconfig(); - gps_Serial = new Serial(p9,p10); + pnub.huz.espconfig(); + */ + + gps_Serial = new Serial(p9,p10); //tx, rx Adafruit_GPS myGPS(gps_Serial); //object of Adafruit's GPS class Timer refresh_Timer; //Timer for updated GPS information const int refresh_Time = 2000; //refresh time in ms @@ -114,10 +120,9 @@ refresh_Timer.reset(); if (myGPS.fix) { publat = dms_convert(myGPS.latitude); - publat -= 0.003125; //Manual correction of GPS accuracy + publat -= 0.003148; //Manual correction of GPS accuracy publong = dms_convert(myGPS.longitude); - publong -= 0.007217; //Manual correction of GPS accuracy - pc.printf("DD Old Lat: %f, DD Old Long: %f \r\nDD New Lat %f, DD New Long %f\r\n",oldlat, oldlong, publat, publong); + publong -= 0.0077074; //Manual correction of GPS accuracy if (publat != oldlat || publong !=oldlong) { //pc.printf("DMS Lat: %f%c, DMS Long: %f%c\r\n",myGPS.latitude, myGPS.lat, myGPS.longitude, myGPS.lon); oldlat = publat;