IoT Dashboard
We hook a simple IoT device up to a couple of IoT Dashboards on the Internet so that everybody can see what’s going on.
We hook a simple IoT device up to a couple of IoT Dashboards on the Internet so that everybody can see what’s going on.
In the last issue of Raspberry Pi Geek we covered a simple IoT device using a I2C Sunlight sensor and a Raspberry Pi [1]. For this project we are going to be hooking it up to a couple of IoT Dashboards on the Internet for all to see our IoT device. This project focuses on hooking the device up to two IoT dashboards to make it accessible via the internet. This tutorial covers two different kinds of IoT dashboards. Both are free for non-commercial use.
An IoT Dashboard is a web-based software program that displays information about IoT devices and enables you to control them. These can be run and viewed on many different computers such as smartphones, tablets, PCs, smart watches and connected TVs. There are many commercial and non-commercial dashboard platforms available. IBM Bluemix [2] is considered the gold standard and is the most complex. Other platforms include InitialState [3], adafruit.io [4] and Freeboard [5]. This tutorial focuses on a combination of Freeboard and Pubnub [6], which are both based on the MQTT protocol [7]. Bluemix and adafruit.io also use MQTT.
MQTT is a publish-subscribe based light weight messaging protocol for use on top of TCP/IP, such as the WiFi packets used in this project. It is designed for connections with remote locations where a small code footprint is required or where the network bandwidth is limited. The publish-subscribe messaging pattern requires a message broker. The broker is responsible for distributing messages to interested clients based on the message topic.
Publish-subscribe is a pattern whereby senders of messages, called Publishers (in this case ESP8266 WiFi module [8]), don't program the messages to be sent directly to subscribers. Instead they characterise message payloads into classes without the specific knowledge of to which subscribers the messages are sent. Similarly, subscribers will only receive messages that are of interest without identifying specific publishers.
Pubnub.com operates as the broker in our system and routes the published data to the appropriate subscribers. Mosquitto [9] can be used to build a broker on a Raspberry Pi [10].
The first step is to set up an IoT Dashboard using Pubnub and freeboard (see Figure 3).
PubNub is a free MQTT broker. It implements a publish/subscribe system for real time data streams. You can expand its tools for more complex applications or products.
Freeboard.io is a free dashboard application. It can build real-time, interactive dashboards and visualisations in minutes using the reasonably intuitive drag & drop interface. While not as pretty as the Initial State dashboard, it has an amazing amount of functionality under the hood and is open source. This means it supports community developed blocks and modules.
JSON [11] is an open standard format that uses human-readable text to transmit data objects consisting of attribute-value pairs. It is the primary data format used for asynchronous browser/server communication, largely replacing XML. XML is a "heavier" protocol that is also hierarchical in nature, but with a great deal more redundancy than JSON. The higher data density of JSON arguably makes it a better choice for IoT applications.
Listing 1 shows an example of the data packet used in the SunIOT code in JSON for the Sunlight data payload:
Listing 1
SunIOT Data Packet
01 { 02 SunIOT_Visible: 260, 03 SunIOT_IR: 257, 04 SunIOT_UVIndex: 0.020000 05 }
PubNub allows you to integrate scalable, real time data streams into applications. Using the publish/subscribe paradigm, subscribers to a particular channel will receive any and all messages that are published to it. It doesn't matter if there is one subscriber or a million. A published message will be delivered to all subscribers on the channel in less than 0.25 seconds.
Pages: 5
Price $15.99
(incl. VAT)