Introduction: My IoT Device - GPS Trigger
In this instructable you'll learn how to set up your IoT controller to send an email when you are x minutes from home.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Open the Example
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.
In a matter of moments you will receive an authorisation code in your email.
Step 2: The Widgets Explained
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.
Step 3: The Code
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.
Step 4: The Blynk Tab
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)).
Step 5: Setting the Trigger Zone
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.