Some might say that it belongs to Ron Weasley now, but to me & most of the Harry Potter fans, it’ll always be Dumbledore’s Deluminator. It was designed by Albus Dumbledore, and the first time we get to know about it is when he uses it to Put Out the lights on Privet Drive so he could leave Harry at the Dursleys’ doorstep, unnoticed.
The Deluminator is described in the books as “..looked something like a silver cigarette lighter, but it had … the power to suck all light from a place, and restore it, with a simple click”. A seemingly simple device that had proven extremely useful at multiple occasions. I wondered what it would be like to have my own Deluminator. I am now surrounded by lights that are apparently smart.. so maybe they can learn to cooperate with some magic too. I knew it’ll for sure feel better than having to whip out my phone, then open an app and navigate to the exact lights I want to turn off!
So here’s my take on the Deluminator, the way I imagined it when I read the books- a silver cigarette lighter with light-controlling powers.
- Very importanty: Smart lights/ plugs compatible with IFTTT (I used Wyze bulbs and Wemo plug)
- Adafruit Huzzah32 as the main microcontroller. Chosen mainly for its Wifi+BLE capability & ease of use with Lipo batteries.
- A momentary pushbutton to click away the lights.
- SPDT slide switch for powering the circuit on & off.
- Neopixel mini for showing the captured lights.
- Lipo battery (around 1024mAh is perfect capacity+size).
- Multi-stranded wires, preferably thin. 26 AWG is a good tradeoff between size & current capacity.
- A silver paint/polish of your choice (I used DecoArt’s Metallic Lustre wax)
- Access to a 3D printer or 3D printing service.
- A metal-to-plastic glue (choices here. A fast drying one is preferred).
- Hot glue gun.
- Tweezers, pliers.
- Small metal hinge
- Chrome paint for the flame holder
- A thin metal chain with hooks/end loops (like the ones in a necklace)
- An easily cuttable transparent/translucent material for the phoenix window.
Step 1: What Will This Deluminator Do?
I wanted it to work as similarly as the original one. But muggle tech has limitations so I settled on the following:
- A single button click will put out a single light. Every consequent click will put out additional lights one at a time until all lights are off. Then it’ll start turning the lights back on.
- Sometimes you need to put out all lights at once (or turn them back on at once), so we’ll hold down the button for a couple of seconds in order to do that.
- It’ll know which room you are in and control only that room’s lights. Move to a different one, and you’ll be able to control lights in that room.
What it won’t do:
- Do all the above super fast.
- Control the lights by listening to your thoughts (or will it?)
Step 2: 3D Print the Deluminator
I used Fusion360 to design the models. The models attached have a tolerance of 0.15mm. So the gap between two parts that fit snugly is 0.075mm. I used the 3D printing services of JPatPrints to print my case in PLA. The case snaps together and holds itself quite well. It might need a little bit of sanding when putting the electronics in since those components would very likely have minuscule changes in size.
I gave it a little phoenix logo in the middle, you know, since it’s Dumbledore’s design.
Step 3: Create IFTTT Applets
While the parts are being printed, let’s work on the software. The main idea of this Deluminator is the use of IFTTT (If this then that). It’s a service that connects different, separate internet-controlled things. So, in our case, it’ll connect our Deluminator with our smart lights.
- Go to https://ifttt.com/ and create an account. The free account lets you create 3 applets. Each applet defines one single action. For example, ‘turn all lights off’ can be defined in one applet. You can start with the free account and upgrade to a paid one later if you find yourself needing to create more applets.
- Create applets for controlling your lights using webhooks. The video shows an example of adding Wyze bulbs from my account. You’ll see that you can control many devices other than Wyze bulbs. You can use any of them. Just make sure your ‘If this’ is always a Webhook, since that’s how our Deluminator is going to communicate with your ‘then that’ device.
- Go to https://ifttt.com/maker_webhooks and click on ‘Documentation’. Note down the IFTTT key shown. This will be used later in our HTTP requests. Don’t share it anywhere. It’s your personal key.
Step 4: Breadboard Testing!
It’s always a good idea to test out your electronics & code on a breadboard before committing to soldering everything. Follow the fritzing breadboard diagram or the schematic above. Note the little trick I’ve used with the slide switch (on/off switch). Since we need the battery terminal connected to the board as well as the neopixels, we’ll use the slide switch’s extra terminal, and connect it to the middle one in such a way that in the correct/on position, the switch connects our battery to both the other terminals, while in the off position, the battery is disconnected.
The neopixels are connected to VBAT & GND, and take signal in on pin 14.
The tactile switch is connected to pin 21, which we’ll set up as input, pulled high internally.
Step 5: Upload Code to Your Arduino Board and Test IFTTT Setup
Download or clone the code from: https://github.com/sanni-t/Deluminator
As mentioned, we’re using Adafruit’s Huzzah32 microcontroller board. It is feature-packed with Wifi & BLE capabilities as well as Lipo battery support, all on a very small form factor. That said, the esp32 that’s at the core of the board is still in its infancy (at least in the hobbyist/ open source community) so the documentation is bit sparse and libraries have some known issues. But, it’s not a deal-breaker and still has a lot to offer. (All this to say that the code might feel a little clunky but it works.).
NOTE: Follow instructions here to install Huzzah32 support in Arduino.
Here’s what the code does in a gist:
- On startup, it initializes the gpios, neopixels, wifi & BLE objects. It’ll blink white once initialization is done.
- Then it’ll connect to wifi using the credentials you provided, and fetch current time from an NTP server (useful for connecting to the server). Once this is done, it’s ready to Deluminate and will blink purple to let us know that.
- Upon every click, it’ll scan for BLE devices to determine its location if it has been a while since last scan. Using this location information, it’ll turn the lights on/ off depending on whether you did a regular click or a long press.
- When it turns lights off, it’ll show that it has ‘grabbed lights’ by turning the phoenix light on. Upon ‘returning’ of all the collected lights, the phoenix light will turn off.
To make the code work for you, you’ll need to make the following changes:
- Rename the deluminator_secrets_sample.h file to deluminator_secrets.h and add your wifi credentials and IFTTT secret key obtained in step 3 above.
- We’ll be connecting to IFTTT using HTTPS, so we’ll need its rootCA certificate in order to verify authenticity. Follow these instructions to download the `.pem` certificate file for https://ifttt.com/ and copy its contents to `IFTTT_ROOTCA_CERT`. Note formatting of the string and the addition of newline endings.
- In `deluminator.h` (update: this file will be renamed to `deluminator_defs.h` in newer version), update the settings shown in the screenshots above.
- Most important- add the `LightInfo` arrays for your own setup. Add the correct number of rooms and lights per room. Use the appropriate webhook event names you have created on ifttt.
- Add the MAC addresses of the BLE tags you have. The tags should have their MAC addresses noted somewhere but if they don’t, you can use the BLE_scan example code in the esp32 Arduino libraries to find BLE devices you have and get the info.
- In `deluminator.ino` initialize RoomLights objects using your LightInfo objects. Also update the names in the BLE scan callback function as shown in the screenshots above.
NOTE: The size of this code is quite large so make sure you select the ‘No OTA (Large App)’ partition scheme from Arduino-> Tools.
Upload to your breadboard setup and verify execution using the serial monitor.
Step 6: Sand, Paint, Finish the 3D Prints
I wanted to make the deluminator a little shabby & worn, very much like most things in the Wizarding world. But you could totally make it look absolutely neat.
- Sand the prints using 320-800 grit sandpaper.
- Then apply a layer of white pearl acrylic paint. This step might not be necessary but I liked the smooth & shiny texture it provided. Mainly, it helped adhere the silver wax to the case.
- For extra smoothness, sand a little between the coats of paint.
- Also recommend painting the inside of the case in some dark color. I went with gray but you could even go with black. It helps stop the light inside from being seen through the plastic.
- Once dried, you can either apply the silver wax now, or after assembling everything.
- Use the chrome paint on the flame holder. You can add a base layer of black paint to it as well.
- Decorate to your heart’s content!
Step 7: Put the Electronics Together
Follow along the video for tips on soldering and assembling the electronics (instructions in captions)
- Use multi-strand wires that are thinner than 24awg since it’s quite cramped inside the deluminator.
- Remove the battery holder on the board so we get a pretty flat profile of the board.
- Once soldered, test that everything works okay still and then seal the exposed solder joints using hot glue. Glue sparingly though, otherwise you’ll have difficulty fitting it all in.
- Carefully put the electronics inside. Use hot glue/ tape to hold things together if required. Assembling tiny things in a cramped space is not easy. Make tweezers and patience your friends.
Step 8: Have Fun!
- The BLE scanning adds quite a lot of delay in accessing the lights. So if you aren’t concerned about controlling lights in multiple rooms, you can simply take that part out.
- HTTPS is also slightly slower but it’s not that noticeable. So I would recommend sticking with https since you’ll be sending sensitive data to IFTTT.
- There has to be a way of making multiple requests faster.
- The 3D model has some scope for improvement too, esp with the top cap design.
It’s not THE Deluminator, but close enough? 🙂