Hello everyone,
I’m new user of this forum and beginer in programming. Please be indulgence. I try to build home weather station project using SparkFun Photon RedBoard + SparkFun Weather Shield + GP-735 + BLYNK. I connected everything besides GP-735. I think I have problem to get data from this GPS module. I know that SerialSoftware.h from Arduino don’t work in this case. I tried to use ParticleSoftSerial library, but I have problem to implement this to my program. This is the piece of orginal code of GPS module.
#include <SoftwareSerial.h> //Needed for GPS
static const int RXPin = 5, TXPin = 4; //GPS is attached to pin 4(TX from GPS) and pin 5(RX into GPS)
SoftwareSerial ss(RXPin, TXPin);
const byte GPS_PWRCTL = 6; //Pulling this pin low puts GPS to sleep but maintains RTC and RAM
void setup()
{
ss.begin(9600); //Begin listening to GPS over software serial at 9600. This should be the default baud of the module.
pinMode(GPS_PWRCTL, OUTPUT);
digitalWrite(GPS_PWRCTL, HIGH); //Pulling this pin low puts GPS to sleep but maintains RTC and RAM
}
void loop()
{
Serial.print(",lat=");
Serial.print(gps.location.lat(), 6);
Serial.print(",lng=");
Serial.print(gps.location.lng(), 6);
Serial.print(",altitude=");
Serial.print(gps.altitude.meters());
Serial.print(",sats=");
Serial.print(gps.satellites.value());
char sz[32];
Serial.print(",date=");
sprintf(sz, "%02d/%02d/%02d", gps.date.month(), gps.date.day(), gps.date.year());
Serial.print(sz);
Serial.print(",time=");
sprintf(sz, "%02d:%02d:%02d", gps.time.hour(), gps.time.minute(), gps.time.second());
Serial.print(sz);
//smartdelay(800); //Wait 1 second, and gather GPS data
}
//While we delay for a given amount of time, gather GPS data
static void smartdelay(unsigned long ms)
{
unsigned long start = millis();
do
{
while (ss.available())
gps.encode(ss.read());
} while (millis() - start < ms);
}
I tried to convert this code to be compatible with new library. I looked the example of ScruffR code and wrote something like this. Please tell me what to convert to get correct data from this GPS module.
#include <ParticleSoftSerial.h>
#define GPS data
// GPS is attached to pin 4(TX from GPS) and pin 5(RX into GPS)
static const int RXPin = 5, TXPin = 4;
ParticleSoftSerial data(RXPin, TXPin);
const byte GPS_PWRCTL = 6; //Pulling this pin low puts GPS to sleep but maintains RTC and RAM
void setup()
{
GPS.begin(9600); //Begin listening to GPS over software serial at 9600. This should be the default baud of the module.
pinMode(GPS_PWRCTL, OUTPUT);
digitalWrite(GPS_PWRCTL, HIGH); //Pulling this pin low puts GPS to sleep but maintains RTC and RAM
}
void loop()
{
Serial.print(",lat=");
Serial.print(gps.location.lat(), 6);
Serial.print(",lng=");
Serial.print(gps.location.lng(), 6);
Serial.print(",altitude=");
Serial.print(gps.altitude.meters());
Serial.print(",sats=");
Serial.print(gps.satellites.value());
char sz[32];
Serial.print(",date=");
sprintf(sz, "%02d/%02d/%02d", gps.date.month(), gps.date.day(), gps.date.year());
Serial.print(sz);
Serial.print(",time=");
sprintf(sz, "%02d:%02d:%02d", gps.time.hour(), gps.time.minute(), gps.time.second());
Serial.print(sz);
//smartdelay(800); //Wait 1 second, and gather GPS data
}
//While we delay for a given amount of time, gather GPS data
static void smartdelay(unsigned long ms)
{
unsigned long start = millis();
do
{
while (GPS.available())
gps.encode(GPS.read());
} while (millis() - start < ms);
}
Thank you in advance for your help.