Tim is currently doing research in Internet of Things (IoT). His desire to spread the concept, ideas, and experience of IoT.
Adafruit IO (AIO) platform provides an easy way to develop Internet of Things (IoT) applications. Since AIO supports MQTT protocol, it makes communication faster. AIO also provides graphical interface to create widgets for your devices.
- NodeMCU Development Board X 1
- LED X 1
- Resistor (220 Ohm) X 1
- Male-To-Male Jumper Wires (Optional) X 2
- Breadboard (Optional) X 1
Connect LED to NodeMCU pin 'D6' using 220 Ohm resistor as shown in following figure.
Please follow the instruction given under 'Environment Setup' section in my another tutorial by clicking this link to set up the environment for the tutorial.
You need to upload following code to NodeMCU using Arduino IDE. Please remember to update your WiFi SSID and password on lines 7 and 8 and Adafruit IO username and API key in the lines 14 and 15. Please follow the instructions below to retrieve your Adafruit IO Key.
Create an account on AIO and sign in using your credentials.
After login get the AIO Key by clicking the link provided at top right to retrieve username and key for Arduino code as shown in following figure.
Use this key in your Arduino code and upload the code to NodeMCU.
Now let's build the user interface on AIO platform. First you need to create the dashboard. If you have already built a dashboard from my tutorial Control Led Brightness using Adafruit IO Platrorm, then you can use same dashboard otherwise create a new one. To build the dashboard, Click on Actions->Create New Dashboard and name your dashboard as show below.
Your dashboard named 'AIO_Controller' will be created.
Click on dashboard name to open following screen where you can create widget to control your LED.
Click the '+' button to create a new block. This block will be your widget, an Of/Off button in this tutorial.
From the 'create new block' dialog box as in the following figure, choose 'Toggle'.
Now create a feed named 'onoff' as following. This feed is used in your arduino code line 33, therefore they must be the same. Actually is the MQTT topic.
After creating the feed, select the feed for the block you are creating and click next.
It will open 'Block setting' dialog box. Provide settings as following.
Please note that I left the button on text as 'ON' and button off text as 'OFF' because I am using this text in my code. You can use anything or even 1 and 0, but you have to modify your Arduino code accordingly. This the the message that will be published on MQTT topic.
Now click create block button at bottom.
Your widget will be created as following which you can use to control the LED.
Timothy Malche (author) from Manipal University Jaipur, Jaipur, Rajasthan, India on July 31, 2020:
pdlwaste solutionsllc from Edgerton,USA on July 28, 2020: