This is a small project I made in a day that allows me to control my lights with my voice. My bed is on the opposite side of the room from my lights, and I hate getting into bed, deciding I'm tired and going to sleep, but then having to get out of bed to turn the lights off.
I created this project so that I can use my Alexa to control my lights. Initially, I planned to use voice2json for offline voice control, but it had too many issues. Alexa offers better voice recognition, so I switched to using it instead.
All services that control the lights communicate through a webserver, which is run via a Cloudflare tunnel since I cannot open ports on the university network. The Raspberry Pi (Pi) communicates with an ESP32 using a cable and serial, sending commands. The ESP32 then uses ESP-NOW to transmit the commands to another ESP32 running the hardware that switches the lights.
- Voice control of lights using Alexa
- Webserver integration via Cloudflare tunnel
- Communication between Raspberry Pi and ESP32 using serial and ESP-NOW
- Basic integration with voice2json (not supported, may require tweaks)
- Ensure you have an Alexa device set up and connected to your home network.
- Follow the instructions to integrate your lights with Alexa.
- Optionally, set up voice2json (though it's not officially supported and may need tweaking).
- Run the webserver through Cloudflare Tunnel for secure communication.
- Connect the Pi to the ESP32 using a serial connection.
- Set up the ESP-NOW communication between the ESP32s to control the hardware that manages the lights.
Use voice commands with your Alexa device to control the lights. For example:
- "Alexa, ask Cosmos Controller to turn off the lights" (All Lights)
- "Alexa, ask Cosmos Controller to turn on the lights"
- "Alexa, ask Cosmos Controller to turn on the left light" (My Light)
- "Alexa, ask Cosmos Controller to turn on the right light" (My Roommate's Light)
- "Alexa, ask Cosmos Controller to turn off the left light"
- "Alexa, ask Cosmos Controller to turn off the right light"
The original plan was to use voice2json for offline voice control, which required the microphone to be near my bed for better voice capture. This setup necessitated using ESP-NOW to transmit the data from the Pi by my bed to the ESP32 controlling the lights. Now that I'm using Alexa, the Pi could technically be mounted directly on the device to control it, but since this setup works well, I decided to keep it as is.
- The voice2json integration is not supported and may require tweaks to work.
- Alexa provides a much better voice recognition experience.
- You may need to tweak the 3D files and code to adapt this project to your own light setup.
This is me posting the project to contribute to my profile. If you want to build it yourself, you'll likely need to adjust the setup for your specific environment, but it's a nice starting point. This project is just a simple way to control lights, it's NOT meant to be a full-fledged home automation system. It is not meant to be easily modified or adapted to other setups. It's just a fun project I made in a day.
Another project I made that allows you to unlock your door using your phone IS much more polished and complete. You can check it out here. This has an integration to turn on the lights when you unlock the door, so it's a nice companion to this project.