I’m doing a project which I need to sending the current location of mine from the GPS Module NEO-6M with arduino to Blynk Apps.
But this code cannot run the GPS location showing when the Blynk.run() are not in comment as well as sending email and notification from the Blynk Apps.
When I commented the line Blynk.run(), then the module will give me my current location in the Serial Monitor.
May I get some help on this? Thank you.
My code are attached as below.
When trying to merge two or more time and connection sensitive processes, you have to do it differently than the way “normal” Arduino code works (dump it all in the void loop() and pray it works )
Using BlynkTimer instead of blocking commands and processes like while() and the evil delay()… at least whenever possible, and when absolutely necessary, do so in small timed functions so as not to block Blynk.
There is also the possibility to temporarily disable the Blynk link long enough to get a location snapshot, then restore Blynk in-order to carry on as needed. This is not simple programming, but requires some experience and use of Blynk’s connection management commands…
Search this forum for keywords like GPS, NEO-6M, and so on… others have managed workarounds, so no need to start from square one again… assuming anyone here is willing/able to handhold you though it anyhow
I had tried the example given and I modify the code into the way I wanted it to be. But still the Blynk keep on shows me the Wifi shield is offline when it started to transmit the location.
#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <TinyGPS++.h>
#include <SPI.h>
#include <SoftwareSerial.h>
char auth[] = "acc51176f7a74de2b5eedd1072fd4fcb";
char ssid[] = "L";
char pass[] = "0123456789";
// or Software Serial on Uno, Nano...
SoftwareSerial EspSerial(2, 3); // RX, TX
SoftwareSerial serial_gps(9, 8); // RX = pin 10, TX = pin 11
TinyGPSPlus gps;
double latitude, longitude;
// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600
ESP8266 wifi(&EspSerial);
BlynkTimer timer;
void myTimerEvent()
{
serial_gps.listen();
while(serial_gps.available())
{
gps.encode(serial_gps.read());
}
if(gps.location.isUpdated())
{
latitude = gps.location.lat();
longitude = gps.location.lng();
String link = "http://www.google.com/maps/place/" + String(latitude, 6) + "," + String(longitude, 6) ;
Serial.print("Link Google Maps : ");
Serial.println(link);
Serial.print("Latitude : ");
Serial.println(latitude, 6);
Serial.print("Longitude : ");
Serial.println(longitude, 6);
Serial.println("");
Blynk.email("xxx@hotmail.com", "GPS Test 1", "GPS Test 2");
Blynk.notify("GPS Test test");
Blynk.virtualWrite(V5, latitude, 6);
}
}
void setup()
{
Serial.begin(9600);
EspSerial.begin(ESP8266_BAUD);
delay(10);
Blynk.begin(auth, wifi, ssid, pass);
Serial.println("GPS Startup");
// Setup a function to be called every second
timer.setInterval(1000L, myTimerEvent);
}
void loop()
{
Blynk.run();
timer.run(); // Initiates BlynkTimer
}