Permalink
Browse files

gps sketch adapted to D-pins

  • Loading branch information...
Marwe committed Apr 23, 2016
1 parent 586ce82 commit 58ff3fc409eb353f7f1e25051d55f153be9601b7
Showing with 39 additions and 4 deletions.
  1. +2 −0 esp8266-arduino/gps/README.md
  2. +5 −1 esp8266-arduino/gps/gps.ino
  3. +32 −3 esp8266-arduino/gps/gpsfunctions.h
@@ -4,3 +4,5 @@ http://arduiniana.org/libraries/tinygpsplus/
ESP Software Serial (should be built in)
https://github.com/plerup/espsoftwareserial
do not connect GPS to 3v3 of esp board, it might not be able to provide enough power, use a DC-DC voltage regulator
@@ -4,12 +4,16 @@
// TODO implement
// #define PUSHTO_MQTT
// GPIO PINSs <-> nodemcu PINs (Dx) mapping
// 0 1 2 3 4 5 6 7 8 9 10 11 12
int D[13]={16, 5, 4, 0, 2, 14, 12, 13, 15, 3, 1, 9, 10};
#define GPS_ACTIVE
#ifdef GPS_ACTIVE
/* config, move later to sensorconfig.h */
// wiring: GPS6MV2-RX->GPSRXPin
static const int GPSRXPin = 5, GPSTXPin = 0;
static const int GPSRXPin = D[7];
static const int GPSTXPin = D[8];
static const uint32_t GPSBaud = 9600;
unsigned long gpsmaxtime_ms=2100;
@@ -42,6 +42,11 @@ Serial.print(gps.location.lng(),6);
Serial.print("\t");
Serial.println(gps.altitude.meters());
#endif
#ifdef PUSHTO_MQTT
mqtt_publish_subtopic("GPS/lat",gps.location.lat());
mqtt_publish_subtopic("GPS/lon",gps.location.lng());
mqtt_publish_subtopic("GPS/height",gps.altitude.meters());
#endif
}
bool push_gps_datetime(){
@@ -51,24 +56,40 @@ bool push_gps_datetime(){
if (!d.isValid()){
return false;
}else{
sprintf(sz, "DateTimeAge\t%02d-%02d-%02d", d.year(), d.month(), d.day());
sprintf(sz, "%02d-%02d-%02d", d.year(), d.month(), d.day());
#ifdef PUSHTO_SERIAL
Serial.print("DateTimeAge\t");
Serial.print(sz);
#endif
#ifdef PUSHTO_MQTT
mqtt_publish_subtopic("GPS/date",gps.hdop.value());
#endif
}
if (!t.isValid()){
Serial.println("");
return false;
}else{
sprintf(sz, " %02d:%02d:%02d\t%02d", t.hour(), t.minute(), t.second(),gps.location.age());
sprintf(sz, "%02d:%02d:%02d", t.hour(), t.minute(), t.second(),gps.location.age());
#ifdef PUSHTO_SERIAL
Serial.print(" ");
Serial.println(sz);
#endif
#ifdef PUSHTO_MQTT
mqtt_publish_subtopic("GPS/time",sz);
#endif
sprintf(sz, "%02d", gps.location.age());
#ifdef PUSHTO_SERIAL
Serial.print("\t");
Serial.println(sz);
#endif
#ifdef PUSHTO_MQTT
mqtt_publish_subtopic("GPS/locationage",sz);
#endif
}
return true;
}
bool push_gps_info(){
bool retval = ( gps.hdop.isValid() & gps.satellites.isValid() );
bool retval = (gps.hdop.isValid() & gps.satellites.isValid());
#ifdef PUSHTO_SERIAL
Serial.print("HdopSat\t");
if(gps.hdop.isValid()){
@@ -80,6 +101,14 @@ bool push_gps_info(){
}
Serial.println("");
#endif
#ifdef PUSHTO_MQTT
if(gps.hdop.isValid()){
mqtt_publish_subtopic("GPS/HDOP",gps.hdop.value());
}
if(gps.satellites.isValid()){
mqtt_publish_subtopic("GPS/satellites",gps.satellites.value());
}
#endif
return retval;
}
bool gps_read(){

0 comments on commit 58ff3fc

Please sign in to comment.