In this article we are going to learn how to use Adafruit MQTT broker and turn ON/OFF ESP8266 LED. And if you want to know how to install Adafruit and how to use it then read this article till the end. I hope this article help you in your project.
Requirement for this project is
- ESP8266 board
- Adafruit MQTT broker
- and rest of the work is done by coding.
Adafruit MQTT broker
We need to create an account on Adafruit. click on this to open Adafruit Website. If you want know what is the Adafruit MQTT broker then Click on this link. A step by step tutorial for beginner
Follow the following steps to create an account on Adafruit MQTT broker.
- Create an account by click on sign in
- Create an account here or if you have already an account just sign it.
- After that, this window will appear on your screen. Click on the Actions>>Create a New Dashboard
- After that a new window will appear on the screen. You can create dashboard name here. Give a friendly name. Description is optional you can either skip it or fill it. Then click on create.
- This will create a new dashboard by using name workstation.
- Now you can create block by using the plus sign. Then click on this plus sign. A new window will pop up on your screen.
ON/OFF— ESP8266 Board LED by using Adafruit MQTT Broker
Here you have got a lot of option but for this project we need ON-OFF block. This is very reliable you can change it according to you project.
- Choose your feed name. In this project we name it as “onoff”. And then click on create. And follow the next step.
- After that you can modify your block. Create a block title and button name Here:
- 1 means ON
- 0 means OFF
Then click on create block.
- Finally, you successfully create a block in Adafruit MQTT Broker. You can make changes whenever you like by clicking on setting button.
- Now move on the coding.
Copy the given code.
#Here is code
You should add network credentials. Type your Wi-Fi router name and password.
Next you need to insert block user name and regenerate key. You get it through Adafruit. just click on Adafruit IO Key on the top right corner f the screen.
Copy these two keys and put it in your code.
This part is subscribing on the interested topic by using payload. Low means power off and high means power on.
Finally Upload the code.
As you can see that when we click on the 0 LED turn off and when we click on 1 the LED turn on.
This is the basic phenomena of how to turn LED OFF and ON y using Adafruit MQTT broker.
Let us know if you have any issue related to this topic in the below comment section. We’ll feel grateful to solve your issue. Thank you!
nodemcu esp8266 library for proteus
ESP8266 Board LED by using Adafruit MQTT Broker