Blynk NEO6M GPS Locator

Hi friends. here for those who want to locating the GPS position with Blynk from the hardware side.

Materials:
1x ESP8266 NodeMCU
1x NEO6M GPS module with antenna
3X male jumper wires
a usb cable to programming the NodeMCU
a Breadboard to placing the parts on it.

Wiring:

the Project:

Setting up Widgets:

MAP Widget setting

LCD Widget setting

######################################################################################

The Arduino Sketch:

/* ##############  Libraries  ############## */
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include <SimpleTimer.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

/* ##############  Blynk Connection Setup  ############## */
char auth[] = "your blynk token"; // Blynk authentication key
char ssid[] = "your wifi ssid"; // Name of your WiFi SSID
char pass[] = "your wifi password"; // WiFi Password
char server[] = "your local server ip address";
/*  virtual pins:
  # V0: MAP
  # V1: LCD screen in Advanced
*/
// Blynk LCD and map widgets
WidgetLCD lcd(V1);
WidgetMap myMap(V0);
String GPSLabel = "BLYNK"; //Labeling location on MAP

/* ##############  Timer  ############## */
SimpleTimer timer;

/* ##############  GPS PIN Setup  ############## */
static const int RXPin = 4, TXPin = 5;   // GPIO 4=D2(conneect Tx of GPS) and GPIO 5=D1(Connect Rx of GPS)
static const uint32_t GPSBaud = 9600; //if Baud rate 9600 didn't work in your case then use 4800

TinyGPSPlus gps;                             // The TinyGPS++ object
SoftwareSerial ss(RXPin, TXPin);     // Serial connection to the GPS module

/* ############################
   Starting Program
   ############################ */

void setup() {
  Serial.begin(9600);       // serial connection for debugging
  ss.begin(GPSBaud);
  //Connect Blynk
  Blynk.begin(auth, ssid, pass, server, 8080);
  Serial.println("Activating GPS");
  timer.setInterval(1000L, periodicUpdate);
  timer.setInterval(60*1000, reconnectBlynk);
}

//Show GPS lat and lng on LCD
void periodicUpdate() {
  String line1, line2;
  //LCD
  lcd.clear();
  if (gps.location.isValid() && (gps.location.age() < 3000)) {
    //position current
    line1 = String("lat: ") + String(gps.location.lat(), 6);
    line2 = String("lng: ") + String(gps.location.lng(), 6);
    lcd.print(0, 0, line1);
    lcd.print(0, 1, line2);
    //update location on map
    myMap.location(2, gps.location.lat(), gps.location.lng(), GPSLabel);
  } else {
    //position is lost
    lcd.print(0, 0, "GPS lost");
  }
}

void updateGPS() {
  //read data from GPS module
  while (ss.available() > 0) {
    gps.encode(ss.read());
  }
}

void reconnectBlynk() {
  if (!Blynk.connected()) {
    Serial.println("Lost connection");
    if(Blynk.connect()) Serial.println("Reconnected");
    else Serial.println("Not reconnected");
  }
}

void loop() {
  timer.run();
  if(Blynk.connected()) { Blynk.run(); }
  updateGPS();
}
6 Likes

Your local host ip address means?

If you are referring to this, and you don’t know what it means, then you do not have a Local Server :stuck_out_tongue: Just use blynk-cloud.com instead.

We also recommend you spend some time reading this forum, the documentation and trying much simpler Blynk examples in order to understand the bare basics.

1 Like