That is not my version, my version has simulation variables etc.
OK. compiling and not show anything on V7 V8 V10 and V5 map widget
/* BlynkifyGPSv2.ino for https://community.blynk.cc/t/arduino-or-nodemcu-gps-tracking-system-on-map-widget/15739
Sketch for physical GPS device connected to a decent ESP
In map widget set SHOW MY LOCATION to NO unless you also want Smartphone actual location in addition to GPS device + ESP
*/
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 9600;
TinyGPSPlus gps; // The TinyGPS++ object
SoftwareSerial ss(RXPin, TXPin); // The serial connection to the GPS device
BlynkTimer timer;
char auth[] = "6075f93a98734b3abddb3c3ba6babf08";
char ssid[] = "MikroTik Home";
char pass[] = "";
char server[] = "192.168.1.104";
//unsigned int move_index; // moving index, to be used later
unsigned int move_index = 1; // fixed location for now
bool simulation = false; // set to true for simulation mode, else false. If IranHack is true this must be false
// simulation location is in Egypt
bool IranHack = false; // set to true if GPS is faulty, else false. If simulation is true this must be false
WidgetMap myMap(V5);
void setup()
{
Serial.begin(115200);
Serial.println();
ss.begin(GPSBaud);
Blynk.begin(auth, ssid, pass, server);
// disable GPS device checking for now
//timer.setInterval(5000L, checkGPS); // every 5s check if GPS is connected, only really needs to be done once
timer.setInterval(30000L, readGPS); // read GPS data every 30s
readGPS(); // read GPS data on each reboot after connection to Blynk server
}
void readGPS(){
long startTime = millis();
long counter = 0;
Serial.print("Started reading GPS data at ");
Serial.println(startTime);
if(simulation == true || IranHack == true)
{
long loopmax = 100L; // max 2,147,483,647 or double this if usigned
while (counter < loopmax)
{
counter++;
Serial.print(".");
delay(20); // pause 10ms (1s total) 20ms (2s total)
}
Serial.println();
//counter = 0; // not required as counter is redefined each time readGPS() is called
displayInfo();
}
else
{
while (ss.available() > 0) // sketch displays information every time a new sentence is correctly encoded.
if (gps.encode(ss.read()))
displayInfo();
}
Serial.print("Finished reading GPS data at ");
Serial.print(millis());
Serial.print(" and it took ");
Serial.print(millis() - startTime);
Serial.println("ms.");
Serial.println("-----------------------------------------------------------");
Serial.println();
}
void checkGPS(){
if (gps.charsProcessed() < 10)
{
Serial.println(F("No GPS detected: check wiring."));
Blynk.virtualWrite(V10, "GPS ERROR"); // Value Display widget set as PUSH frequency on V10
Blynk.virtualWrite(V7, "--------"); // Value Display widget set as PUSH frequency on V7 LATITUDE
Blynk.virtualWrite(V8, "--------"); // Value Display widget set as PUSH frequency on V8 LONGITUDE
}
}
void loop()
{
Blynk.run();
timer.run();
}
void displayInfo()
{
if (gps.location.isValid() || simulation == true || IranHack == true)
{
//move_index++; // moving index, maybe use later
Blynk.virtualWrite(V10, "GPS OK");
float latitude = (gps.location.lat()); // removed , 6 as it can't be used for creating the float
float longitude = (gps.location.lng()); // removed , 6 as it can't be used for creating the float
if(latitude == 0 && longitude == 0 ) // checking to see if the 2 floats variables are correct
{
Blynk.virtualWrite(V7, "--------");
Blynk.virtualWrite(V8, "--------");
Blynk.virtualWrite(V10, "0,0");
}
if(simulation == true) // location in Egypt
{
latitude = 30.000123; // also used for debugging
longitude = 30.000987; // also used for debugging
}
if(IranHack == true)
{
latitude = 32.644824;
longitude = 51.681746;
}
Serial.print("LAT: ");
Serial.println(latitude, 6); // float to x decimal places
Serial.print("LONG: ");
Serial.println(longitude, 6);
Blynk.virtualWrite(V7, String(latitude, 6));
Blynk.virtualWrite(V8, String(longitude, 6));
myMap.location(move_index, latitude, longitude, "GPS_Location");
}
else
{
Serial.print(F("INVALID"));
Blynk.virtualWrite(V10, "GPS INVALID");
Blynk.virtualWrite(V7, "--------");
Blynk.virtualWrite(V8, "--------");
}
Serial.println();
}
SM is what is important, please provide.
whats SM ?
Serial Monitor
[263] Connecting to MikroTik Home
[1292] Connected to WiFi
[1293] IP: 10.5.50.234
[1295]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ \/ '_/
/____/_/\_, /_//_/_/\_\
/___/ v0.4.8 on NodeMCU
[5001] Connecting to 192.168.1.104:8442
[5057] Ready (ping: 3ms).
Started reading GPS data at 5079
Finished reading GPS data at 5082 and it took 4ms.
-----------------------------------------------------------
My SM in simulation mode with reading set at 5s intervals and 4800ms delay to âreadâ GPS data.
All works fine, no disconnects and no ESP resets.
Started reading GPS data at 246356
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 251162 and it took 4806ms.
-----------------------------------------------------------
Started reading GPS data at 251356
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 256159 and it took 4803ms.
-----------------------------------------------------------
Started reading GPS data at 256356
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 261162 and it took 4806ms.
-----------------------------------------------------------
which sketch you use ?
The last sketch you posted but with the following changes:
bool simulation = true;
Only set this as true for test purposes, change back to false afterwards
In setup() change the 30000L to 5000L and this readGPS()
void readGPS(){
ESP.wdtFeed(); // feed the ESP WDT, not needed in simulation mode at 4800ms delay but included just in case it's needed
long startTime = millis();
long counter = 0;
Serial.print("Started reading GPS data at ");
Serial.println(startTime);
if(simulation == true || IranHack == true)
{
//long loopmax = 100L; // max 2,147,483,647 or double this if usigned
long loopmax = 1L; // doesn't need to be a long variable
while (counter < loopmax)
{
counter++;
Serial.print(".");
delay(4800); // e.g. pause, 4800 seems ok
}
Serial.println();
//counter = 0; // not required as counter is redefined each time readGPS() is called
displayInfo();
}
else
{
while (ss.available() > 0) // sketch displays information every time a new sentence is correctly encoded.
if (gps.encode(ss.read()))
displayInfo();
}
Serial.print("Finished reading GPS data at ");
Serial.print(millis());
Serial.print(" and it took ");
Serial.print(millis() - startTime);
Serial.println("ms.");
Serial.println("-----------------------------------------------------------");
Serial.println();
}
Post your SM with the changes above and later we can try to work out why the sketch is not pulling down your actual GPS data.
[263] Connecting to MikroTik Home
[1288] Connected to WiFi
[1290] IP: 10.5.50.234
[1291]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ \/ '_/
/____/_/\_, /_//_/_/\_\
/___/ v0.4.8 on NodeMCU
[5001] Connecting to 192.168.1.104:8442
[5012] Ready (ping: 6ms).
Started reading GPS data at 5015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 9861 and it took 4846ms.
-----------------------------------------------------------
Let SM run for a little longer and paste a bigger section. I just want to see time closer to 4800ms.
[263] Connecting to MikroTik Home
[1288] Connected to WiFi
[1290] IP: 10.5.50.234
[1291]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ \/ '_/
/____/_/\_, /_//_/_/\_\
/___/ v0.4.8 on NodeMCU
[5001] Connecting to 192.168.1.104:8442
[5012] Ready (ping: 6ms).
Started reading GPS data at 5015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 9861 and it took 4846ms.
-----------------------------------------------------------
Started reading GPS data at 10015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 14832 and it took 4817ms.
-----------------------------------------------------------
Started reading GPS data at 15015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 19831 and it took 4816ms.
-----------------------------------------------------------
Started reading GPS data at 20015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 24862 and it took 4847ms.
-----------------------------------------------------------
Started reading GPS data at 25015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 29830 and it took 4815ms.
-----------------------------------------------------------
Started reading GPS data at 30015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 34860 and it took 4845ms.
-----------------------------------------------------------
Started reading GPS data at 35015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 39829 and it took 4814ms.
-----------------------------------------------------------
Started reading GPS data at 40015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 44860 and it took 4845ms.
-----------------------------------------------------------
Started reading GPS data at 45015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 49829 and it took 4815ms.
-----------------------------------------------------------
Started reading GPS data at 50015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 54861 and it took 4846ms.
-----------------------------------------------------------
Started reading GPS data at 55015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 59829 and it took 4814ms.
-----------------------------------------------------------
Started reading GPS data at 60015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 64862 and it took 4847ms.
-----------------------------------------------------------
Started reading GPS data at 65015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 69839 and it took 4824ms.
-----------------------------------------------------------
Started reading GPS data at 70015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 74860 and it took 4845ms.
-----------------------------------------------------------
Started reading GPS data at 75015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 79829 and it took 4814ms.
-----------------------------------------------------------
Started reading GPS data at 80015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 84861 and it took 4846ms.
-----------------------------------------------------------
Started reading GPS data at 85015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 89829 and it took 4814ms.
-----------------------------------------------------------
Started reading GPS data at 90015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 94861 and it took 4846ms.
-----------------------------------------------------------
Started reading GPS data at 95015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 99831 and it took 4816ms.
-----------------------------------------------------------
Started reading GPS data at 100015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 104860 and it took 4845ms.
-----------------------------------------------------------
Started reading GPS data at 105015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 109829 and it took 4814ms.
-----------------------------------------------------------
Started reading GPS data at 110015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 114870 and it took 4855ms.
-----------------------------------------------------------
Started reading GPS data at 115015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 119829 and it took 4814ms.
-----------------------------------------------------------
Started reading GPS data at 120015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 124869 and it took 4854ms.
-----------------------------------------------------------
Started reading GPS data at 125015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 129829 and it took 4815ms.
-----------------------------------------------------------
Started reading GPS data at 130015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 134869 and it took 4854ms.
-----------------------------------------------------------
Started reading GPS data at 135015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 139829 and it took 4814ms.
-----------------------------------------------------------
Started reading GPS data at 140015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 144859 and it took 4844ms.
-----------------------------------------------------------
Started reading GPS data at 145015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 149830 and it took 4815ms.
-----------------------------------------------------------
Started reading GPS data at 150015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 154869 and it took 4854ms.
-----------------------------------------------------------
Started reading GPS data at 155015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 159829 and it took 4814ms.
-----------------------------------------------------------
Started reading GPS data at 160015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 164869 and it took 4854ms.
-----------------------------------------------------------
Started reading GPS data at 165015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 169826 and it took 4811ms.
-----------------------------------------------------------
Started reading GPS data at 170015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 174859 and it took 4844ms.
-----------------------------------------------------------
Started reading GPS data at 175015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 179829 and it took 4814ms.
-----------------------------------------------------------
Started reading GPS data at 180015
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 184869 and it took 4854ms.
Itâs noticeable that every 10s you have an extra 40ms more processing time than I have.
This is either something to do with the Blynk 10s hearbeat or the fact you actually have a GPS device connected and I donât.
If itâs the former I am surprised as you are using a local server and I am using a cloud server i.e. my processing time should be longer but it can vary from system to system.
OK. now itâs from Blynk Cloud
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ \/ '_/
/____/_/\_, /_//_/_/\_\
/___/ v0.4.8 on NodeMCU
[5001] Connecting to blynk-cloud.com:8442
[5658] Ready (ping: 0ms).
Started reading GPS data at 5972
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 13748 and it took 7776ms.
-----------------------------------------------------------
Started reading GPS data at 13748
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 21530 and it took 7782ms.
-----------------------------------------------------------
Started reading GPS data at 21968
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 29722 and it took 7754ms.
-----------------------------------------------------------
Started reading GPS data at 29723
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 37300 and it took 7577ms.
-----------------------------------------------------------
Started reading GPS data at 37300
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 45108 and it took 7809ms.
-----------------------------------------------------------
Started reading GPS data at 45492
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 53479 and it took 7987ms.
-----------------------------------------------------------
Started reading GPS data at 53480
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 60980 and it took 7501ms.
-----------------------------------------------------------
Started reading GPS data at 60985
.
LAT: 30.000122
LONG: 30.000986
Finished reading GPS data at 68634 and it took 7649ms.
-----------------------------------------------------------
Did you change the 4800ms?
Strange that yours now takes 7500ms.
My cloud server is not Blynkâs server, itâs a âlocalâ server thousands of miles away.
What Blynk server are you connecting to from Iran i.e. what does ping blynk-cloud.com show as the IP?
I dont change 4800
Pinging blynk-cloud.com [139.59.206.133] with 32 bytes of data:
Reply from 139.59.206.133: bytes=32 time=159ms TTL=54
Reply from 139.59.206.133: bytes=32 time=149ms TTL=54
Reply from 139.59.206.133: bytes=32 time=151ms TTL=54
Reply from 139.59.206.133: bytes=32 time=145ms TTL=54
Looks like that is in Germany. Probably same distance from me to my cloud server as Iran to Germany. Perhaps poor routing from Iran but I guess you are the Network Engineer
the routing problem is from ISP.
@ErfanDL Nice thing about a physical GPS device is that you get a free clock thrown in too.
QR code for Android / iOS plus Android Smartphone url are:
http://tinyurl.com/yd4dqal8
Change email address from user@home.com to your actual email address.
Change the timezone, unless you are in Cyprus (or GMT + 3). Project uses GMT at present.
Notification widget should be left as ON, 1min, DEFAULT RINGTONE and HIGH.
Project will send you a PUSH message with the initial Satellite fix and further PUSH messages if the fix is lost for more than 15s.
Some of these PUSH messages are actually to help me debug a few issues. Please keep a record of the âFirst fixâ and âLost fixâ times.
You will have a fixed red LED until you have the first satellite fix and the green LED will flash as long as you are connected to the server.
@Dmitriy couple of questions:
- Is the 15s minimum wait period between messages applicable to any type of message (PUSH / EMAIL) or do they have independent 15s wait periods? Think I might have offended Google
- Please confirm the map doesnât actually track i.e. we have keep clicking the Google âlollipopsâ to see where we are in the world.
Send me a PM if you want the associated bin file.
Independent.
Sorry, didnât get it.