Introduction: GPSteal : Geolocate Your Stolen Car
Everyone wants to find its car when it has been stolen. That's why we had the idea to develop GPSteal.
GPSteal is a module which sends GPS data every 15 minutes to a network. The data can then be visualized on the website we developed. The interface is easy to understand : you just have to sign up and add your cars in your profile. You can finally see the location of your car on a map.
Note: This project has been held by an embedded system specialization from Polytech Paris-UPMC.
Step 1: What You'll Need
Here is the list of the material needed to build the project.
Electrical Part
- Sigfox shield (Akene)
- Antenna
- Accelerometer
- GPS
- STM32 microcontroller (Nucleo L476-RG)
- Few cables
- (optional) RaspberryPi to host your server
For this project we decided to use the Grove components. This kind of components is very special because they are connected to a board with the Base Shield (image bottom right). This shield is composed of ports where you can directly connect the components. It’s very convenient because you don’t need to know how the components are make to plug them correctly.
We connect the Nucleo L476-RG (image bottom left) to this Grove Shield to control the GPS and the accelerometer.
For the Sigfox part we used the Akene Shield (image bottom center). This device is also a Base shield but you can stack it with the shield Grove base. This will give you a "3-level" card with the nucleo, the Akene shield and the shield grove.
Computing Part
- Access to the Mbed workspace management to compile codes : https://developer.mbed.org/
- Access to Actoboard website for your Akene device : http://www.actoboard.com/
- Access to the console for google developers in order to obtain Keys for the APIs : https://console.developers.google.com/apis/
- A computer with Linux installed with different packages :
- apache2
- php - libapache2-mod-php7.0
- mysql-server
- php7.0-mysql
Note :If you prefer to use Windows or MAC instead of Linux, be careful that the packages to install could not be the same.
Step 2: Use the Accelerometer to Send GPS Data
The accelerometer
The accelerometer is used to activate the gps only when the car is moving. For our demonstration, the accelerometer activates the gps when it doesn’t move.
The only things you need to know is that the accelerometer works with the I2C bus. You have to connect it to an I2C port on the base shield.
To program the accelerometer we used the library created by ST for the Grove sensors here : Accelerometer library
To use this sensor we just created in main.cpp a function called : bool mouvement (int readings[],int precedent_read[])
This function compares the current values of the accelerometer with the previous ones. If the difference is greater than the DELTA_SEUIL the function returns true, if not it returns false.
The GPS
We used the grove gps for this project. It is a gps which sends its data through the serial port.
To program it we used this library : GPS library
We just had to change the timeout because the original timeout wasn't working with the Nucleo board.
The GPS class use callback functions to determine what kind of message is printed on the terminal. The function are called according to the state of the GPS (detection of satellite, bad reception of data…).
The function parseAndCallbackGGA(char *src, gps_callback_t *cbfuncs) is called when the data are correctly received by the gps.
Note : The autor of the library made an error about the types of data received. The autors wrote about latitude and longitude in decimal degrees (DD) but the data are finally in DMS so we have to make the conversion in the function conversion(float latitude, float longitude, DataStruct* data_gps).
Step 3: Send the GPS Data to Actoboard Using Sigfox
To send the GPS data, we used the Akene device. You can used it with an account to connect it to the Actoboard website. The goal of this device is to send data with the sigfox network.
Actoboard configuration
When the data are sent you can see them on the website. The only things you need to do on the Actoboard website are to connect your device with the website (the PAC and modem number) and to set the data format of the data which will be sent by your module.
Device configuration
The library for the Akene device is available here : Akene library
You just have to be sure which port are used. The Akene port used are D5 for the transmission (TX) and D4 for the reception (RX). So you have to use the same port on the Nucleo. The problem is that the D5 and D4 pins are not used for serial communication on the Nucleo so you will have to use the SoftwareSerial library to convert these two ports into RX and TX.
Finally you just have to use the Akene function in the function parseAndCallbackGGA(char *src, gps_callback_t *cbfuncs) to send the data through the Sigfox network. We had a timer to send the data every 10 minute.
Note : The maximum number of messages that can be sent each day is 140 for Sigfox.
Source code
The ZIP folder contains all the source code for our project. It can be run on uKeilVision5 or any mbed compiler.
Step 4: Create the Database With MySQL
First, you need to have a RaspberryPi to host the website in order to be able send data from your module to the database.
What is MySQL ?
MySQL is a Relational Database Management System. It's a software which makes it possible to manage databases using the SQL language.
Steps to create the database
To create the database, you have to be root on your computer.
- Open a terminal, go to the directory you want to create the database in and open MySQL management system
- mysql -u root -p
- Enter your root password
- Create a user with all privileges to use the database, here we created the user 'projetiot' identified by the password 'gpsteal'
- CREATE USER 'projetiot'@'localhost' IDENTIFIED BY 'gpsteal';
- GRANT ALL PRIVILEGES ON * . * TO 'projetiot'@'localhost'
- -> WITH GRANT OPTION;
- Create the database, here named 'gpsteal'
- create database gpsteal;
- Finally you can used our file gpsteal_data.sql to generate the different tables
- source gpsteal_data.sql;
You have created the database and the different tables. You can now exit the MySQL management system.
Attachments
Step 5: Send the Data in Actoboard to the Database
With your sigfox module, you can have access to an account on Actoboard. Actoboard is a website where you can have access to data sent thanks to Sigfox.
- Insert your URL on forwarding URL
- HTTP POST request with different parameters
- Choose what parameters you want to save
In our project, the data send were longitude and latitude. We send the data received to a PHP file on our server (on the RaspberryPi). In this file, you have to open the database and then insert the POST data into your database. Because we only have one module, we insert the data for the same car.
In reality, the number of the device is also send so we could use it to select the car which has this device.
Step 6: Create the Website
Website
At this address, you can find our website. It is actually running on a RaspberryPi but we are planning to export it on another server like Heroku very shortly.
Our website is in french but a video tutorial is done in english. Because we only have one module, the GPS coordinates are updated for only one car (the Daewoo Kalos of the video) but the idea is to link each existing module to a specified car to locate each of them.
We used several languages to create the website and tools such as the Google APIs to make everything more userfriendly.