GPS and BLYNK not working together. Help..!

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();
  
}

Anyone??? plz help.

Avoid using blocking commands like this in the void loop();

http://help.blynk.cc/getting-started-library-auth-token-code-examples/blynk-basics/how-to-display-any-sensor-data-in-blynk-app

Can you plz tell me how can i alter while loop. Plus without " while (SoftSerial.available() > 0)" the code is not working.

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?

  1. Have u used Gps library other than TinyGPS and TinyGPS++.
  2. On a trial purpose i used while loop inside timer and it is working fine for a different program.

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

So… is this issue solved?

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. :slightly_smiling_face:

use the search “feature”, there are several topics for gps module on this forum. highly probable you can find the solution.

1 Like

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.

Should i change Uno and work on mega?

I tried about a lot of libraries. What to do?? I also had the same problem few days back.

@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:

it is highly probable it could work…

@wanek Are u suggesting me to use this? If u don’t mind, can u plz tell me the portion from the above code needed to be edited.

@wanek not working :disappointed_relieved:

Yeah me too… damn… im stuck this while serial avaible… no one can help?

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.

Pete.

3 Likes