Internet of Halloween Costumes
For Halloween I had a pretty geeky costume idea - I wanted to build a costume with lights that anyone could control from their own phone.
How it works
An ESP32 microcontroller is used to control the LEDs.
The microcontroller is connected to the internet through my phone hotspot.
The microcontroller will constantly check the communication server for messages. Once it gets a message it interprets the command to figure out what, if anything, it should do.
On the webapp, I have buttons set up for a couple different effects and pressing any of these will send a message to the MQTT server that tells the microcontroller what to do.
Anyone can go to the webapp (which could be hosted on any domain eg. spookyhalloween.com) and control the lights
Because I am a lot more familiar with Python than Javascript, I felt it was easiest to do the heavy lifting through Python so what the webapp really does is calls a postman script that is written in Python and tells it what message to send to the communication server. I happened to use Google Cloud Functions as my "server" for the postman script.
I could definitely have done this without the postman script but it was much quicker for me to do it this way and because this was just a Halloween costume - quick and easy was the way to go.
Demo
Here's a longer demo of the costume:
Next I just add on the light diffusers and we are good to go.
What didn't work
The way you would do this if you could just connect to your home WiFi would be much easier. You wouldn't need an MQTT server - you can just enable port-forwarding on your router and send the HTTP requests directly from the website to your microcontroller. Unfortunately because I had to connect to a phone hotspot this isn't possible. Network providers block incoming requests so any requests sent from the website to the microcontroller over cellular would just by dropped by the network provider. You can buy Machine-To-Machine (M2M) sim cards but that is both overkill and unnecessary for a Halloween costume so mobile hotspot + MQTT it is!
I also tried to use aREST which is a service that would have made this pretty turnkey but their documentation is sparse and their server seems down.
As a side note, one nice thing about this project is I didn't really buy (and waste) any parts, just used parts parts that I had lying around. After Halloween, those parts went back into my bin to be used for other projects. This is why I'm using plain old LEDs rather than using WS2812 I2C controlled LEDs where I would have much fewer wires to connect.