Spelunking into actual IoT Development – Part 1 – The Lamp in the Corner

So you may have read my previous post about my adventures in controlling my ceiling fan with my phone, computer, watch, etc using HomeKit. I decided my second project would a simple lamp.

For my controller, I chose the ESP-32 originally. It’s cheap, has wifi, and has a good reputation. All of the reliable libraries that implement the HomeKit protocol are proprietary and expensive. I’m on a student budget, so that’s not an option. However, there is a pretty good library built by maximkulkin hosted on Github.

Now, even with that good reputation, I had some difficulties with the ESP-32 that I’ll get to later. Because I am going to be putting this in a lamp which gets its power from mains, I needed a way to get a 5V power supply. So, I took apart one of those USB wall adapters and pulled out the circuitry so that I could use it as my power source. Then, I spliced the wires of the lamp on the inside, and connected them to that circuit. Then I got a relay, and wired the live wire from the wall into the common terminal of the relay and the live wire going to the lamp to the normally open terminal. Then, I wired the 5V from the power supply to the ESP-32’s voltage input GPIO pin and to the VCC pin of the relay.

I found the esp-homekit-demo repository on GitHub from which I modified the LED example to work as a lamp, and U connected that GPIO pin to the input on the relay.

Et voila! I had a lamp controllable from my phone!
Wait. It stopped working exactly two minutes later? Okay, okay.
It turns out that the library I’m using has an issue on the ESP-32 where the MDNS broadcasts don’t work quite right. Since then, I’ve only been using ESP-8266s as they do not share this issue and are actually cheaper. The projects later in this series will all use the ESP-8266.
Thanks for reading!

Was this post helpful?

Leave a Reply

Your email address will not be published. Required fields are marked *