This node was designed to map the range of Multitech Conduit gateways, It uses a Multitech mDot and Adafruit GPS breakout.

Dependencies:   MBed_Adafruit-GPS-Library libmDot-mbed5

Fork of mDot_LoRa_Connect_ABPA_DHT22_sleep by Brendan Kelly

Files at this revision

API Documentation at this revision

Comitter:
mcdocm1
Date:
Sat Nov 04 00:45:41 2017 +0000
Parent:
11:45465d7cff1f
Commit message:
modified base program to use GPS

Changed in this revision

DHT22.lib Show diff for this revision Revisions of this file
MBed_Adafruit-GPS-Library.lib 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 45465d7cff1f -r 99d45969ec41 DHT22.lib
--- a/DHT22.lib	Mon Aug 28 00:42:34 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://developer.mbed.org/users/Julepalme/code/DHT22/#7fd3ff04ae95
diff -r 45465d7cff1f -r 99d45969ec41 MBed_Adafruit-GPS-Library.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MBed_Adafruit-GPS-Library.lib	Sat Nov 04 00:45:41 2017 +0000
@@ -0,0 +1,1 @@
+http://os.mbed.com/users/mlee350/code/MBed_Adafruit-GPS-Library/#a23e3099bb0a
diff -r 45465d7cff1f -r 99d45969ec41 main.cpp
--- a/main.cpp	Mon Aug 28 00:42:34 2017 +0000
+++ b/main.cpp	Sat Nov 04 00:45:41 2017 +0000
@@ -14,16 +14,17 @@
 #include "MTSLog.h"
 #include "dot_util.h"
 #include "mbed.h"
-#include "DHT22.h"
+#include "MBed_Adafruit_GPS.h"
 #include <string>
 #include <vector>
 #include <algorithm>
 #include <sstream>
  
- //dht 22 pin (D6 on UDK 2)
- DHT22 dht22(PA_1);
- //analogue ldr pin (A0 on UDK 2)
- AnalogIn a0(PB_1);
+ 
+Serial * gps_Serial;
+Serial pc (USBTX, USBRX);
+
+
 
 // these options must match the settings on your Conduit
 /*
@@ -130,6 +131,54 @@
     }
     
     //this is where the magic happens
+     pc.baud(115200); //sets virtual COM serial communication to high rate; this is to allow more time to be spent on GPS retrieval
+    
+    gps_Serial = new Serial(p28,p27); //serial object for use w/ GPS
+    Adafruit_GPS myGPS(gps_Serial); //object of Adafruit's GPS class
+    char c; //when read via Adafruit_GPS::read(), the class returns single character stored here
+    Timer refresh_Timer; //sets up a timer for use in loop; how often do we print GPS info?
+    const int refresh_Time = 2000; //refresh time in ms
+    
+    myGPS.begin(9600);  //sets baud rate for GPS communication; note this may be changed via Adafruit_GPS::sendCommand(char *)
+                        //a list of GPS commands is available at http://www.adafruit.com/datasheets/PMTK_A08.pdf
+    
+    myGPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA); //these commands are defined in MBed_Adafruit_GPS.h; a link is provided there for command creation
+    myGPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);
+    myGPS.sendCommand(PGCMD_ANTENNA);
+    
+    pc.printf("Connection established at 115200 baud...\n");
+    
+    wait(1);
+    
+    refresh_Timer.start();  //starts the clock on the timer
+    
+    while(true){
+        c = myGPS.read();   //queries the GPS
+        
+        if (c) { pc.printf("%c", c); } //this line will echo the GPS data if not paused
+        
+        //check if we recieved a new message from GPS, if so, attempt to parse it,
+        if ( myGPS.newNMEAreceived() ) {
+            if ( !myGPS.parse(myGPS.lastNMEA()) ) {
+                continue;   
+            }    
+        }
+        
+        //check if enough time has passed to warrant printing GPS info to screen
+        //note if refresh_Time is too low or pc.baud is too low, GPS data may be lost during printing
+        if (refresh_Timer.read_ms() >= refresh_Time) {
+            refresh_Timer.reset();
+            pc.printf("Fix: %d\n", (int) myGPS.fix);
+            if (myGPS.fix) {
+                pc.printf("Location: %5.2f%c, %5.2f%c\n", myGPS.latitude, myGPS.lat, myGPS.longitude, myGPS.lon);
+                pc.printf("Altitude: %5.2f\n", myGPS.altitude);
+                pc.printf("Satellites: %d\n", myGPS.satellites);
+            }
+        }
+    }
+    
+    
+    
     while (true) {
     
         //wake up