Who don’t need a connected button???
Immagine a button who automatically send a message via WiFi to your server and start your heating, or trigger the start of your favorite film on your TV. It’s time to build one!
Materials needed:
- the button enclosure plus a switch and battery holder – I found out a low cost push light in a elegant white enclosure perfect for realize this button (and big enough to not loose in a messy environment)
- the WiFi board – I chosen a very simple and low cost ESP8266
- the light – I used a 8 element NeoPixel bar
- connection wires
Software:
- an MQTT broker for
- optionally an IoT platform like Node-Red
- Arduino IDE for compile and program the ESP8266
When the button is pressed the ESP turn on and try to connect to the WiFi, if the board can not connect automatically switch on access point mode and ask to choose the WiFi and insert the password.
- Once the WiFi is connected the board immediately connect to an MQTT server and the light become blue.
- After the subscription to the confirmation message queue the board send a message on the queue:
-
1iot/T/esp8266/I/<chip id>/D/button/F/json
- When the message is sent the board wait for an answer on the queue
-
1iot/T/esp8266/I/<chip id>/C/button/F/json
- If this message contain the string “OK” the light become green, otherwise red.
When you can see the feedback light (green or red) you can turn off the board clicking the button once again.
Simple!
Permalink
could you post the sketch you used for the ESP8266?
Permalink
You can see a preview of the code here.
Permalink
Thanks!
Permalink
Where did you get the button enclosure? It looks quite good!
Permalink
It’s an indoor battery powered light found in a little shop, originally was operating with 5 white leds … but with 8 Neopixel and an ESP look perfect!