Not getting the location from my GPS project

I am using this sketch to get the location on map using blynk…
The components used are: Arduino Uno, Sim900A, Neo-6m…
But the problem is I am not getting the location…
Is there one who can help me??

#define BLYNK_PRINT Serial

#define TINY_GSM_MODEM_SIM900

// Default heartbeat interval for GSM is 60
// If you want override this value, uncomment and set this option:
//#define BLYNK_HEARTBEAT 30

#include <TinyGsmClient.h>
#include <BlynkSimpleSIM800.h>
#include "TinyGPS++.h"

int fixed = 0;
TinyGPSPlus gps;
WidgetMap myMap(V1);
char auth[] = "968e1928f92e450bad4125ba8d6f8db5";

// Your GPRS credentials
// Leave empty, if miSoftSerialing user or paSoftSerial
char apn[]  = "ufone.pinternet";
char user[] = "";
char pass[] = "";

//unsigned int move_index;         // moving index, to be used later
unsigned int move_index = 1;       // fixed location for now


#include <SoftwareSerial.h>
SoftwareSerial SerialAT(9, 10); // RX, TX
SoftwareSerial SoftSerial(3, 4);
BlynkTimer timer;

TinyGsm modem(SerialAT);

void setup()
{
  Serial.begin(9600);
  Serial.println("Initializing modem...");
  //modem.restart();
  SerialAT.begin(9600);
  Blynk.begin(auth, modem, apn, user, pass);
  SoftSerial.begin(9600);
  timer.setInterval(5000L, checkGPS); // every 5s check if GPS is connected, only really needs to be done once
}
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);

    myMap.clear();
    myMap.location(move_index, latitude, longitude, "GPS_Location");
  }

  Serial.println();
}

Welcome to the forum. Please read the welcome topic regarding procedures and formatting of all posted code (I have fixed your last post already).

Please don’t tack your issues onto others topics, particularly solved ones. Or “reopen” topics that are more than a few months old. On that note, I have moved your question to your own topic.

And finally, this forum is here to assist you in learning about Blynk… What we do not do is act as a code factory or mechanic shop… Aside from the basic direct pin control from the App, you need to understand enough about programming to carry the load for anything more intensive (like this) as we assist with any Blynk related issues and questions.

As for your issue…

What are you getting for data?

What have you tried so far?

Do you understand how your code works or is it someone elses code?

Have you gotten your GPS module to work without the Blynk interface?

.

I do understand this code because this code is written by me… I have tried almost everything with my gps and gsm like sending lat and long via sms etc etc.
In the case of blynk what Im trying to do is that my gsm module will provide the internet and my gps module will provide the lat and long and that will be shown to blynk app on map widget…
The problem Im getting is that gps and gsm dont work together…

1 Like

Usually, it helps to

  1. Make sure your GSM works without Blynk and you can read the GPS
  2. Try the bare minimum GSM code to establish communication with Blynk server
  3. Start reading GPS data and send it to Blynk map widget

Also, start indexing with ‘0’

1- My GSM can read the data from GPS without Blynk… I already tried this.
2- I also did this successfully.
3- I also did this using usb serial…

Have you tried double instead of float for lat lon, also did you try to set index to 0 ?

No i didn’t tried double and yes Right now Im trying to do with index 0

Also try sending some known static lat lon to map widget just to make sure that it works for you.

Not sure you need to clear map every time. Checking it right now.

yes i tried to send some known static lat lon to map widget and that works fine

Which means that your lat and lon are sent wrongly…

maybe
let me show you console.

so when the gsm connected the Blynk app comes online but shows the wrong location…
and when the gps started working the gsm goes off i guess and the blynk app also goes offline… this is the problem Im getting

Ios or Android?

Android

Try using timer instead of a while function

Is the lat and long that’s shown in Serial Monitor incorrect as they look ok to me?

Great… that is a refreshing change :smiley:

Thank you for this clarification… more informative than “not getting the location” as now it helps possibly narrow down your issue to SoftwareSerial… as you are using two (2) ports, there is a limitation with that…


The library has the following known limitations:

- If using multiple software serial ports, only one can receive data at a time.


So aside from changing you code around to use only one port at a time, can you try with something like a Arduino MEGA which has multiple hardware serial ports?

Or, as also provided in the above link…


If your project requires simultaneous data flows, see Paul Stoffregen’s AltSoftSerial library. AltSoftSerial overcomes a number of other issues with the core SoftwareSerial, but has it’s own limitations. Refer to the AltSoftSerial site for more information.


1 Like

@Gunner thankyou so much. Now i understand the main problem so i read the AltSoftSerial and NeoSWSerial but i could not get this issue solved.
So i need to use two ports at time because this is the need of my projects so kindly suggest me to use Arduino Uno or i should go with Arduino Mega to overcome this issue…
Thanks in Advance…