Project tutorial

PhoneLocator © GPL3+

Simply click a button to receive your phone's geolocation.

  • 3,932 views
  • 1 comment
  • 18 respects

Components and supplies

Apps and online services

About this project

Overview

Have you ever forgot your phone in your friend's house? Are you afraid of an unpleasant person taking your phone? I am sure that everyone was confronted with loosing or forgetting their phone. PhoneLocator aims to locate your phone (hint in the name) and send you its geolocation coordinates via email so you can recover your precious device. Thanks to Blynk, all you have to do is press a button. Note that you will need a Blynk account to operate this project, a guide to creating an account is placed under constructing the project below.

Functionality

The project works really simply, whenever the user presses a button, The Arduino Yún will read the phone's geolocation and send the client an email. And to make the project more professional, you can think that the email is sent to you from the Blynk app on your phone, smart robber. Here is an image illustrating the project.

This image illustrates the project's code overview.

  • if(button is pressed) will check if the button connected to pin 2 is pressed
  • getLocation will request the phone's location from Blynk
  • Process Data will process the received co-ordinates into the body of the email
  • Send email will send the email to the user

A response from the Arduino will be received in about 8 seconds from the press of the button if the phone is located. Note that this project can work if the phone is sleeping or on once the Blynk app is allowed to run in the background (even if the app is closed). The user must ensure that the Blynk project on the phone is on, for more details, see constructing the project.

Benefits

The user operating this project will benefit in:

  • Locating their phone if it is lost or stolen
  • Ease of use

Constructing the Project

Step 1: Required Apparatus

There are a few things needed in this project.

  • Jumper Wires
  • 1, Button
  • 1, Breadboard
  • 1, Resistor (220Ω)
  • 1, Smart Phone

Step 2: Connecting the Circuit

A simple project needs simple schematics, here is an image displaying the project's circuit.

Step 3: Acknowledging the Code

There are three parts to this project's code, each one is simple.

  • getLocation
  • Process Location Data
  • Send Email

Here is an indent look at each of the functions.

  • getLocation
BLYNK_WRITE(V0) // read virtual pin 0 for co-ordinates 
{ 
 latitude = param[0].asDouble(); 
 longitude = param[1].asDouble(); 
 altitude = param[2].asDouble(); 
 speed = param[3].asDouble(); 
} 

Blynk stores variables in Virtual pins, the function BLYNK_WRITE(V0) will read virtual pin 0 and store the values in separate variables, latitude and longitude will be used in this project. Ensure that the Blynk project is set up correctly before uploading the code. See below for instructions.

  • Process Location Data
if(latitude != 0.00 && longitude != 0.00) // if co-ordinates are valid 
     { 
       //String toSend is the string that will be sent as the emails body 
       String toSend = "Phone Located! \n received co-ordinates \n LAT "; 
       toSend += latitude; // add vaiables to string 
       toSend += " LNG "; 
       toSend += longitude; 
       toSend += ". View location on Maps: "; 
       toSend += "www.google.com/maps/?q="; 
       toSend += latitude; 
       toSend += ","; 
       toSend += longitude; 
       delay(500); 
    }

The email can only be sent as a string, so its body must be a string. This section of code will run if the received co-ordinates are reliable. Multiple items are added to the string, including Latitude and Longitude of phone and a Google Maps link to view the location on a map.

The Arduino will always check if the received co-ordinates are existent (not 0) before sending the email, the Arduino will continue requesting the phone's location until a valid one is received, the Arduino will loop this function up to 10 times.

  • Send Email
Blynk.email(userEmail, "PhoneLocator | Notification", toSend); // send email 
       if(proDebug == 1) 
       { 
         Serial.println("Success"); 
         Serial.println("Email Sent"); 
         Serial.println("Restarting Protocol"); 
         Serial.println(""); 
       }  

This is the function where the Arduino will send the email, the Arduino will send the string as the body of the email. ProDebug is a debugging tool that must be set to 0 in the project to enable the project to work without the Serial Monitor. The default setup is 1, which requires the Serial Monitor to be open for the project to work.

Setting up the Variables

Ensure that all the variables marked TODO are edited. These include your email, your Blynk auth token and proDebug. You will be guided on receiving your Blynk auth token further down.

Libraries

Bridge - Arduino LLC this library is in the public domain

Blynk - Blynk this library is released under The MIT License (MIT)

Blynk Setup

  • Step 1: Download Blynk

Blynk is a simple app that helps you create IOT products simply and easily, to get started with, download Blynk for IOS or Android.

  • Step 2: Create your Blynk Account

Fallow the images below and their data to set up your Blynk account.

Setup

The final step is to change the TODO variables, if not done already. The auth variable must be set to the Auth token received by email in the previous step. Make sure that all the TODO marked variables are correct. Connect your Arduino Yún to your Mac/PC and upload the code.

Background

I created this project as I was thinking of an easy solution to finding a lost phone. Blynk allows the user's Arduino Yun to receive geolocation even if the App is only working in the background and the phone is sleeping. By the click of a button, a lost phone can be located. Tested on iPhone (IOS11).

Code

PhoneLocator
The whole Code

Schematics

schematics_UhOTpO8N1Z.fzz

Comments

Similar projects you might like

Arduino Uno-Based, Easy-to-Build Pet Feeder

Project tutorial by edr1924

  • 1,912 views
  • 3 comments
  • 19 respects

HOW PIR SENSOR WORK

Project tutorial by DIY Partners

  • 2,544 views
  • 6 comments
  • 21 respects

4-Stroke Digital Clock With Arduino

Project tutorial by LAGSILVA

  • 7,441 views
  • 8 comments
  • 30 respects

RGB Camera Backlight Control with Android Mobile

Project tutorial by DIY Partners

  • 143 views
  • 0 comments
  • 2 respects

"Living Art" Arduino-Controlled Desk Lamp

Project tutorial by Modustrial Maker

  • 1,536 views
  • 0 comments
  • 5 respects
Add projectSign up / Login