Interfacing with Adafruit IO

Adafruit IO has a very user friendly, and intuitive interface and is well documented which makes getting started and building dashboards very easy. And quick!

Step 1 - Create an Adafruit IO Account 

Go to io.adafruit.com and register using an email address, username and password. You will need the AIO Key for authentication. Use the "View AIO Key" option from the main menu of io.adafruit.com to view or generate a new key.

You are now ready to start sending data to the io.adafruit.com. You send data using a key and a value. For example the Python code below will to send a temperature reading from device ID 21 with temperature reading 16.18 is:

Step 2 - Send data to Adafruit IO

Example Python code to send data to io.adafruit.com:

from Adafruit_IO import Client
ADAFRUIT_IO_KEY = 'YOUR ADAFRUIT IO KEY'
aio = Client(ADAFRUIT_IO_KEY)
aio.send('21', "16.18")

Step 3 - View your data 

Select the "Feeds" menu option and you will see a new feed has been created as shown below:

 

Click on the feed and you will see some historical data in a graph and data table. 

Step 4 - Create a visualization

Select menu option "Dashboard", click on the "Actions" button and select "Create new dashboard". Enter a name for your dashboard. 

Adafruit IO dashboards use "Blocks" to visualize the data. Click the blue + to create a new block and then select the type of block you want for your sensor. 

At the time this tutorial was written the above are the various blocks available for your dashboard. It is likely that over time this will get updated. Select the block you want and then follow the next couple of screens to link the block to the data feed and configure some settings for the block. You can create multiple blocks for the same data feed so this allows you to display the current value on a gauge and the historical data on a graph or table. 

Adafruit IO conveniently allows you to  manually add and delete your data, and download the data from a feed using the button for it when you are viewing a feed. A really cool feature we like is the data stream indicator at the top of the screen You probably won't notice it at first but once you start sending data to adafruit.io you will see a bunch of gray dots in a line separating the web page header from the body of the web page. Every time you send data to adafruit.io then you see a blue dot appear. Over time you will see the dots scroll to the left which gives you a very effective timeline of data being sent. Another cool feature is the error monitor that you can use to monitor any errors. 

Interfacing JemRF sensors with Adafruit IO

The JemRF Adafruit IO interface examples can be found at:

https://github.com/JemRF/Adafruit-IO

Raspberry Pi Python Tutorial

What you will need:

  1. Any model Raspberry Pi with preferably the full Raspbian distro (you can use Rasbian Lite but will need to install Python and PIP)
  2. Wireless Base Station for Raspberry Pi or Flex RF Module
  3. Any wireless sensor

What you need to know beforehand:

  1. How to operate a Raspberry Pi
  2. You have already set up your wireless base station and tested your sensor
  3. Some Python programming knowledge is preferable but not mandatory as we provide you with the source code
  4. You can review the Adafruit IO Python github page documentation here.

Step 1 - Download the JemRF sample interface code

Open up a terminal session on your Raspberry Pi and download the JemRF Adafruit IO library from github:

git clone https://github.com/JemRF/Adafruit-IO

cd Adafruit-IO

sudo nano rf_adio.py

Step 2 - Insert your AIO Key

Page down and insert your AIO Key in between the single quotes.

#Update aio variable below with your Adafruit AIO Key
aio = Client('b80da00de14646bc9a0c68109ae1186e')

Press ctrl-x and then y to save and exit. 

Step 3 - Install Adafruit IO Library

sudo pip install adafruit-io

Step 4 - Run the sample interface

Type the following to run the application:

python rf_adio.py

You will see output being sent to the screen when RF signals are processed:

pi@raspberrypi:~/temp/Adafruit-IO $ python rf_adio.py
Thu May 24 00:53:51 2018 a86AWAKE----
Thu May 24 00:53:51 2018 a86BUTTONON-
Processing data : DevId=86,Type=1,Value1=NON,Value2=0
Thu May 24 00:53:51 2018 a86BUTTONON-
Thu May 24 00:53:51 2018 a86SLEEPING-
Thu May 24 00:53:53 2018 a86AWAKE----
Thu May 24 00:53:53 2018 a86BUTTONOFF
Processing data : DevId=86,Type=1,Value1=NOFF,Value2=0
Thu May 24 00:53:53 2018 a86BUTTONOFF
Thu May 24 00:53:53 2018 a86SLEEPING-

In the above example you can see a wireless switch sensor being opened and then closed.

Now view the data feed on the Adafruit IO website. The below picture shows the open/close data that was sent.