Tim is currently doing research in Internet of Things (IoT). His desire to spread the concept, ideas, and experience of IoT.
Adafruit IO platform provides MQTT services and a dashboard to create stunning Internet of Things (IoT) and M2M applications. This platform supports variety of hardware and is very flexible and easy to use solution for building connected applications.
- 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 the LED to NodeMCU pin D6 as shown in following diagram. D6 is the PWM pin which is require to control the LED.
Now open your Arduino IDE and Install libraries as per instructions given in following links:
After all the required libraries are installed, type or copy paste following code and compile and upload it to NodeMCU.
In the above code, please update your WiFi SSID and password on lines 6 and 7. You will also need Adafruit IO username and API key in the above code lines 13 and 14. Please follow the instructions below to retrieve your Adafruit details.
Go to Adafruit IO Platform and create your account. After you have created you account, sign in to your account.
After login get the Username and API Key for the Arduino code above. To get this click on AOI Key link on top right as shown in following image and copy your details to your Arduino code.
After you have compiled and uploaded the Arduino code on NodeMCU, access the AIO account again and create a dashboard which will contain the slider control to control LED brightness. To create dashboard, click on Actions->Create New Dashboard and name your dashboard as show below.
Your screen will now look as following.
Now click on your dashboard link 'AIO_Controller' on the AIO Platform. You will see screen as in following figure.
Click on '+' button to create a new block.
Clicking the '+' button, following screen will be shown.
Click on slider control.
The next dialog box 'Choose Feed' will be shown. Here you can choose previously created feeds for your control or you can create new feed. In this example we are creating new feed since we do not have any feed right now. I have created a feed named 'brightness' as shown in following figure.
Type the name of feed 'brightness' and click create button. You will see following screen. Please note that this feed should be same as I have described here because I am also using it in Arduino code line 30. This is the MQTT topic to which your IoT Node subscribe therefore it should be same. If you wish another name, then please change at both places.
Choose the feed 'brightness' and click next button.
Clicking the next button you will see 'Block settings' dialog box where you have to specify certain settings. Do it as shown in following figure.
And then click create block button.
Your interface is now created as shown in following figure.
You can use this slider control to control the LED attached to your NodeMCU board remotely using the MQTT protocol.