Some nodemcu based to run sonoff wifi enabled plugs through MQTT
Lua
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 4 commits ahead, 21 commits behind elric91:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
LICENSE
README.md
broker.lua
config.lua
init.lua
ota.lua
page.tmpl
switch.lua

README.md

nodemcu_sonoff

Some nodemcu based code to run sonoff wifi enabled plugs through MQTT

This version is prepared to work with PiDome MQTT plugin

  • config.lua : as it name implies
  • init.lua : runs the wifi connection and launches ota and broker modules
  • ota.lua : web server (http) and over the air updates module
  • switch.lua : code to switch on the relay
echo -e "**LOAD**\npage.tmpl" | cat -  page.tmpl | socat -u stdin TCP:ipaddress:80 -- updates the page.tmpl file on device
echo "**RESTART**" | socat -u stdin TCP:ipaddress:80 -- restart esp8266
  • broker.lua : mqtt client module
mosquitto_pub -h "myMQTTserver" -t "/myMQTTpath/power" -m "on" -- turn plug on
mosquitto_pub -h "myMQTTserver" -t "/myMQTTpath/power" -m "off" -- turn plug off

Sonoff pin layout and GPIOs stolen from Pete and the community
Wifi connection loop stolen from marcelstoer/wifi-watch.lua
nodemcu firmware generated with Marcel's NodeMCU custom build machine (just add MQTT to the standard module selection)