Can't get Gps stream location

Hi all…i am creating project in which i am using blynk Gps stream widget to get my mobile location on Wemos d1 board when i press 1 on serial monitor… but it kinda not work the way i want…my longitude and lattitude variables always stays zero…i have provided the code below(i know my coding style is way bad and i am trying to improve…yes i am student :slight_smile: …and newbie here)…and sorry if my english is bad too…



#define BLYNK_PRINT Serial
#define BLYNK_MAX_SENDBYTES 200


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>


char auth[] = "put your own";
char userEmail[] = "put your own";


char ssid[] = "put your own";
char pass[] = "put your own";

float latitude = 0.00;
float longitude= 0.00;
double altitude;
double speed;

byte input_char=0;
long user_input=0;


bool proDebug = 1; // TODO - set to 0 if not debugging
int i=0;
int online;

BLYNK_WRITE(V0) // read virtual pin 0 for co-ordinates
{
  latitude = param[0].asDouble();
  longitude = param[1].asDouble();
  altitude = param[2].asDouble();
  speed = param[3].asDouble();
}

void getLocation()
{
  if(i == 9)
    { 
      Serial.println("Device unreachable");
      i=0;
      online = 0;
    }
   
  if(i == 0)
  {
       Serial.println();
       Serial.println("press 1 to get phone Location:");
       Serial.println();
       
      while(Serial.available() == 0) {Blynk.run();}
      
      while(Serial.available())
         {
          input_char = Serial.read() - 48;
           user_input = user_input * 10 + input_char;
          Blynk.run();
         }
      if(user_input == 1)
       {
        online = 1;
      
       
      }
      else
      {
        Serial.println("wrong entry.");
        Serial.println();
      }
  }
  
    if(online == 1)
    {
     
      
      if(latitude != 0.00 && longitude != 0.00) // if co-ordinates are valid
      {
        //String toSend is the string that will be sent as the emails body
        String toSend = "Phone Located! \n received co-ordinates \n LAT ";
        toSend += String(latitude, 8); 
        toSend += " LNG ";
        toSend += String(longitude, 8);
        toSend += ". View location on: ";
        toSend += "www.google.com/maps/?q=";
        toSend += String(latitude, 8);
        toSend += ",";
        toSend += String(longitude, 8);
        delay(500);

        if(proDebug)
        {
          Serial.println("Phone geolocation found");
          Serial.println("Sending Email...");
          Serial.println(toSend);
        }
      
        Blynk.email(userEmail, "PhoneLocator | Notification", toSend); // send email

        if(proDebug)
        {
          Serial.println("Success");
          Serial.println("Email Sent");
          Serial.println("Restarting Protocol");
          Serial.println("");
        } 
      
        delay(500);

        i=0;
        online = 0;
        latitude = 0.00;
        longitude= 0.00;
      }
      else
      {
          if(i==0 || i == 8)
              {
                
                Serial.println("Geolocation not Received");
                Serial.println("server responded with");
                Serial.println(latitude, 8);
                Serial.println(longitude, 8);
                Serial.println("");
                Serial.println("checking again.");
                Serial.println("");
              }
            i++;
       }
    //while end
  } 
    
  
  
  
input_char=0;
user_input=0;

}

 
void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);


  delay(1000);
  

  if(proDebug)
  {
    while(!Serial) {};
    delay(1000);
    Serial.println("Tracker is online");
    Serial.println("");
  
    delay(500);
  }
  
}

void loop()
{
  Blynk.run();
  getLocation();
  
}

This delay is totally unnecessary.

First you declare them as Float, then process them as Double… Try using float for everything.

Or take a look at the GPS Streaming example

https://examples.blynk.cc/?board=ESP8266&shield=ESP8266%20WiFi&example=Widgets%2FGPS_Stream

thanks for reply. :slight_smile:
so for double check i followed that example sketch …and found that

BLYNK_WRITE(V0)

is not running because my serial monitor stays blank after its connected with blynk server…

code:

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "";
char pass[] = "";

BLYNK_WRITE(V0) {
 GpsParam gps(param);

 // Print 6 decimal places for Lat, Lon
 Serial.print("Lat: ");
 Serial.println(gps.getLat(), 7);

 Serial.print("Lon: ");
 Serial.println(gps.getLon(), 7);

 // Print 2 decimal places for Alt, Speed
 Serial.print("Altitute: ");
 Serial.println(gps.getAltitude(), 2);

 Serial.print("Speed: ");
 Serial.println(gps.getSpeed(), 2);

 Serial.println();
}

void setup()
{
 // Debug console
 Serial.begin(9600);

 Blynk.begin(auth, ssid, pass);
 // You can also specify server:
 //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
 //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
}

void loop()
{
 Blynk.run();
}

ok i just found there is no error in code(realy sorry for taking ur time)…its just my internet but…its still a problem for me cuz i wont be having my home wifi in college.
Actually when i use my home internet…every thing works fine…but when i use my mobile data and hotspot(for wemos d1)…i get no reponse from VirtualWrite function. but its says i am connected to blynk server…
i tried mine and my dads mobile data…both doesn’t work.

It sounds like your mobile provider(s) are blocking some people f communication protocols needed for device to server to device communication.

Pete.