This LUA script is for ESP8266 hardware.
Send motion sensor data through an ESP8266 to a MQTT broker
- Connect to a wifi AP
- Start a MQTT client and try to connect to a MQTT broker, restart until it does
- Publish data to topic
/data/
each time GPIO is trigger (GPIO 2 in this case)
The device subscribe to topic /action/
and wait for those messages :
- Get the current state :
{ mac: #DEVICE_MAC#, action: "STATE"}
- Ping the device :
{ mac: #DEVICE_MAC#, action: "PING"}
- Force to device to send an online message :
{ mac: #DEVICE_MAC#, action: "ONLINE"}
- Get the device IP :
{ mac: #DEVICE_MAC#, action: "IP"}
- Get the device name :
{ mac: #DEVICE_MAC#, action: "NAME"}
- Get the device type :
{ mac: #DEVICE_MAC#, action: "TYPE"}
- Restart the device :
{ mac: #DEVICE_MAC#, action: "RESET"}