One day I was walking around town and I came across this brilliant looking, LED backlit Autobot logo. I thought instantly "I want to hack this" and eventually I decided that I wanted it to be a notification system for all sorts of things. I recently got my hands on some ESP8266 development boards loaded with the nodeMCU firmware. Among other things, this board can connect to or host a WiFi network and allows you to create and run lua scripts to control it's functionality.
Lets get making!
Step 1: Gather Your Supplies
For this instructable, you will need (included are Amazon links though you may do better on Aliexpress):
You will also need the following:
- Soldering Iron
- Wire stripper/snips
- Dupont cables/several lengths of wire for connections
Step 2: Disassemble the Light
First you'll need to disassemble the light. There are 6 small Philips screws holding the back plate onto the unit. Remove these carefully and set aside for later. The two sides can then be separated. Inside you will find the power connector at the bottom, with the centre positive supply connected to the switch at the top, and finally three white LEDs.
The LEDs can be removed by snipping the cables coming from the power socket and the switch, and then carefully using a blade to push them off of their plastic pillars. Save the LEDs for another project - they sure are bright!
Step 3: Add Your Circuit
I've opted for simplicity at the moment and have arranged the NeoPixel stick vertically in the centre. The three connections are GND, VCC and DIN. These should be connected to GND and 3.3V on the development board, while DIN should be connected to the D6 pin.
I've taken power from the existing cables by stripping the lead, tinning it, and then connecting the dupont cable. The cable at the power socket connects to GND, while the switch should connect to the VIN pin on the development board (do not connect to 3.3V as this will blow the ESP chip)!
Step 4: Write the Code!
I've used the Esplorer development environment for this project. I've attached some example code to get you going.
The web server on the development board will respond to any request received on port 8080 (this port can be configured in the code). I've got a static IP and have set up port forwarding on my router to forwarded the request from IFTTT to the device's IP.
To set up integration with IFTTT, create a new recipe with whatever you'd like as the trigger. For the action, use the Maker channel, and enter your home IP address as the destination, with port 8080 at the end.
Step 5: Test It Out
Once we have the code working, you can easily test the device by going to http://yourhomeipaddress:8080
Now that it's working correctly, you'll want to create a new file called init.lua to run the notification script on reboot. Otherwise you'd have to keep opening it up!
The file can be nice and simple, such as the following:
I prefer to use a timer to load the file, just in case it gets caught in a loop (I don't want to have to keep flashing the firmware):
tmr.alarm(0, 100, 0, function() dofile("NotificationSystem.lua") end)
This will give the device 100 micro seconds to pause execution of the script. Just enough time for it to pause and overwrite the init file, for example!
Save the line of code above into a new file on the device called init.lua and reboot. It should go straight into the program
Step 6: Thinking of the Future
Obviously there are several improvements that can be made. Here's my list for the future:
- Move everything onto a PCB at the bottom
- Use a raw ESP module so I can get my development board back
- Add in new light modes and a button or sensor to change between them
- Add different forms of notification flash, with triggers based on the URL called or JSON in the request
- Add a piezo speaker to produce sound along with the notifications
- Write another lua file to bootstrap the notification program and download any changes I make remotely