AWS IoT using Onion Omega

The Onion Omega is a single-board development kit. It is really the brains of a Linux-based WiFi router. So I want to see if it can run the AWS CLI and work with AWS cloud services. Here is mine plugged into a dock that has a display expansion attached.

First up is to see what Amazon IoT is all about and get the Omega to work with it. After going through Amazon’s interactive tutorial and using an article on the subject, I was able to get the basic functionality working.

Basically you need to register your IoT device as a “Thing”, assign a certificate and a policy to authorize the device allowing it to do only what you permit. Amazon with give you a URL to send you messages to and poll for instructions from.

I set it up in the AWS IoT console using the article as a guide, and ran the setup script provided (installs the mosquitto framework and sets some variables, and subscribes the device to the “thing”). At this point I could run the following tests from the Omega command line and immediately view the results in the IoT console. For example, the following line:

mosquitto_pub -t \$aws/things/Omega-3425/shadow/update -m '{"state": {"desired": {"temperature": 1 }}}' -q 1
mosquitto_pub -t \$aws/things/Omega-3425/shadow/update -m '{"state": {"delta": {"temperature": 1 }}}' -q 1

($aws is a variable holding the URL for this Thing, and “Omega-3425” is the name given to the Thing)

This produces this content in the “Shadow”:

And adding:

mosquitto_pub -t \$aws/things/Omega-3425/shadow/update -m '{"state": {"reported": {"varName": 1}}}' -q 1

Updates the shadow to:

The Shadow (optional) is state stored in AWS IoT that represents what the thing’s state should be regardless of its actual physical state. If the connection is lost the device can later query the shadow and set its state to what it needs to be – to catch up. This also allows the rest of the application to “see” the device and perform triggers without needing to query it. As you can see, the state, like much of AWS, is based on a JSON document.