Software apps and online services
Sandro is a device that lets you monitor people and things, and tell you continuously their location, and the values of the sensors attached to it.
You can set limit values for the sensors, and when these are exceeded an SMS alert is sent to you.
You can also set restrictions from some places, in order to be alerted when the device is too closer or goes to far from these places.
It's also possible to communicate with the device through SMS, in order to get information about it.
- GPS antenna (included in Linkit ONE kit)
- Battery (included in Linkit ONE kit)
- GSM antenna and a SIM with internet connection, or Wi-Fi antenna (antennas included in Linkit ONE kit)
- Web Host
- Grove starter kit (optional)
If this is the first time you are using Linkit ONE, please visit this page from Mediatek Labs web site. You'll find a guide to setup the Arduino IDE and the board.
Now put these file in the same directory on a web server:
Set your Linkit ONE to Mass Storage Bootup mode, and put "settings.JSON" in its internal storage.
Put the board in UART mode again, and load "Sandro.ino" on it with the Arduino IDE.
Now everything should be ready to work, so just power on Linkit one with the battery.
Go to your web server and open "index.html".
The browser will ask you to allow the page to get your coordinates based on your internet connection, in order to see it on the map.
If there is an error while getting you location, it will set it to New York, or if your browser doesn't support geolocation, it will set it to Siberia or it will set your last known location, if there is one.
Then you should see something like this:
The blue marker is you and all the other markers are the devices you are monitoring.
When a marker is red, means that we haven't got news from it for more than 2 minutes. When it's yellow, the device is sending data, but there are less than 4 visible satellites, so the coordinates he sends are probably not correct. The green color instead indicates that the device is online and there are more than 3 satellites visible.
The marker starts bouncing when there is an alert (restriction violated or sensor alert) even if its color is yellow.
On the top there are your latitude and longitude, and you can edit them and press Update to make the blue marker move, and the distances from all the devices updated.
With the "Click n' set" function, you can change your location simply by clicking on the map.
Then press "Find me!" to restore your true position.
Pressing "Show charts" reduces the height of the map, to let you see the charts.
Under your location there are the informations about the selected device, which you can change from the dropdown menu.
When the web page is closed all data about you and the devices are saved in the "save.JSON" file.
You can monitor it by sending SMS like this:
To receive informations about the device location, send a message containing the word "where".
For the value of a sensor, write its name in the message.
To store data on the device's storage (for example when it's not connected to internet)
the massage must contain "log" and "start", "begin" or "enable". To disable it send "log" and "stop", "disable" or "end".
The data will be saved on a file in the local memory (or microSD) of the device, named "YYYY-MM-DD.txt", so a new file is created every day.
As you can see, if there is an alert, an SMS is sent every 3 minutes.
This is the json file that we previously put in the Linkit One.
As you can see, you can set your pubnub keys, the device name and your phone number.
To add restrictions, just add their coordinates, minimum and maximum distance in the "places" json array.
The restriction can be for a static location, or for another device. if you set the "type" to "device", it will subscribe to the other's pubnub channel to get its position and calculate the distance in real-time.
For the sensors, you can change their limit values, but if you add or remove sensors, you will also need to edit the Linkit ONE's sketch.
Chose where to save the log file:
#define STORAGE LFlash // Use Internal Flash storage
// #define STORAGE LSD // Use SD card storageode>Chose GPRS or Wi-Fi connection:
//LWiFiClient c; //Uncomment this for Wi-Fi connection
LGPRSClient c; //Uncomment this for GPRS connection
while (!LGPRS.attachGPRS("your_apn", "username", "password")) delay(1000);
//while (0 == LWiFi.connect(WIFI_AP, LWiFiLoginInfo(WIFI_AUTH, WIFI_PASSWORD)))delay(1000); //Uncomment this line if you want o use WI-Fiode>
If you use Wi-Wi you need to set the AP name and password
#define WIFI_AP "AP_name"
#define WIFI_PASSWORD "password"
#define WIFI_AUTH LWIFI_WPA
You can set how often the device will publish messages on pubnub channel, and how often it will send SMS alerts:
const int pubTimeout = 5000, alertTimeout = 300000 ; //timeout for publishing pubnub messages and timout for sending SMS alertode>In the setup we start GPS, get informations from
and enable internet connection.
This function reads your sensors values and put them in the json that will be sent on the pubnub channel.
So here you will need to read your sensors and put their values in the json with something like this:
message["Light_sensor"] = analogRead(sensorPin);
The name of the sensor must correspond to what you written in setting file.
In this demostration, I used random value to simulate temperature and humidity sensor.
message["Temperature"] = random(5, 30);
message["Humidity"] = random(10, 90);ode>
Called after readSensors(), checks if the sensors values don't excede limit values.
Controls all the restrictions. if it's from a location, it calculates the distance from there, but if it's from a device it first subscribe to its channel, in order to get its coordinates.
The other functions are quite simple.
index.htmlHere you need to change your pubnub and Google Maps Keys:
This file works as "settings.json", you can edit it accordin to your devices and your sensors
This file is called by index.html when you close the web page in order to save data:
You can do great things I'd say! This project is not for a specific type of sensors, so you can plug in every thing you want. The grove kit has some interesting sensor and they are very easy to use.
Lets make an example for a real temperature and humidity :
- First off all we go here to see how to use the sensor.
- We include libraries and initialze variables
#define DHTPIN 2 // what pin we're connected to
#define DHTTYPE DHT22 // DHT 22 (AM2302)
DHT dht(DHTPIN, DHTTYPE);ode>
}ode>- Now in the readSensors function, we read the sensor's values and put them in the json message
float t = 0.0;
float h = 0.0;
message["Temperature"] = t;
message["Humidity"] = h;
The device provides you also many other GPS informations, and the battery level, so it's up to your immaginatio to think how to use these data.
since the beginning, this project had to have a touchscreen display on it, but the display I already had did't worked with Linkit ONE.
I had to submit the project before the deadline of the mediatek smart cities contest, so I decided to make it without the display for now.
When I'll find it, I'll continue with the project.
Sandro (Alessandro) is a friend of mine we both study at the university of Padua.
One day I told His "what about if I give your name to one of my projects?"
And that's all