Using the ESP8266-01 module to control a Relay using MQTT
- ESP8266 Boards Manager: http://arduino.esp8266.com/Arduino/versions/2.0.0/doc/installing.html
- AdaFruit_MQTT: https://learn.adafruit.com/mqtt-adafruit-io-and-you/arduino-plus-library-setup
- ArduinoJson: https://arduinojson.org/
- Boards Manager: "esp8266 by ESP8266 Community" (ref: https://arduino-esp8266.readthedocs.io/en/latest/)
- Board Type: Generic ESP8266 (Tools->Board->Generic ESP8266 Module)
- Baud Rate: 115200
Fill the following details for connecting to the WiFi router (at your home):
WLAN_SSID
WLAN_PASS
As this is a Demo project, I have used AdaFruit IO's Feeds as the MQTT Broker to communicate with the Device. (see https://accounts.adafruit.com).
You will need the following details of your AdaFruit IO (AIO) account:
AIO_USERNAME
AIO_KEY
<= This can be accessed/generated from: https://io.adafruit.com/<AIO_USERNAME
>/dashboards (look for the "My Key" tab on the menubar).AIO_MQTT_FEED_ONOFFBUTTON
<= The name of the feed to which the Device should subscribe (would start with something like "/feeds/<FEED_NAME
>").
- Using ESP8266 GPIO0/GPIO2/GPIO15 pins
- How to Use the ESP8266-01 Pins and Leds
- ESP8266 Pinout Reference
- Beginners Guide To The Paho MQTT Python Client
- http://test.mosquitto.org/