This project was used as a demo platform for a technical talk on MQTT and is dependant on the following related resources:
This repository serves as the primary readme for the talk.
Please refer to the following resources
emqtt Broker emqtt.io
Once emqtt is downloaded and launched, following the directions on the site, you can get to the emqtt dashboard by going to http://localhost:18083/
and entering user name: admin
and password public
as defaults.
Please refer to the dashboard repository iot-led-dashboard for more information.
IMPORTANT: This project uses Platformio's ability to "inject" defines based on the [env:...]
build-flags argument for modifying the main.ino
for multiple devices; including uploads. So, if you're a little unfamiliar with this, you'll see what appears like a constant (ie SET_LED_TOPIC_DEF
) used in main.ino
that doesn't seem to be defined. Just review the platformio.ini
for its definition based on a particular [env:{device name}]
set of defines. So, for your own purposes, modify the platformio.ini
build flags to set defines as appropriate. There are defines for wifi settings, MQTT broker settings, and MQTT topics.
This program is designed to:
- connect to a predefined/hard-coded wifi SSID as defined in the
platformio.ini
file using the ESPHepler library - connect to a predefined/hard-coded MQTT broker s defined in the
platformio.ini
file; also using the ESPHepler library - Detect a button press to ramp a pot (short for potentiometer) value up and down; cycling as long as the button is pressed
- Listen for pot and led value set from predefined/hard-coded topics as defined in the
platformio.ini
file and update the local system as appropriate - Send the pot value to a predefined/hard-coded topic as defined in the
platformio.ini
file when the value changes either by button press(es) or MQTT topic set(s) - Send the led value to a predefined/hard-coded topic as defined in the
platformio.ini
file when the value changes by MQTT topic set(s)