Let's see what we need to set up a smart home system using MediaTek Linkit. Since there are lot of experts here to guide you on the hardware hookup to read the sensor data, I will concentrate on creating apis and setting up ultra low cost $15 local server to capture all your sensor data. Optionally, I log the data to azure.
The post is originally written by Syed Sanoor.
The sensors transmit there data via radio signals using xbee or any low cost transceiver to the MediaTek LinkIt. The MediaTek linkIt receives all the raw sensor data, packages it into json object using adruinojson library and makes a POST request to the local server. The local server hosts then nodejs web application and receives all the sensor data as json objects.
The local server is being used as pre-processor and adds the utc time and signature. Any data validation, conversion and filtration can be processed here. The local server logs all the data to cloud service in our case azure storage services. Alternatively, MediaTek linkIt can directly post the json objects to azure storage services. I setup a local server just to prove that a $15 pc can be as powerful enough to handle our data. we can log our data into any no-sql db even in our local server completely elimination the need for external cloud storage. I leave all this upto you guys.
Data logging demo
I assume that you know how to read sensor data using sensors and microcontroller like arduino or mediaTek. To limit the scope of this project I am going to assume that the sensor data are available to MediaTek Link It. You can use low cast radio transceiver or Xbee to transmit and receive the radio signals from sensors attached to microcontoller like MediaTek. Beginners can use the MediaTek linkIt groove starter kit to read the external environment data like temperature, humidity, light etc.
Json has become the de facto standard for iot and its been widely adopted. Having said about the prerequisite, lets begin by modeling our sensor data. The main purpose is to capture as many data you can and pass it to the server. The server can do all heavey lifting works like analytics, data conversion, machine learning etc.
Please refer the ino file attached to the software section to log the data into local server. The sensor data are simulated, you can pass in the actual reading to respective json object.
Local server adds a overhead but will be verify helpful in many ways. We can make use of local server as a pre-processor for out iot data. Data can be filtered, time stamped and signed
A tiny PC and nodejs is an excellent choice for local server. We can choose any tiny pc like raspberry pi, odriod, banana pi, beagle bone etc. I have choosen orange pi ($15) for this project.
Raspberry pi 2 or Orange Pi with any flavour of linux os that supports nodejs 5. I have chosen orange pi with arch linux for arm7. Installed nodejs and npm. Download my iotapp from github and navigate to /your/local/path/iotapp and run npm install. The basic expressjs app starts to listen on your port 3000.
Browse to your-local-ip:3000 to check if the default expressjs view is rendered. I have created these apis to post the sensor data
/iot/myhome/livingroom/thermostat - Temperature api
/iot/myhome/livingroom/mic - Sound api
/iot/myhome/livingroom/pir - Presence sensor api
/iot/myhome/livingroom/distance - Distance sensor api
/iot/myhome/mydevice/location - gps tracker api
/iot/myhome/garden/moisture - soil moisture sensor api
/iot/myhome/kitchen/gas - gas leak sensor api
/iot/myhome/livingroom/light - light sensor api
/iot/myhome/livingroom - other api for living room
/iot/myhome/bedroom - other api for bed room
To setup local server. Clone the source code iotapp from my github. Modify the index.js to put your cloud ip address or domain name where aspnet5 application is hosted in azure
Publishing data to the cloud has become popular now a days. We can purchase subscription from iot data provide like amazon, azure,spark fun, pubnub, initial state and many other. I have choosen azure for this demo. Data analytics, data mining and machine learning algorithm can be developed to process our data.
Download the iotwebapp from my github. I created it using visual studio 2015 targeting asp.net5. These apis were setup to post the iot data. The api logs the iot in the azure storage tables
The deviceid parameter can be set to identify if the sensor location.
These api's have been setup,