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…
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
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.
@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…