This is the enclosure for a simple Alexa lightswitch.
It uses an ESP32 with two buttons (on and off), as well as an LED on the top that lights up when a button is pressed.
You can find the code for the project on GitHub: https://github.com/manolol1/lightswitch
You will need:
- ESP32 (or similar compatible device)
- Power supply and cable for the ESP32
- two buttons (the diameter of the holes for the buttons is 14mm. You might need to change that if you have other buttons.)
- LED (optional)
- resistor for the LED (if required)
- some cables (jumper wires)
- soldering equipment (optional, might be helpful to shorten the wires)
- a computer or laptop (for flashing the ESP32)
- some basic knowledge about programming microcontrollers and PlatformIO would be helpful.
Instructions:
Feel free to do things differently, this is just how I did it.
- Get the required parts and change the diameter of the button holes in Onshape if required.
- Print the enclosure. I printed it with the front (where the buttons are) on the buildplate. I only needed support for the screw holes and for that little part that keeps the lid in place.
- Print the lid and make sure it fits into the enclosure. It might be a bit difficult to slide it in, but I didn't want to add extra “rails” on the side to avoid more support.
- Download the source code from GitHub and open the project. I used Visual Studio Code with PlatformIO for this.
- In the code, you see some variables you need to edit. Let's fill in the WiFi credentials first!
- Next, you should start assembling the parts. I already set the pins for the buttons and the LED, so you could just use these. If you want to use different pins, make sure to change the pin numbers in the code!
First, I would recommend mounting the buttons and the led into the enclosure.
Then, connect or solder the cables of the buttons to the corresponding pins on the ESP32. Usually, one cable is connected to the data pin (specified in the code) and another one is connected to ground (GND). You might need to do some research for your buttons.
- Also connect the LED if you have one. Make sure to add a resistor if needed!
- Now, you need to get the links for controlling your lights. I used an Alexa Skill called “URL routine trigger” for this. With this skill, you can create Alexa routines that are triggered when a link is “opened”.
- Fill in the links in the code.
- Now, let's flash the ESP32 and test if everything works! Make sure that your WiFi credentials, pins and links are filled in correctly!
- If it works, congratulations! You can now mount the lightswitch wherever you want or modify it as you please.
If you need help, feel free to contact me. I'd love to help you.
I'm terrible at writing instructions, so I'd really appreciate constrictive criticism!
I made this model with Onshape. If you want to make any changes to the model, you can do that here.
Tags
The author marked this model as their own original creation.