Professional Documents
Culture Documents
Welcome To Adafruit IO
Welcome To Adafruit IO
Welcome To Adafruit IO
Guide Contents 2
Overview 5
Why We Built Adafruit IO 5
What is Adafruit IO? 6
What can Adafruit IO do for me? 6
Dashboards 6
Triggers 7
Integration with IFTTT and Zapier 7
Getting Started with Adafruit IO 8
Feeds 8
Dashboards 9
Arduino and Adafruit IO 10
Compatible Hardware 11
WiFi 11
Ethernet 12
Cellular Connectivity 13
Libraries 14
Adafruit IO Arduino Library (REST-based) 14
Installation 14
Usage 15
Using the Adafruit IO Arduino Library with WiFi 16
Using the Adafruit IO Arduino Library with Ethernet 16
Using the Adafruit IO Arduino Library with Cellular (32u4 FONA) 17
Adafruit MQTT Arduino Library 17
Installation 17
Projects 19
Adafruit IO Basics 19
Adafruit IO on the Adafruit Learning System 21
Gmailbox (https://adafru.it/CrU) 22
Adafruit IO Environmental Monitor for Feather or Raspberry Pi (https://adafru.it/CrV) 22
Adafruit IO Home: Lights and Temperature (https://adafru.it/CrW) 22
Using IFTTT with Adafruit IO to Make an IoT Door Detector (https://adafru.it/Bo3) 23
Home Automation in the Cloud with the ESP8266 & Adafruit IO (https://adafru.it/Bo2) 23
Cloud Cam: Internet-Connected Security Camera (https://adafru.it/BmA) 23
Smart Toilet Light (https://adafru.it/Bo4) 24
Adafruit IO Projects on the Blog! 24
Python and Adafruit IO 25
Compatible Hardware 26
CircuitPython and Raspberry Pi 26
What does this mean for Adafruit IO? 26
Suggested Hardware 26
Raspberry Pi Zero W 27
Raspberry Pi 3 - Model B+ - 1.4GHz Cortex-A53 with 1GB RAM 27
I don't see the board I wish to use listed here. 27
Client Library 28
Adafruit IO (https://adafru.it/fsU) is a platform designed (by us! (https://adafru.it/Bo5)) to display, respond, and interact
with your project's data. We also keep your data private (data feeds are private by default) and secure (we will never
sell or give this data away to another company (https://adafru.it/BlI)) for you. It's the internet of things - for everyone!
Here at Adafruit, we sell all of these amazing components (https://adafru.it/dAR), but we couldn't find a good way to
interact with them over the Internet. There are certainly a lot of great services out there for datalogging, or
communicating with your microcontroller over the web, but these services are either too complicated to get started, or
they aren't particularly fun to use. So, we decided to experiment with our own system, and that's Adafruit IO.
Adafruit.io is a cloud service - that just means we run it for you and you don't have to manage it. You can connect to it
over the Internet. It's meant primarily for storing and then retrieving data but it can do a lot more than just that!
Dashboards
No problem! Dashboards (https://adafru.it/f5m) are a feature integrated into Adafruit IO which allow you to chart, graph,
gauge, log, and display your data. You can view your dashboards from anywhere in the world.
Triggers
Use triggers in Adafruit IO to control and react to your data. Configure triggers to email you when your system goes
offline, react to a temperature sensor getting too hot, and publish a message to a new feed.
Want to make your project react to an email, display trending tweets, or turn on the front lights when your pizza is on
the way? We baked in integrations with IFTTT (https://adafru.it/Bvr) and Zapier (https://adafru.it/BlL) to connect your
project's sensors to hundreds of web services.
You need an account because we want to make sure the data you upload is available to you and only you
until you are ready to make it public
Head over to io.adafruit.com (https://adafru.it/fsU) and click Sign In to log into IO using your Adafruit account. It's free
and fast to join.
You will be directed to your profile page showing your plan, connected services, and account data:
From here, you'll want to learn about two important features of Adafruit IO before proceeding further - Feeds and
Dashboards
Feeds
Dashboards
Have an Arduino or Arduino-Compatable board which you want to use with Adafruit IO? Want to adapt your sketch to
Adafruit IO? It's easy! We provide two libraries which work with lots of compatable hardware.
Need inspiration or project examples? We built sixteen examples sketches to get you up and running, along with six
guides to follow-along to.
There's a ton of hardware using these interfaces available, but this guide is going to highlight boards Adafruit
produces and sells:
WiFi
You know WiFi - you use it all-day every-day. It’s the standard wireless protocol for connecting to the Internet. It’s
available not only at home and work but also in stores, cafes, trains, planes and in most major cities. The
worldwide universality of WiFi makes it a common first choice for IoT. - All the Internet of
Things (https://adafru.it/BlX)
The Adafruit IO Arduino and MQTT libraries are compatible with hardware using using ESP8266, ESP32, WINC1500,
and WICED interfaces.
Ethernet
Good ol' Ethernet. This ‘ancient’ protocol has withstood the test of time. You almost certainly use Ethernet at home
and at work. Ethernet has a standardized connector, the venerable RJ-45. When you need something to "just
work," often a wire will do that. (Just because it's "IoT" doesn't mean it's wireless, just that many Things happen to
be wireless.) - All the Internet of Things (https://adafru.it/BlY)
Cellular Connectivity
Cell phones can go just about anywhere - there are towers across every country, in almost any place there are
people. And cellular towers can be very powerful. When coupled with a high power transceiver on your device,
range can easily hit miles away. - All the Internet of Things (https://adafru.it/BlZ)
The Adafruit IO Arduino Library is a simple library to send and receive feed data using the Adafruit IO REST
API. (https://adafru.it/uff) We suggest using it before moving onto the more advanced features of the MQTT Library.
ESP8266 (https://adafru.it/fpd)
ESP32 (https://adafru.it/fpd)
ATWINC1500 (https://adafru.it/fpd)
WICED (https://adafru.it/fpd)
Ethernet (https://adafru.it/fpd)
FONA (Cellular) (https://adafru.it/fpd)
Installation
You can install the library through the Arduino Library Manager (click: Sketch -> Include Library -> Manage Libraries...)
Alternatively, you can download the Adafruit IO Arduino Library from GitHub (https://adafru.it/fpd) and install it
Usage
The included examples sketches will walk you through all of the features of the library. They can be used on all
platforms, but they default to WiFi. Most of the sketches have companion projects on the Adafruit Learning
system. (https://adafru.it/BmC)
To change between platforms, you will need to change two lines of code in the config.h tab of the example. It is
recommended that you start with one of the Adafruit WiFi feathers before moving on to cellular or ethernet.
For all examples, you will need to set IO_USERNAME and IO_KEY in the config.h tab:
To find your IO_USERNAME , navigate to your profile on Adafruit IO (https://adafru.it/BmD) and click View AIO Key.
Copy the Username field (ctrl+c or command+c)
Then, in the config.h tab, replace the "your_username" text with your the username from your profile:
To find your IO_Key , navigate to your profile, click View AIO Key, and copy the ACTIVE KEY field to your clipboard
(ctrl+c or command+c).
In config.h , replace the IO_KEY with the IO Key copied to your clipboard.
If you are using the included examples, you do not need to change anything for the Adafruit WiFi Feathers. All WiFi
based Feathers (ESP8266, M0 WiFi, WICED) will work with the examples out of the box once you add your WiFi SSID
and Password to the config.h file.
In the config.h tab, replace "your_ssid" with your WiFi's SSID and "your_pass" with your WiFi's password:
For Ethernet, you will only need to change from the default WiFi constructor to the Ethernet specific constructor in
the config.h tab. The rest of the sketch remains the same.
#include "AdafruitIO_WiFi.h"
AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);
For FONA, you will only need to change from the default WiFi constructor to the FONA specific constructor in
the config.h tab. The rest of the sketch remains the same.
#include "AdafruitIO_WiFi.h"
AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);
#include "AdafruitIO_FONA.h"
AdafruitIO_FONA io(IO_USERNAME, IO_KEY);
If your carrier requires APN info, you can set it by adding a call to io.setAPN() after io.connect() in the setup() function of
the sketch.
void setup() {
// start the serial connection
Serial.begin(115200);
// connect to io.adafruit.com
io.connect();
io.setAPN(F("your_apn"), F("your_apn_user"), F("your_apn_pass"));
}
We also have a library to provide support for accessing Adafruit IO using MQTT. This is a general-purpose MQTT
library for Arduino that's built to use as few resources as possible so that it can work with platforms like the Arduino
Uno. Unfortunately platforms like the Trinket 3.3V or 5V (based on the ATtiny85) have too little program memory to
use the library--stick with a Metro 328p or better!
The MQTT library supports the following network platforms and hardware:
Installation
You can install the library through the Arduino Library Manager (click: Sketch -> Include Library -> Manage Libraries...)
If you're using an Adafruit FONA, you'll need to install an additional two libraries for the MQTT Library to work properly:
Adafruit SleepyDog (https://adafru.it/fp8), watchdog library used by FONA code for reliability.
Adafruit FONA (https://adafru.it/dDC), required for the FONA hardware.
Adafruit IO Basics
Todd Treece (https://adafru.it/ubi) has put together seven guides using Adafruit IO for input, temperature, humidity,
servo control, and so much more:
Gmailbox (https://adafru.it/CrU)
Build a physical mailbox for your emails using Adafruit
IO and IFTTT
The Adafruit Blog is also a good resource for finding your next project. Check out the Adafruit IO blog posts
here! (https://adafru.it/Bm0)
Want to use Adafruit IO with your computer or a Raspberry Pi running CircuitPython (more on this in Compatible
Hardware)?
Try the Adafruit IO Python Client library. The library includes two clients for accessing Adafruit IO via the REST API or
MQTT.
Want inspiration or project examples? The Adafruit IO Basics Guide Series (https://adafru.it/iDX) have been updated to
use this library and CircuitPython.
Write your code in CircuitPython and connect it to the internet with Adafruit IO!
We’ve written a special library called Adafruit Blinka (https://adafru.it/BJS) to provide the layer that translates the
CircuitPython hardware API to whatever library the Linux board provides.
We’ve got tons of projects, libraries and example code for CircuitPython on microcontrollers, and thanks to the
flexibility and power of Python, it’s easy to get it working with microcomputers like Raspberry Pi or other ‘Linux with
GPIO pins available’ single board computers.
We've updated the Adafruit IO library with usage examples for CircuitPython and Adafruit IO (https://adafru.it/CrX).
We have been testing and building guides using Adafruit Blinka library with the Raspberry Pi.
Suggested Hardware
The Raspberry Pi Zero W offers all the benefits of the full-sized Pi and built-in WiFi. This board is perfect for Adafruit IO
projects which require a Feather-like form factor.
$10.00
IN STOCK
ADD TO CART
The Raspberry Pi 3 Model B+ boasts a 64-bit quad core processor, 5GHz wireless LAN and faster (300mbps) Ethernet.
If you'd like to have a beefier hardware platform to use with Adafruit IO and possibly some more intensive libraries
(such as OpenCV) - this is the ideal hardware platform for your project..
$35.00
IN STOCK
ADD TO CART
This library can use either the REST API or MQTT to access feeds and groups, and send data on Adafruit IO.
If you have PIP (https://adafru.it/ncM) installed (typically with apt-get install python-pip on a Debian/Ubuntu-based
system), run:
This will automatically install the Adafruit IO Python client code for your Python scripts to use. There are usage
examples within the examples folder of the GitHub repository (https://adafru.it/fpg) for use with MQTT, API, and Basic
IO functionality.
Library Usage
We provide usage examples within the examples folder of the GitHub repository (https://adafru.it/fpg) for the REST API
and MQTT.
If you want to download all the examples to your computer, clone the repository in a easy-to-access location.
cd Desktop
Download the latest version of the repository by entering the following command into your terminal:
Then, navigate to the examples folder by entering the following into your terminal:
cd io-client-python/examples/
Note: For all examples in this folder, you'll need to set the ADAFRUIT_IO_KEY and ADAFRUIT_IO_USERNAME before
running the program.
Library Documentation
Documentation for all methods and classes in the Adafruit IO Python library can be found on the ReadTheDocs page
for this project (https://adafru.it/BQt).
We've updated our Adafruit IO Basics Series (https://adafru.it/iDX) to add compatibility for using Adafruit IO and
CircuitPython. These are the best examples if you're looking to get started using these two projects together.
Raspberry Pi Physical
Dashboard (https://adafru.it/Bmy)
Build a dashboard to visualize data on LED displays and
automotive gauges! (https://adafru.it/Bmy)
Writing a Node.js web application? We provide a Node.js client, local server, and TLS tunnel for io.adafruit.com on our
GitHub (https://adafru.it/Bm2). This library can use both the REST API and the MQTT API to access feeds and data on
Adafruit IO.
The library readme on GitHub (https://adafru.it/elj) describes how to install and use the library.
Ruby
If you have a Ruby program you'd like to interface with Adafruit IO, we provide a Ruby Client on our
Github (https://adafru.it/enB). This library wraps the REST API to access feeds and data on Adafruit IO. The library
readme shown on GitHub (https://adafru.it/enB) describes how to install and use the library.
Be sure to also see the examples (https://adafru.it/fpf) included for use with this library.
Go
You can also talk to your io.adafruit.com account using our go client library (https://adafru.it/Bvt). The library requires go
version 1.2 and running tests requires the testify library, which can be installed with:
$ go get github.com/stretchr/testify
Be sure to also see our usage notes (https://adafru.it/Bvt) along with the godoc page (https://adafru.it/Bvu) for full
package documentation.
Your Adafruit IO experience is even better with IO+. The 'plus' stands for MORE STUFF! More feeds, dashboards,
storage, speed. IO+ unlocks more data, more storage, and more feeds than our free service.
Subscribing to Adafruit.IO
Ready to subscribe to Adafruit IO+? Visit your profile page (https://adafru.it/BmD) and click the Upgrade to IO+ button:
IO Plus FAQ
IO+ subscriptions are billed immediately when you subscribe and then monthly or yearly, repeating each month or
year on the same day you signed up until you cancel.
I'm having trouble with billing, or payment processing. Can you help?
Absolutely! If you have a question we haven't answered here or on the Adafruit IO forums, or if you have a question
about your subscription specifically, you can use the Adafruit Contact page to get in touch with our support team
directly.
Is there a way to purchase IO+ for a yearly fee instead of billing monthly?
Sure, we offer a one-year subscription pass in the Adafruit store.
Much like a sandwich, Adafruit IO projects have a lot of layers where things can go wrong. As a result, it becomes
much harder to troubleshoot these types of projects.
There's the hardware (like a Feather ESP8266) layer which brings issues such as "why isn't my motor turning". Your
wiring may be an issue. The code could be incorrect. It could even be a networking issue, which brings us to the next
layer...
Then, there's networking which connects your internet-controlled project to the internet. Problems could arise here
resulting to DNS configuration, port forwarding problems, or your router simply not talking to The Internet™.
There's also The Internet™, and that brings a lot of problems too. Finally there's Adafruit IO, a web service that we built
and support.
...and there could be problems with any layer of this delicious sandwich.
How to Help Out ("I have a problem that's not listed here, what now?")
If your project is not working properly, the Adafruit community is here to help you out. Post up in the Adafruit IO
Forums (https://adafru.it/plC) or chat with Adafruit staff and community members in real-time on the adafruit-io channel
on the Adafruit Discord server (https://adafru.it/BmL).
While we help out and see repeated issues, we'll add them to this page to help others.
Common Issues
My Serial Monitor prints "..." endlessly after the "Connecting to Adafruit IO" message
Your board is not connecting to Adafruit IO, but why? Let's find out:
First, check in config.h that you have the correct IO_USERNAME , IO_KEY , WIFI_SSID , and WIFI_PASS are set
correctly.
Next, we're going to modify the while loop which waits for an IO connection in your sketch. Change the line in the
status check loop from Serial.println(.); to Serial.println(io.statusText());
Verify and re-upload the sketch. If you're receiving a Network disconnected error message, the board is not able to
talk to the internet. Re-check your hardware, connections, and router settings.
If it's still not showing Adafruit IO connected, check the IO status on the Adafruit Status page to make sure the
service is online.
My dashboard is reporting a temperature reading in Fahrenheit/Celsius but I need it in the opposite unit
The dashboard displays information from feeds. Chances are, the sensor you are using is outputting a temperature
in Fahrenheit/Celsius but you need to convert it (in your code) to the opposite unit. Here's some handy pseudo-code
to help out:
I'm using an Feather M0 WiFi (ATWINC1500) and it's not connecting to Adafruit IO.
If you're using a Feather M0 WiFi and receiving a Disconnected from Adafruit IO message in your serial monitor,
you'll want to check two things:
1. Make sure that you have the correct Adafruit IO Keys in your sketch, and that the router/network configuration
is correct.
2. The SSL ceritifcates on your device for Adafruit IO need to be up-to-date. It's hard to check if they're up-to-
date from the device, so we suggest running through the process of adding a new SSL certificate through the
Arduino IDE. You can find the guide for that here.
Board-Specific Issues
ESP8266
The most current HTTP API documentation is available at https://io.adafruit.com/api/docs/. (https://adafru.it/uff) The
source code for our documentation in Open API v2 format is available at https://github.com/adafruit/io-
api (https://adafru.it/BmK).
For questions or comments visit the Adafruit IO Forums (https://adafru.it/plC) or the adafruit-io channel on the Adafruit
Discord server (https://adafru.it/BmL).
If you aren't familiar with MQTT check out this introduction from the HiveMQ blog (https://adafru.it/fpt). All of the
subsequent posts in the MQTT essentials series (https://adafru.it/fpu) are great and worth reading too.
To use the MQTT API that Adafruit IO exposes you'll need a MQTT client library. For Python, Node.js, and Arduino you
can use Adafruit's IO client libraries as they include support for MQTT (see the client libraries
section (https://adafru.it/Boc)). For other languages or platforms look for a MQTT library that ideally supports the MQTT
3.1.1 protocol.
Connection Details
You will want to use the following details to connect a MQTT client to Adafruit IO:
Host: io.adafruit.com
Port: 1883 or 8883 (for SSL encrypted connection)
Username: your Adafruit account username (see the accounts.adafruit.com (https://adafru.it/fpw) page here to
find yours)
Password: your Adafruit IO key (click the AIO Key button on a dashboard to find the key)
We strongly recommend using SSL (https://adafru.it/oSd) if your MQTT client allows it.
If the MQTT library requires that you set a client ID then use a unique value like a random GUID (https://adafru.it/Bxa).
Most MQTT libraries handle setting the client ID to a random value automatically though.
Topics
Adafruit IO's MQTT API exposes feed data using special topics. You can publish a new value for a feed to its topic, or
you can subscribe to a feed's topic to be notified when the feed has a new value. Any one of the following topic forms
is valid for a feed:
Where (username) is your Adafruit IO username (the same as specified when connecting to the MQTT server) and
(feed name or key) is the feed's name or key. The smaller '/f/' path is provided as a convenience for small embedded
clients that need to save memory.
Check out our guide to Feed Naming for the full details (https://adafru.it/oSe).
For example if your username is mosfet and you're accessing a feed called Photocell One (which has a Key of
photocell-one) you can use any of these paths:
In order to reduce confusion, however, we always recommend using the Key to refer to a specific feed or group in
code.
To append a new value to a feed perform a MQTT publish against the feed topic and provide the new feed value as
the payload of the request.
To be notified of a change in a feed perform a MQTT subscribe to the feed topic. When a new value is added to the
feed then the Adafruit IO MQTT server will send a notification with the new feed value in the payload.
You can also subscribe to the parent 'feeds' path to be notified when any owned feed changes using MQTT's #
wildcard character. For example the mosfet user could subscribe to either:
mosfet/feeds/#
mosfet/f/#
Once subscribed to the path above any change to a feed owned by mosfet will be sent to the MQTT client. The topic
will specify the feed that was updated, and the payload will have the new value.
Be aware the MQTT server sends feed updates on all possible paths for a specific feed. For example, subscribing to
mosfet/f/# and publishing to mosfet/f/photocell-one would produce messages from: mosfet/f/photocell-one,
mosfet/f/photocell-one/json, and mosfet/f/photocell-one/csv; each referring to the same updated value. To reduce
noise, make sure to grab the specific topic of the feed / format you're interested in and change your subscription to
that.
PLEASE NOTE: as we adjust which identifiers we use for Feeds internally, the feed updates you receive when using a
wildcard will include but may not be limited to the ones shown above.
If you'd like to avoid the formatted feeds ("/json" and "/csv" topics) but still see all the feeds you're publishing to, you
can use MQTT's + wildcard in place of # . In this case, subscribing to mosfet/f/+ would produce output on
mosfet/f/photocell-one , but not mosfet/f/photocell-one/json .
For publishing feed values the Adafruit IO MQTT API supports QoS level 0 (at most once) and 1 (at least once) only.
QoS level 2 (exactly once) is not currently supported.
Rate Limit
Adafruit IO's MQTT server imposes a rate limit to prevent excessive load on the service. If a user performs too many
publish actions in a short period of time then some of the publish requests might be rejected. The current rate limit is
at most 1 request per second (or 60 requests within 60 seconds).
If you exceed this limit, a notice will be sent to the (username)/throttle topic. You can subscribe to the topic if you wish
This limit applies to all connections so if you have multiple devices or clients publishing data be sure to delay their
updates enough that the total rate is below 2 requests/second.
Data Format
There are a few ways to send data to our MQTT API if you're writing your own client library.
The simplest way to send values to an IO Feed topic is to just send the value. For example, a temperature sensor is
going to produce numeric values like 22.587 . If you're sending to mosfet/feeds/photocell-one you can use the raw
number or a string. That means either 22.587 or "22.587" will be accepted as a numeric value. Adafruit IO does its
best to treat data as numeric values so that we can show you your data as a chart on an Adafruit IO
dashboard and through our Charting API (https://adafru.it/uff).
Sending JSON
JSON can be sent to either the base topic or the /json topic - for example mosfet/feeds/photocell-one or
mosfet/feeds/photocell-one/json . The proper format for location tagged JSON data is:
{
"value": 22.587,
"lat": 38.1123,
"lon": -91.2325,
"ele": 112
}
Specifically, JSON objects must include a "value" key, and may include "lat", "lon", and "ele" keys.
Sending CSV
Alternatively, you can send location tagged data to /csv topics. In this example, that would be the
topic mosfet/feeds/photocell-one/csv instead of mosfet/feeds/photocell-one . Both store data in the same feed. The format
IO expects for location tagged CSV data is VALUE, LATITUDE, LONGITUDE, ELEVATION.
With the example data shown before, that means you could publish the string "22.587,38.1123,-91.2325,112"
to mosfet/feeds/photocell-one/csv . to store the value "22.587" in the location latitude: 38.1123, longitude: -91.2325,
elevation: 112.
Examples
Using a simple Ruby MQTT library and the data shown, all these examples publish the same data to the same feed:
username = 'test_username'
key = 'not-a-real-key'
url = "mqtts://#{ username }:#{ key }@io.adafruit.com"
{
"value": 22.587,
"lat": 38.1123,
"lon": -91.2325,
"ele": 112
}
This lets us store the individual value, 22.587 , and data about the value: its latitude, longitude, and elevation.
Metadata (https://adafru.it/Cwg)!
But what happens when the value you want to send is itself JSON? Good news! There are a few solutions available to
you in that situation.
IO formatted JSON
{
"value": {"sensor-1":22.587,"sensor-2":13.182},
"lat": 38.1123,
"lon": -91.2325,
"ele": 112
}
It's worth noting that because Adafruit IO parses the entire JSON object that you send it, any valid JSON will be parsed
and when it is stored in our system and forwarded to any subscribers, it will be regenerated. The significance of that is
that if you publish JSON data with whitespace, it will be stored and republished without whitespace, because our
generator produces the most compact JSON format possible.
The second way you can send JSON data as a value is to "double encode" it before sending, in which case IO will
treat it as a raw string. If you're using something like javascript's JSON.stringify function or Ruby's JSON.generate ,
double encoding means passing the result of JSON.stringify through JSON.stringify a second time. In this node.js
console example, you can see the difference:
> JSON.stringify({"sensor-1":22.587,"sensor-2":13.182})
'{"sensor-1":22.587,"sensor-2":13.182}'
> JSON.stringify(JSON.stringify({"sensor-1":22.587,"sensor-2":13.182}))
'"{\"sensor-1\":22.587,\"sensor-2\":13.182}"'
The double encoded JSON string can be sent directly through Adafruit IO without interference from our processing
system, because the processing system will not interpret it as JSON. In your receiving code, because the value passed
through includes surrounding double quotes, you have to call your parse function twice to restore the JSON object.
The third way you can send raw JSON data is to just send it. If Adafruit IO doesn't find a "value" key in the JSON object
you send, it will treat the whole blob as plain text and store and forward the data. That means with our example JSON
object, sending the string {"sensor-1":22.587,"sensor-2":13.182} will result in {"sensor-1":22.587,"sensor-2":13.182} being
stored in IO and sent to MQTT subscribers.
If you use the /json or /csv endings on your group MQTT topic, your data should be formatted in JSON or CSV,
respectively. By default, IO expects published values to be in JSON format.
{
"feeds": {
"key-1": "value 1",
"key-2": "value 2",
"key-3": "value 3"
},
"location": {
"lat": 0.0,
"lon": 0.0,
"ele": 0.0
}
}
key-1,value 1
key-2,value 2
key-3,value 3
location,0.0,0.0,0.0
In each payload format, "key-1" represents the respective feed's key and "value 1" represents the value you'd like
to publish to that feed.
For CSV location values, the location is interpreted as `lat`, `lon`, `ele` and `ele` is optional / not required.
Any number of feeds present in the group may be included.
Each value may be either a string or a number.
If any feed key is included that does not already belong to a feed in the group, then a new feed with the given
key as its name will be created.
Subscribing to groups
If you use the /json or /csv endings when subscribing to your group MQTT topic, your data will be formatted in JSON
or CSV, respectively. By default, IO publishes values in JSON format.
{
"feeds": {
"key-1": "value 1",
"key-2": "value 2",
"key-3": "value 3"
},
"location": {
"lat": 1.0,
"lon": 2.0,
"ele": 3.0
}
}
And CSV:
key-1,value 1
key-2,value 2
key-3,value 3
location,1.0,2.0,3.0
It's important to note that you will only receive updated values for the feeds that received new values. That means if
you're subscribed to {username}/groups/example and publish to {username}/feeds/key-1 , the subscription will receive:
{
"feeds": {
"key-1": "value 1"
}
}
It's also worth noting that JSON subscription formats will always receive string type values, regardless of whether a
string or number was published.
In the MQTT protocol, setting the retain flag on a published message (https://adafru.it/Cxv) asks the MQTT broker
(server) to store that message. Then any new clients which connect and subscribe to that topic will immediately
receive the retained message. Retain makes writing basic MQTT-only Internet of Things clients easier, without it, a
client that connects and subscribes to a feed topic has to wait until a new value is published on the feed to know what
state it should be in. In the case of slowly updated feeds, there could be hours between updates which means a
device that disconnects and reconnects (for example, due to power cycling or sleeping) might lose the current value
for a long time between updates.
Among other factors, our scale, Adafruit IO's mix of MQTT & HTTP APIs, the speed at which we’re taking in new data,
Since we don’t actually store data in the broker but at a lower level and can’t support PUBLISH retain directly, we’re
proposing a different solution for the retaining problem: the /get topic modifier.
The way it works is that for any given Adafruit IO MQTT feed or group, subscribe to the appropriate topic, then
add /get to the topic you subscribed to and publish anything to that new topic (our Arduino
library (https://adafru.it/Cxw) uses the null character: '\0' ) . IO will immediately publish, just for that client , the most
recent value received on the feed.
For example, let's imagine we have a device that subscribes to a counter feed: uname/f/counter . If we want to get the
latest value, the /get topic we should publish to is uname/f/counter/get . After connecting, subscribing, and publishing to
the /get topic, we will immediately receive a message on our uname/f/counter subscription with the last value that was
published to the feed.
If you’re using the Adafruit IO Arduino library, you can add /get support to your project in one line of code:
void setup() {
// 1. start IO connection
io.connect();
}
// ....
What about the data that my project generates? Where does it go? What happens to it? Are you going to sell it?
The data your store with IO is yours to manage and control. You can download it all anytime and we will never sell
or give it away to another company. We feel strongly enough about this that we put it in our IoT Bill of Rights.