.
I am going to build a hiker tracking device with companion app. It will be use as tracking device for hikers in case getting lost. There isn't much different from existing solutions. But I plan to add a feature which allows the device to track other moving objects like trucks and cars.
The device will send GPS data and other sensors data (if there are) to an IoT platform. The companion web app will show those data and map of those GPS data.
.
How it works.
Due to lack of WiFi component, I use a MKR1000 to provide the WiFi capability. Sony Spresense board will communicate with and send position coordinates to MKR1000. MKR1000 will then send these data to Azure IoT hub whereby a node.js script will read the data and update to a Firebase realtime database. A hikers' map will display the data as the position of the hikers in real time.
.
Setup Azure IoT Hub.
I have set up an IoT hub and an IoT device on the Azure cloud following this quickstart tutorial. Take note of the hub name, device name and their corresponding connection string. These info is needed for the configuration in the code.
The ReadDeviceToCloudMessages.sonydevice01.js shows the messages sent to the IoT hub. This codes write the latitude and longitude values to Firebase realtime database too. There is a picture showing a list of telemetry messages below.
.
Setup MKR1000.
Set up WiFi for MKR1000 by following the instruction at this link.
Azure IoT Hub library for Arduino is used to allow MKR1000 communicating to Azure IoT hub.
MKR1000 will send GPS data and other sensor data (if there is any) to the Azure IoT Hub. Upon receiving the data, the latitude and longitude values are updated to a Firebase realtime database and used to position a marker on Google map (see below).
.
Use of Android phone.
In this project, a Android phone is used as a mobile hotspot for MKR1000 to make a internet connection to Azure IoT Hub.
.
Make the map.
Follow instructions of this tutorial to make the companion web app which show a map tracking the movement of hikers.
.
Setup Sony Spresense development board.
I use Arduino IDE. Follow this guide to get started with the Sony Spresense board and its development environment. And here is the Spresense Arduino Library Developer Guide.
.
Some pictures.
.
.
Some codes.
The following code write data to Firebase:
var config = {
apiKey: "<apiKey>",
authDomain: "<name>.firebaseapp.com",
databaseURL: "https://<name>.firebaseio.com",
storageBucket: "<name>.appspot.com"
};
firebase.initializeApp(config);
var database = firebase.database();
...
function writeData(hiker, latitude, longitude) {
database.ref(hiker).set({
lat: latitude,
lng : longitude
});
}
.
Sony Spresense MKR1000
TX ---> RX
RX ---> TX
.
Future enhancements.
- Build a companion mobile app.
- Do away the MKR1000 component, but add a WiFi shield instead.
- Write the latitude and longitude data directly to Firebase realtime database.
.
Summary.
I have difficulty getting the satellite reading at my area. I only get the whole thing works end-to-end once or twice. Like I mentioned in future enhancements, a lot of improvement can be made to this project. I will make another project with some of the above mentioned enhancement in the future.
.
Comments