My IoT Device - GPS Trigger

by MyBrewbot in Circuits > Arduino

2251 Views, 3 Favorites, 0 Comments

My IoT Device - GPS Trigger

Picture1.jpg

In this instructable you'll learn how to set up your IoT controller to send an email when you are x minutes from home.

Open the Example

GPS_Trigger_Load.JPG
Blynk_LED_Play.JPG
GPS_Trigger7.jpg
GPS_Trigger.png

Go to File/Example/My_IoT_Device and load the GPS_Trigger file

Open the Blynk app and take it offline (touch the square icon in the top right corner).

If you haven't bought any extra energy units, delete the current project by touching the nut shaped icon at the top of the screen, scrolling down and selecting delete.

If you have bought extra energy units and want to add the project then touch the back button at the top left of the screen to take the current project out of focus.

Touch the QR code at the top of the screen and point the camera at the QR code above. Once the project has loaded touch the nut symbol at the top of the screen, scroll down and select 'email all'

In a matter of moments you will receive an authorisation code in your email.

The Widgets Explained

GPS_Trigger3.jpg
GPS_Trigger2.jpg
GPS_Trigger6.jpg

This project needs 3 widgets.

An email widget.

A push button widget (to switch the GPS tracker on and off).

The GPS trigger itself.

The project also uses a Blynk feature called 'Notification' which, when triggered, will send a notification to your phone.

The Code

GPS Code 1.JPG

Despite this being a very sophisticated application - the code is surprisingly simple.

As in all examples you need to input your SSID, password and authentication code. This example requires a further three inputs. The address you want the email sent to. The header for the email and the email text (140 characters maximum). These are all found on the first tab.

On the Blynk tab is the main code for this application.

The Blynk Tab

GPS_Trigger6.jpg
GPS Code 2.JPG
GPS_Trigger5.jpg
GPS Code 3.JPG

This consists of two blocks of code, one for the push button widget and one for the GPS trigger.

The first block is for the BLYNK_WRITE(V0) instruction.

When the button is switched on it sets a global variable (boolean GPS_On = false;) which was set on the first tab and is therefore available to the whole program. When the button is switched on it sets the variable to true, and false when it is switched off.

The second block is for the GPS trigger BLYNK_WRITE(V1) instruction.

If the push button is switched on (if(GPS_On) ) it will execute. If the push button isn't switched on it won't.

When the phone exits the trigger zone it will notify the user's phone that it has exited. (if (!state)).

When the phone enters the trigger zone (you are coming home) it will send an email to the addressee telling them that you are on your way. (if (state)).

Setting the Trigger Zone

GPS_Trigger4.jpg

Very easy. Just orientate and size the circle to give you the trigger zone.

Once all that is done, upload the code to the controller and press play on the Blynk application.

Congratulations! You have now created an IoT GPS application.