BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

GPS Trigger not working


#1

Hi Blynkers,

I’m using Blynk with my heating system and was therefor happy to see there is a GPS trigger functionality whitin Blynk. But somehow it won’t work correctly. I don’t quite understand why. I would expect i’m not the only one facing this issue. But somehow it seems, since I can’t find the same issues on this forum

What i’m using

  • I’m using WEMOS D1 Mini as a main unit in my setup. This unit will control other units when necessary. The main unit has a Virtual Pin to receive the triggers
  • Im using a Smartphone (tried three!) including a Samsung S8 with Android 7 to ensure the Smart Phone isnt the issue.
  • I have a range selected in de GPS Trigger. I tried to use Enter and Exit.
  • I’m using Blynk Cloud Server.

And using code:

BLYNK_WRITE(V62) 
{ 
  Serial.println("Received GPS Trigger State: "+param.asInt());
}

Issues i’m facing

  1. V62 is never triggered. If i’m in, out or whereever I am. However, all other blynk functions are working perfectly on the same device. So connection etc is ok.
  2. When a range is selected in the App, it will almost never show the same range again when I open the second or third time. It seem to zoom out, everytime I open the GPS Trigger.

Interesting to mention is that the ‘GPS Stream’ is working as espected in all these cases, so thats my workaround for now.

Can anyone advice in this? I quite wondered why I don’t see the same issues on this forum.

Thanks for your reply in advance!


#2

If by “same issue” you mean the generic “not working”… well that is ALL over this forum :stuck_out_tongue_winking_eye: Or perhaps it is not a common issue after all?

Assuming your code is correct… then the accuracy or even activation of the trigger is likely due to your particular phone. Possibly a permissions issue? And if you have multiple phones connecting to the project, then that might also add to the confusion? Hard to say with limited background info.

Can you post you entire code here (properly formatted for viewing of course :wink: ) thanks.

PS Have you looked at some apparently resolved issues and compared code/notes?


#3

Hi Gunner,

I searched the forum many times. I’ve seen the example you send. But in my case the ‘Vpin’ isn’t triggered at all.

It is also not an permission issue, since the GPS stream is working fine. The other phone i tried, are off.

The code, hopefully readable enough,Thanks for taking a look into it.

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


char auth[] = "***";
char ssid[] = "***";
char pass[] = "***";
char authThermostaat[] = "***";


BlynkTimer timer;
int numTimer;

WidgetTable table;
BLYNK_ATTACH_WIDGET (table, V55);
int rowIndex = 0;

WidgetBridge bridgeKachel(V97); //bridge to thermostaat

int program; //1=home soon, 2 =@home, 3=out 4=comfort 5=night
int kachelTempLow = 15; 
int kachelTempNormal = 20; 
int kachelTempComfort = 21; 
int gpsTrigger = 0; //enable gps trigger
bool userin = true; //home or out

BLYNK_CONNECTED() {
  bridgeKachel.setAuthToken(authThermostaat);
  Blynk.syncVirtual(V0);
}

BLYNK_WRITE(V51) // GPS trigger on/off ->> which is now own made GPS trigger on stream base
{
  gpsTrigger = param.asInt();
}
BLYNK_WRITE(V52) // receive gps //program; //1=home soon, 2 =@home, 3=out 4=comfort 5=night
{
  GpsParam gps (param);

  Serial.println("GPS: Lat/lon: ");
  Serial.println(gps.getLat(), 7);
  Serial.println(gps.getLon(), 7);

  if (gps.getLat() > 52.8470000 && gps.getLat() < 52.8530000 && gps.getLon() > 45.7360000 && gps.getLon() < 45.6500000)
  {
    table.addRow(rowIndex, "IN - Lat: " + (String)gps.getLat() + " - Lon: " + gps.getLon(), (String)hour() + ":" + (String)minute() + ":" + (String)second());
    rowIndex++;

    if (gpsTrigger == 1)
    {
      if (!userin)
      {
        userin = true;
        //if(program != 5)
        updateProgram(2);
      }
    }
  }
  else
  {
    table.addRow(rowIndex, "OUT - Lat: " + (String)gps.getLat() + " - Lon: " + gps.getLon(), (String)hour() + ":" + (String)minute() + ":" + (String)second());
    rowIndex++;

    if (gpsTrigger)
    {
      if (userin) {
        userin = false;
        updateProgram(3);
      }
    }
  }

}
BLYNK_WRITE(V62) // receive gps //program; //1=home soon, 2 =@home, 3=out 4=comfort 5=night
{
  Serial.println("Received GPS Trigger State: " + param.asInt());
}

BLYNK_WRITE(V0) //
{
  int rec = param.asInt();

  if (rec == 1) { //1 = 15 minuten thuis,
    if (program != rec)
    {
      updateProgram (rec);
      bridgeKachel.virtualWrite(V9, kachelTempNormal);
      numTimer = timer.setTimeout(10 * 60 * 1000L, setModeHome);
    }
  }
  if (rec == 2) { //2 = @home
    if (program != rec)
    {
      updateProgram (rec);
	  bridgeKachel.virtualWrite(V9, kachelTempNormal);
    }
  }
  if (rec == 3) { //, 3= out
    if (program != rec)
    {
      updateProgram (rec);
      bridgeKachel.virtualWrite(V9, kachelTempLow);
    }
  }
  if (rec == 4) { //4= comfortmode
    if (program != rec)
    {
      updateProgram (rec);    
	  bridgeKachel.virtualWrite(V9, kachelTempComfort);
    }
  }
  if (rec == 5) { //5= home night
    if (program != rec)
    {
      updateProgram (rec);
	  bridgeKachel.virtualWrite(V9, kachelTempLow);
    }
  }
  if (rec != 1 && program != rec) { //in case plans change
    timer.disable(numTimer);
  }
}

void setModeHome() {
  program = 2;
  bridgeKachel.virtualWrite(V9, kachelTempNormal);
}

void setup()
{
  Serial.begin(9600);
  Serial.println("SETUP");
  Blynk.begin(auth, ssid, pass);

  setSyncInterval(10 * 60);
  table.clear();
  Serial.println("Leaving setup > Going to loop");
}

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

void updateProgram(int rec) {
  program = rec;
  Blynk.virtualWrite(V0, program);
}



#4

Hii guyss,
Even im facing the same problem which mvkrt is facing, please send the solution asap.
PS:
By the way mvkrt does you got the solution of your problem??


#5

No not yet. I didnt try this recently however.


#6

Ok!!


#7

I solved this by using IFTTT app and then use the location trigger. You then can use webhook to trigger an action in Blynk.

Related example: