Published © GPL3+

NodeMCU ESP8266-12E Phone Locator Via Email Notification

Where did I leave my phone? Push a Button and an email will be sent giving you the Geolocation of your phone.

BeginnerFull instructions provided2 hours2,990
NodeMCU ESP8266-12E Phone Locator Via Email Notification

Things used in this project

Hardware components

NodeMCU ESP8266-12E
Solderless Breadboard Half Size
Solderless Breadboard Half Size
Pushbutton switch 12mm
SparkFun Pushbutton switch 12mm
Jumper wires (generic)
Jumper wires (generic)

Software apps and online services



Read more


Phone Locator/GeoLocation With a Push of the Button

Push a button and the ESP8266-12E sends an email to find the location of your phone. This is used in conjunction with Blynk.


Phone Locator/GeoLocation With a Push of the Button

Code that will send you an email to locate your phone in the event it is lost. The Code is definitely a little rough and probably could use some tweaking but it works. I push a button and then a message is sent stating the location of the phone. This can be expanded to other projects I am sure. My mind is already spinning with ideas. I am new to this stuff so apologize in advance for the "roughness" of it all.
  Download latest Blynk library here:
  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.
    Downloads, docs, tutorials: http://www.blynk.cc
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Follow us:                  http://www.fb.com/blynkapp
  Blynk library is licensed under MIT license
  This example code is in public domain.
  This example runs directly on NodeMCU.
  Note: This requires ESP8266 support package:
  Please be sure to select the right NodeMCU module
  in the Tools -> Board menu!
  For advanced settings please follow ESP examples :
   - ESP8266_Standalone_Manual_IP.ino
   - ESP8266_Standalone_SmartConfig.ino
   - ESP8266_Standalone_SSL.ino
  Change WiFi ssid, pass, and Blynk auth token to run :)
  Feel free to apply it to any other example. It's simple!

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Blynk.h>
#include <SevSeg.h>

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

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

String latitude;
String longitude;

BLYNK_WRITE(V0) { // Read Virtual Pin 0 for coordinates.
  GpsParam gps(param);

  Blynk.virtualWrite(V0, param[0].asString());
  Blynk.virtualWrite(V0, param[1].asString());

  latitude = param[0].asString(); // THIS IS A CHANGE FROM LAST CODE
  longitude = param[1].asString(); // THIS IS A CHANGE FROM LAST CODE

  // 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("Altitude: ");
  Serial.println(gps.getAltitude(), 2);

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

void emailOnButtonPress()
  // *** WARNING: You are limited to send ONLY ONE E-MAIL PER 15 SECONDS! ***

  /* Let's send an e-mail when you press the button connected to digital pin
     2 on your Arduino.  Connected to Digital Pin D4 on the ESP8266-12E */

  int isButtonPressed = !digitalRead(2); // Invert state, since button is "Active LOW"

  if (isButtonPressed) // You can write any condition to trigger e-mail sending
    Serial.println("Button is pressed. Locating Phone!"); // This can be seen in the Serial Monitor

    //String toSend is the string that will be sent as the emails body
    String toSend = "Phone Located! \n received co-ordinates \n";
    toSend += " LAT ";
    toSend += latitude;
    toSend += " LONG ";
    toSend += longitude;
    toSend += ". View location on Maps: ";
    toSend += "http://maps.google.com/?q=";
    toSend += latitude;
    toSend += ",";
    toSend += longitude;

    Blynk.email("email@email.com", "Subject: Phone Locator", toSend);

void setup()
  // Debug console

  Blynk.begin(auth, ssid, pass);

  // Send e-mail when your hardware gets connected to Blynk Server
  // Just put the recepient's "e-mail address", "Subject" and the "message body"

  Blynk.email("email@email.com", "PhoneLocator Activated");

  // Setting the button
  pinMode(2, INPUT_PULLUP);
  // Attach pin 2 interrupt to our handler
  attachInterrupt(digitalPinToInterrupt(2), emailOnButtonPress, CHANGE);

void loop()




1 project • 1 follower
IT Professional but just getting into Arduino and Raspberry Pi. BS in Information Technology. IT since 2000 or so. Officially since 2003.


Add projectSign up / Login