Recently i am involved in a project where i have to use GPS module with that of Arduino uno.
The thing is i am unable to get the value as it automatically disconnects after some time.
Secondly i have gone through the examples given and i somewhat understand the concept of Blynk timer but unable to get the required result.
#include <TinyGPS++.h>
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
char auth[] = "aaaaaaa";
char SoftSerialid[] = "bbbbbbb";
char paSoftSerial[] = "cccccccccccc";
BlynkTimer timer;
// or Software Serial on Uno, Nano...
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // RX, TX
static const int RXPin = 8, TXPin = 9;
static const uint32_t GPSBaud = 9600;
// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600
ESP8266 wifi(&EspSerial);
unsigned int move_index = 1;
TinyGPSPlus gps;
SoftwareSerial SoftSerial(RXPin, TXPin);
void setup()
{
Serial.begin(9600);
EspSerial.begin(ESP8266_BAUD);
Blynk.begin(auth, wifi, SoftSerialid, paSoftSerial);
SoftSerial.begin(GPSBaud);
timer.setInterval(2000L, checkGPS);
}
void checkGPS(){
if (gps.charsProcessed() < 10)
{
Serial.println(F("No GPS detected: check wiring."));
// Blynk.virtualWrite(V4, "GPS ERROR"); // Value Display widget on V4 if GPS not detected
}
}
void loop()
{
while (SoftSerial.available() > 0)
{
// sketch displays information every time a new sentence is correctly encoded.
if (gps.encode(SoftSerial.read()))
displayInfo();
}
Blynk.run();
timer.run();
}
void displayInfo()
{
if (gps.location.isValid() )
{
float latitude = (gps.location.lat()); //Storing the Lat. and Lon.
float longitude = (gps.location.lng());
Serial.print("LAT: ");
Serial.println(latitude, 6); // float to x decimal places
Serial.print("LONG: ");
Serial.println(longitude, 6);
}
else
{
Serial.print(F("INVALID"));
}
Serial.println();
}
Sorry, I donât have any answers, I donât have any GPS modules to experiment with⌠I was just pointing out the area that you need to work on. You might have to find another way of polling data from your particular GPS sensor⌠perhaps a different library or something?
Yes, while I canât be certain (see Answer #1 above), having it in a timer might allow it to be uninterrupted once in awhile to allow the void loop() and Blynk.run(); a change to process.
You could also try adding in an extra Blynk.run(); into the while() loop
I tried this but still the same condition.
What else do u suggest?
Can you please refer me to someone who has worked with GPS module before. Its urgent. Btw thanks for all the support u are providing.
Not happening bro, what else can i try. Keeps sending GPS location for 9-10 seconds and gets disconnected after that. Any idea whatâs wrong with connecting with app??
We already determined that in above posts⌠the GPS/Library you are running requires constant âbabysittingâ and overrides all other background needs. stick a Blynk Run() in the While() loop and if that doesnât work, then find another library and/or GPS that can feed the data stream without TinyGPSâs apparent reliance on that constant serial scan.
@Nebula, @Abhinav_Thakur, i do not know what is your intended application, but if you do not require very ârealtimeâ positioning, eventually you can implement the solution discussed in this topic:
This is an old topic, and the OPâs original code is very strange because it uses two SoftwareSerial ports, and personally I canât follow which one is being used for what.
Many different solutions were suggested, and the OPâs responses where simple one line âit didnât workâ type of replies. No detail was provided about the exact code changes that were tried, or what results were observed, so itâs hard to know whether any of the suggestions came close to solving the problem.
We have no idea whether you are using the same GPS hardware, board and connections as the OP, and which of the suggestions above youâve tried.
My suggestion would be to try using an Arduino Mega, and forget all of the SoftwareSerial rubbish, then if you canât get it working start your own topic with FULL details of your setup, what results youâre getting, and what variations youâve tried.
Iâm locking this thread, as itâs not the proper place to help you diagnose your specific issue.