IoT communication with the Adafruit IO API

Switching via the Dashboard

The program code for the Huzzah board in Listing 1 and the circuit in Figure 1 already includes a convenient function for receiving messages from the dashboard. This approach makes it easy for the developer to trigger actions on the IoT device. The LED on GPIO 13 controls an event handler that receives messages from a feed. The example shows the feed titled LED.

Figure 1: IoT clients and desktop apps communicate via REST or MQTT with the Adafruit IO API.

You create the dashboard in Figure 4 via Dashboard | Actions | Create a New Dashboard. You can then click on the blue plus symbol to add a new block to this dashboard. After selecting the toggle button and linking it with the LED feed, you create the block using Create block. The dashboard also includes a line graph next to the button for the LED that shows the temperature and humidity levels.

Figure 4: The dashboard not only displays the feed data, it also controls IoT devices, specifically the LED.

Finally, when you click on the toggle button on the dashboard, the sensor board detects it and turns the LED on or off. The function led-> onMessage() in Listing 1 redirects incoming notifications to the handleMsg() function, which analyzes the content of the message and switches to the appropriate LED.

Conclusions

Open hardware platforms such as Arduino and Adafruit lower the barriers for creative IoT projects. Meanwhile, the Adafruit IO API makes it particularly easy to combine network-compatible sensors with web dashboards and control them via the Internet. Only a few lines of script integrate applications into the Linux desktop.

Dashboards don't just display the measured data, they are also perfect for controlling hardware. Application output, as well as system values such as CPU and memory usage, can trigger events on the IoT hardware. You can use this triggering feature to display a message or output a signal to another hardware component, such as a light or WiFi socket.

The Author

Marcus Nasarek is completely devoted to scripting, Ruby, and the Raspberry PI.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

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

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Monitoring Beehives

    Beekeepers can get to know their colonies better without continuously disturbing the industrious insects. Using a Raspberry Pi and various sensors, two hobby beekeepers monitor the temperature and humidity of their hives, with plans to monitor their weight.

  • Conky System Monitor

    This light-weight system monitor keeps you informed about your computer's performance.

  • Decisions, Decisions

    When it comes to open hardware projects, the choice of an Arduino or a Raspberry Pi board can determine success or failure. Read on for guidance in selecting the best board for your specific needs.

  • Programmable USB Hub

    The Programmable USB Hub promises to resolve common issues with USB reliability in the short term, making way for future open hardware testing and debugging.

  • The sys admin's daily grind: Mi Flora sensors

    Columnist Charly Kühnast recently attached Mi Flora humidity sensors to his potted plants. At first, they only transmitted junk on Bluetooth, but armed with the right tools and a Rasp Pi, Charly now reaps a rich harvest of data.

comments powered by Disqus

Direct Download

Read full article as PDF:

Price $2.95

News