Open Standard-based Internet of Pumpkins

From a different post, you might have tried to control the colour of Sensy, SensorUp's Internet-connected Pumpkin.  Some of you might say there is nothing new about sending a message to a pumpkin light and change its colour, because you have seen it on Big Bang Theory.

However, what we present here is world's first Internet of Pumpkins enabled by international open standards.  Why open standard IoT?  One of the biggest challenges for today's IoT is the lack of interoperable standards.  Today's IoT systems are a proprietary and fragmented systems using customized APIs, so that it is difficult to integrate these heterogeneous systems to create new applications. An open standard-based system means it is very easy and simple to integrate different systems into a coherent system, so that we can focus on creating innovative applications rather than the daunting details of handling heterogeneous APIs and data formats.

In this technical blog, we are going to explain the underlying interoperable standards allowing you to control Sensy's colour. Figure below shows the system architecture of the Internet of Pumpkins.

Internet of Pumpkin's Open Standard Architecture

 

SensorUp's SensorThings API (STA) is the IoT cloud platform and data exchange platform connecting the different components.  When you click on the change colour buttons on the web page (e.g., red), it sends a HTTP POST request to our OGC SensorThings API server:

POST /v1.0/Datastreams(example_datastream_id)/Observations HTTP/1.1 200 OK
Host: www.example.org
Content-Type: application/json
 
{"result":"red"}

The above request inserted a new data point to the STA cloud.  And because Sensy, our pumpkin, connects to SensorUp STA via the MQTT protocol and subscribes to the colour datastream, whenever the colour is changed, a message will be pushed to Sensy immediately:

MQTT Subscribe /v1.0/Datastreams(example_id)/Observations
 
{
  "result": "pink",
  "resultTime": null,
  "@iot.selfLink": "http://chashuhotpot.sensorup.com/OGCSensorThings/v1.0/Observations(example_observation_id)",
  "@iot.id": example_observation_id,
  "phenomenonTime": "2015-10-29T18:18:10.784Z",
  "FeatureOfInterest@iot.navigationLink": "../Observations(example_observation_id)/FeatureOfInterest",
  "Datastream@iot.navigationLink": "../Observations(example_observation_id)/Datastream"
}

Because the message pushed to Sensy is in the OGC SensorThings API standard, Sensy is able to understand the message and act accordingly.  In this case, Sensy turns red.  (smile)  

In addition to changing colour, we also would like to know what's the most popular colour for Sensy. We use the highchart javascript library, and connect it to SensorThings API via MQTT.  Voilà. Whenever Sensy's colour changed, the bar chart also gets updated.

And yes, it is that simple. The whole implementation is just a few lines of code. All components and codes are reusable for different applications, and that's the benefits for open standards.

For more details of the OGC SensorThings API, SensorUp has prepared a comprehensive developer documentation and sample codes. http://sensorup.com/docs/  If you have any interesting ideas, feel free to contact us!  (smile)  

 

One more thing....

If you really want to scare some of us in the office, try the following bash script.... (Gist also available here)

let i=1
COUNT=100
while [ $COUNT -gt 0 ]; do
	curl --request POST \
     --data '{"result":"blue" }' \
     --header "Content-Type: application/json" \
 http://chashuhotpot.sensorup.com/OGCSensorThings/v1.0/Datastreams%28422139%29/Observations
sleep 0.2
curl --request POST \
     --data '{"result":"green" }' \
     --header "Content-Type: application/json" \
 http://chashuhotpot.sensorup.com/OGCSensorThings/v1.0/Datastreams%28422139%29/Observations
sleep 0.2
curl --request POST \
     --data '{"result":"yellow" }' \
     --header "Content-Type: application/json" \
 http://chashuhotpot.sensorup.com/OGCSensorThings/v1.0/Datastreams%28422139%29/Observations
sleep 0.2
	let COUNT=COUNT-i
done