Blynk application is on Android phone and all permission for Blynk are enabled.
GPS Trigger don’t work, first I tried example from Blynk widget info and it seems that is not working.
Second examples, I’ve search on forum and I see that I must to add one button as trigger for GPS. The example are below and is not working.
I want when the GPS is on (exit from area) to put LED to ON. Do you have some suggestion about where I wrong ?
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
BlynkTimer timer;
int lastConnectionAttempt = millis();
int connectionDelay = 10000;
int stareGPS;
int buttonGPS;
WidgetLED ledGPS(V5);
char auth[] = "";
char ssid[] = "";
char pass[] = "";
BLYNK_WRITE(V3)
{
buttonGPS = param.asInt();
}
BLYNK_WRITE(V4)
{
stareGPS = param.asInt();
if (stareGPS)
{
ledGPS.on();
Serial.println("GPS ON !");
}
else
{
ledGPS.off();
Serial.println("GPS Off!");
}
}
void modGPS()
{
if (buttonGPS == 1)
{
Blynk.virtualWrite(V4, 1);
Serial.println("Button ON !");
}
else
{
Blynk.virtualWrite(V4, 0);
Serial.println("Button OFF !");
}
}
void setup() {
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
timer.setInterval(5000L, modGPS);
}
void loop()
{
// check WiFi connection:
if (WiFi.status() != WL_CONNECTED)
{
// check delay:
if (millis() - lastConnectionAttempt >= connectionDelay)
{
lastConnectionAttempt = millis();
// attempt to connect to Wifi network:
if (pass && strlen(pass))
{
Serial.println("Lost Internet connections. Trying to reconnect...");
WiFi.begin((char*)ssid, (char*)pass);
Blynk.connect();
}
else
{
Serial.println("Lost Server connections. Trying to reconnect...");
WiFi.begin((char*)ssid, (char*)pass);
Blynk.connect();
}
}
}
else
{
Blynk.run();
timer.run();
}
}
GPS trigger was configured to “trigger when Enter” and the Output Pin is V4.
You suggest that I don’t need any button to trigger the GPS trigger. It trigger himself when Enter and update “my global variable stareGPS” ?
This is the link for the issues and code that I use to guide me.
The link you provided was for a scenario where someone wanted to disable the use of a button widget if someone was outside of a geofences area. That’s a very different scenario to the one you’ve described.
Have you defined your geofences area in the app? If not then it obviously won’t work.
Don’t you think that these two statements conflict with each other?
I don’t have declared because is not written anywhere about this, even in the widget info from Blynk. Is a new information for me, that I must declare geofence area.
Probably this must be specified in the widget info also for others new user that don’t know.
GPS trigger widget allows easily trigger events when you arrive to or leave from some destination. This widget will work in background and periodically will check your coordinates. In case your location is within/out required radius (selected on widget map) widget will send HIGH / LOW command to hardware. For example, let’s assume you have GPS Trigger widget assigned to pin V1 and option Trigger When Enter . In that case when you’ll arrive to destination point widget will trigger HIGH event.
BLYNK_WRITE(V1) {
int state = param.asInt();
if (state) {
//You enter destination
} else {
//You leave destination
}
}
More details on how GPS widget works you can read here.
GPS trigger widget works in background.
I’m not sure how you expect the app to know if the phone has left the area it you haven’t specified what that area is.
Hello friend, my code does not work either, could you share your code to know how I should do it? I need a led to turn off when I get to a place, my email is maelml1122@gmail.com
Hi, I’m new to this, could you tell me how I can delimit a barrier in the map widget?
I need to disable an LED when I leave a place but it has to be 5 meters away. Some basic example ???