Hardware components: | ||||||
|
× | 1 | ||||
|
× | 1 | ||||
|
× | 1 | ||||
|
× | 1 | ||||
Software apps and online services: | ||||||
|
STORY
Introduction
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 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.
Prerequisite
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 Json Json
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.
The ‘desired’ json object will be the desired state of the sensor data. For example when we record the temperature, the desired value of 24 means we need to sync the value to the cloud with the value of 24. Our clients like web app or mobile app will be updated to this value.
When we want to turn on a light we say, the desired state as on. It means the light is turned on or will be turned on. All our client applications will use this state to reflect the changes to the user. I mean, the icon in our web app will be turned on or off.
This is not a international standard, I just came up with this. So, please feel free to use your own convenient format.
Temperature
{
"deviceid" : "iot/myhome/livingroom/thermostat"
"desired" : { "temperature" : "24", "humidity": "80"},
"timeutc": "2015-11-23T00:41:48.824Z",
"singedBy" : "localserver"
}
Microphone
{
"deviceid" : "iot/myhome/livingroom/mic"
"desired" : {"intensity" : "66"},
"timeutc": "2015-11-23T00:41:48.824Z",
"singedBy" : "localserver"
}
Distance
{
"deviceid" : "iot/myhome/livingroom/obstacle"
"desired" : {"proximity" : "150"},
"timeutc": "2015-01-01",
"singedBy" : "localserver"
}
PIR
{
"deviceid" : "iot/myhome/livingroom/pir"
"desired" : {"motion start" : "2500", "motion end" : "5345"},
"timeutc": "2015-11-23T00:41:48.824Z",
"singedBy" : "localserver"
}
GPS
{
"deviceid" : "iot/mydevice/location"
"desired" : {"lat" : "25.5", "long" : "32.2"},
"timeutc": "2015-11-23T00:41:48.824Z",
"singedBy" : "localserver"
}
Moisture
{
"deviceid" : "
/iot/myhome/garden/moisture"
"desired" : {"moisture": "20"},
"timeutc": "2015-11-23T00:41:48.824Z",
"singedBy" : "localserver"
}
Gas
{
"deviceid" : " /iot/myhome/kitchen/gas"
"desired" : {"leak": "No"},
"timeutc": "2015-11-23T00:41:48.824Z",
"singedBy" : "localserver"
}
Light
{
"deviceid" : " /iot/myhome/livingroom/light"
"desired" : {"intensity": "60"},
"timeutc": "2015-11-23T00:41:48.824Z",
"singedBy" : "localserver"
}
Or use this,
Living Room
{
"deviceid" : "/iot/myhome/livingroom"
"desired" : { "temperature" : "25",
"humidity" : "80",
"window": "open",
"door": "closed",
"light": "80",
"noise":"low"}
}
Bed Room
{
"deviceid" : "/iot/myhome/bedroom"
"desired" : { "temperature" : "24",
"humidity" : "70",
"window": "closed",
"door": "closed",
"light": "80",
"ac":"on"
"noise":"low"}
}
MediaTek – Receiver
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.
Schematics of Arduino RF Transmitter
Local Server
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.
Read More: Smart home system using MediaTek Linkit, Xbee, Arduino, Orange PI and Azure