IoT Dashboards

Freeboard

Now you have all the data that you want being published to the PubNub MQTT broker, it is time to set up a free account at freeboard.io. Go to My Freeboards and create a new Freeboard called SunIOT. Click on the name (i.e. SunIOT) to begin building the IoT dashboard.

The JSON for this dashboard is shown in Listing 4 and included in the GitHub repository. Being able to import dashboards is critical to being able to distribute kits and repositories for projects like this. Build your own dashboard from the following tutorial or copy and paste the following JSON into a file called dashboard.json and import it from the Freeboard site. Edit this file or change your subscribe key in the datasource. Change the "subscribe_key":"sub-c-XXXX", to the value of your own project.

Listing 4

dashboard.json

01 {"version":1,
02 "allow_edit":true,
03 "plugins":["/plugins/all"],
04 "panes":[
05     {
06     "width":1,
07     "row":{"3":1,"4":1,"5":1},
08     "col":{"3":1,"4":2,"5":2},
09     "col_width":1,
10     "widgets":[
11         {
12         "type":"gauge_widget",
13         "settings":
14             {
15             "title":"Visible",
16             "value":"datasources[\"SunIOT\"][\"SunIOT_Visible\"]",
17             "min_value":0,
18             "max_value":"1000"
19             }
20         }]
21     },
22     {
23     "width":1,
24     "row":{"3":1,"4":1,"5":1},
25     "col":{"3":2,"4":3,"5":3},
26     "col_width":1,
27     "widgets":[
28         {
29         "type":"gauge_widget",
30         "settings":
31             {
32             "title":"InfraRed",
33             "value":"datasources[\"SunIOT\"][\"SunIOT_IR\"]",
34             "min_value":0,
35             "max_value":"6000"
36             }
37         }]
38     },
39     {
40     "width":1,
41     "row":{"3":1,"4":1,"5":1},
42     "col":{"3":3,"4":4,"5":4},
43     "col_width":1,
44     "widgets":[
45         {
46         "type":"gauge_widget",
47         "settings":
48             {
49             "title":"UV Index",
50             "value":"datasources[\"SunIOT\"][\"SunIOT_UVIndex\"]",
51             "min_value":0,"max_value":"10"
52             }
53         }]
54     },
55     {
56     "width":1,
57     "row":{"3":9,"4":9,"5":9},
58     "col":{"3":2,"4":3,"5":3},
59     "col_width":1,"widgets":[
60         {
61         "type":"sparkline_widget",
62         "settings":
63             {
64             "value":["datasources[\"SunIOT\"][\"SunIOT_Visible\"]"]
65             }
66         }]
67     },
68     {
69     "width":1,
70     "row":{"4":1},
71     "col":{"4":1},
72     "col_width":1,
73     "widgets":[]
74     }],
75     "datasources":[
76         {
77         "name":"SunIOT",
78         "type":"pluginXXXX",
79         "settings":
80             {
81             "subscribe_key":"sub-c-XXXX",
82             "channel":"SunIOT_Sunlight"
83             }
84         }],
85     "columns":5
86 }

Next, click Add under DATASOURCES. In this case, the datasource is the PubHub MQTT broker. Fill out the form, using your subscribe key from PubNub.

After completing the form, click add Pane, and then click the + in the new pane. Select Gauge. Fill out the form, as follows:

  • Type: PubNub
  • Name: SunIOT
  • Subscribe Key: Your subcription key
  • Channel: SunIOT_Sunlight

Repeat these steps for both of the other SunIOT data types (SunIOT_IR, SunIOT_UVIndex). There are many other types of widgets to experiment with.

Congratulations! You now have your IoT device hooked up to an Internet dashboard. The link can be shared with anyone. Private pages are available through inexpensive paid plans.

Figure 7: The Complete IoT Dashboard Connected to SunIOT.

Further steps

You can expand this project by building some more complex IoT devices with more sensors. You can also add some actuators (such as motors and fans). Feel free to add some controls on your IoT page to activate your actuators.

Note, however, that this software has no computer security features beyond the secret publish and subscribe keys. This is a serious concern for IoT devices. More information as well as some best practices is available online [13].

You can download the code for this article from [14].

Buy this article as PDF

Express-Checkout as PDF

Pages: 5

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content