By: BEEVA Research Lab
# Copy the configuration file
nodemcu file add config.lua config.lua
# Verify the file is copied
nodemcu file ls
# See the configuration file
nodemcu file cat config.lua
require "config"
--Your program
print(THING_ID)
...
# Client
apt-get install mosquitto-clients
# Broker
docker pull eclipse-mosquitto # Docker image
docker create -p 1883:1883 -p 9001:9001 --name iot-test-mqtt eclipse-mosquitto # Create image
docker start iot-test-mqtt # Start the container
docker stop iot-test-mqtt # Stop the container
docker rm iot-test-mqtt # Delete the container
# Terminal A
mosquitto_sub -h localhost -p 1883 -t '#' -v
# Terminal B
mosquitto_pub -h localhost -p 1883 -t "topic/subtopic" -m "This is a message"
docker start test-mqtt
mosquitto_sub -h localhost -p 1883 -t '#' -v
# Press the NodeMCU button and see the message
# Switch the LED on
mosquitto_pub -h localhost -p 1883 -t '<THING_ID>/LED' -m "1"
# Switch the LED off
mosquitto_pub -h localhost -p 1883 -t '<THING_ID>/LED' -m "0"