I have a Photon connected to my GPS Mini NEO-7N Satellite Positioning Module. Ive connected to the 3.3v power supply, GND and GPS RX -> Photon TX and GPS TX -> Photon RX.
I had it working last night however it isn’t now. I’ve used the GPS module on my Arduino and it works so I know its functioning as well it working on my Photon last night, however no longer does it seem to. Here is my code:
#include <TinyGPS++.h>
#include "Particle.h"
void displayInfo();
const unsigned long PUBLISH_PERIOD = 120000;
TinyGPSPlus gps;
unsigned long lastPublish = 0;
void setup()
{
Serial.begin(9600);
Serial1.begin(9600);
}
void loop()
{
char buf[128];
while (Serial1.available() > 0) {
Particle.publish("DEBUG", "Serial is Available");
snprintf(buf, sizeof(buf), "Latitude: %f,Longitude: %f", gps.location.lat(), gps.location.lng());
Particle.publish("gps", buf);
delay(1000);
if (gps.encode(Serial1.read())) {
displayInfo();
}
}
}
void displayInfo()
{
char buf[128];
Particle.publish("DEBUG", "DisplayInfoFunc");
if (gps.location.isValid()) {
Particle.publish("DEBUG", "GPS VALID");
snprintf(buf, sizeof(buf), "Latitude: %f,Longitude: %f", gps.location.lat(), gps.location.lng());
Particle.publish("gps", "GPS DATA");
Particle.publish("gps", buf);
}
else {
Particle.publish("gps", "no location");
}
}