Introduction: Lighting the Way: How to Make Your Own ESP32 Door Key Light

Ever found yourself fumbling for keys in the dark? I did too, until I decided to shed some light on the situation. Enter the DIY Door Key Light, a bright idea born from frustration and crafted with creativity. In this post, I'll guide you through the process of building your own illuminating solution using ESP32 microcontroller. Get ready to light up your entryway and say goodbye to dark door dilemmas!

Supplies

  1. Electronics:
  2. Custom PCB ( check step 3)
  3. ESP32 Wroom 32D
  4. AMS1117 3v3 ( voltage regulator)
  5. WS2812B (neopixels)
  6. SMD Resistors ( check step 3).
  7. SMD Capacitors.
  8. Lithium Ion cell ( 18650).
  9. TP4056 ( charge control module).
  10. Tools.
  11. Reflow Soldering machine ( optional)
  12. Soldering Iron.
  13. 3D Printer ( or 3D printing services.)
  14. Misc.
  15. Command Strip (Velcro).

Step 1: Watch the Video

Whether you're a visual learner who prefers following along step by step, or you like to skim through instructions at your own pace, we've got you covered. If you're eager to get your hands dirty right away, keep watching the video for a detailed tutorial. But if you prefer to take it slow and absorb each step, feel free to continue reading below. No matter your learning style, we're here to guide you through creating your own illuminated doorstep masterpiece!

Step 2: Choice of Components

Let's expand on each component:


1. Main Controller: ESP32

  • I went with the ESP32 microcontroller because it seemed like the perfect brain for my project. It's got this awesome dual-core processor and built-in WiFi and BLE, which felt like overkill but also kinda cool. Plus, it plays nice with the Arduino IDE, so programming it was a breeze. Oh, and the fact that it supports BLE means I can add fancy features later on if I want to control it from my phone or something.


2. LED: WS2812B

  • When it came to lighting up the keyhole, I knew I needed something bright and colorful. That's where the WS2812B LED, or Neopixel as some folks call it, came in. These little guys are like magic – each one can be controlled individually, so I can make all sorts of cool patterns and effects.
  • Another thing about Neopixels is that they're popular, and many people have written drivers for them, so I don't have to worry about it. Plus, they're super efficient, which is perfect for running off a battery.


3. Wireless Connectivity: WiFi Support

  • I decided to throw in WiFi support because, well, why not? It opens up a whole world of possibilities for future upgrades like OTA.
  • I added a special button for WiFi setup and an LED indicator to make connecting a breeze. Who knows, maybe I'll integrate it with my smart home setup down the line or control it from my phone when I'm feeling lazy.


4. Sensor: Ultrasonic

  • Originally, I thought about using a light sensor, but they can be a bit finicky, especially in different lighting conditions. So, I went with an ultrasonic sensor instead. It's reliable and accurate, which means it'll always know when someone's getting close to the door. No more fumbling around in the dark trying to find the keyhole!


5. Power Source: 18650 Lithium-Ion Battery

  • For power, I went with a trusty old 18650 lithium-ion battery. They're rechargeable, so I don't have to worry about constantly buying new batteries. Plus, they've got plenty of juice (around 3000mAh) to keep the light running for a long time. I hooked it up to a TP4056 charge control module, so recharging is as easy as plugging in a USB-type C cable.


With these components handpicked and tailored to my needs, the DIY Door Key Light isn't just a solution to my dimly lit doorway – it's a reflection of my creativity and ingenuity.

Step 3: PCB Design

Alright, folks, buckle up because we're diving into the heart of this project and my personal favorite part.

After countless hours of brainstorming, tweaking, and maybe a few frustrated sighs, I finally had a blueprint that screamed "Eureka!" (or maybe that was just me yelling in excitement). Armed with EasyEDA ( a free PCB design software) and a vision, I set out to bring this bad boy to life.


  • I kicked things off by selecting the components that would breathe life into my creation. The ESP32 Wroom took center stage, while buttons, LEDs, and all the bells and whistles found their place on the canvas.
  • Now, let's talk layout. It's like solving a puzzle, but with electronic bits instead of jigsaw pieces. I made sure everything fit snugly while leaving room for flexibility – you never know when you'll need to swap out a component or two!
  • Future-proofing is key, my friends. I added a handy female header pin for the ultrasonic sensor because, let's face it, who wants to wrestle with alignment issues during assembly? Ain't nobody got time for that!

Shoutout to the Sponsors:

Big thanks to NextPCB for hooking me up with the PCBs! NextPCB is a -Reliable Multilayer PCB Manufacturer. NextPCB is one of the most experienced PCB manufacturers in Global market, and has specialized in the PCB and assembly industry for over 15 years. Their free DFM tool enable makers like us to review our design files with one-click analysis. Without their support, this project would've been stuck in the idea phase forever. Virtual high-fives all around! They are having a free PCB assembly campaign, try it now and grab the discount!


With the design locked and loaded, I sent it off into the digital ether and waited (im)patiently for the PCBs to arrive. And let me tell you, the excitement was real when that package finally landed on my doorstep!

Step 4: Solder the Components

Now, folks, we're getting into the nitty-gritty – the soldering phase!

Let me paint you a picture: a small PCB, cramped with SMD components, and me, armed with nothing but a trusty soldering iron and nerves of steel. Yep, it was a tight squeeze, to say the least!

  • With space at a premium, I had to get creative with component placement. SMD components were the name of the game here, making every solder joint a delicate dance of precision.
  • Now, I'll admit, I wielded my soldering iron like a pro (or at least I pretended to). Sporting a narrow tip, it was my weapon of choice for this intricate operation. But let's be real – the dream team for this job would've been a stencil and some fancy wave soldering or reflow soldering equipment. Alas, a DIYer can dream, right?
  • If you're gearing up for your own soldering adventure, don't sweat it! I've got your back. Check out this handy article by @voltlog for some tips and tricks that might just save your bacon (or at least prevent some burnt fingers).
  • Got a burning question about soldering? Wondering how to tackle those pesky SMD components like a pro? Don't hesitate to hit me up – I'm here to help!


So grab your soldering iron, folks, because we're about to turn these tiny components into a masterpiece of electronic wizardry. And remember, a steady hand and a dash of patience go a long way in the world of soldering!

Step 5: Firmware

Here is the Code for this project:

https://github.com/SnippetsOfAkshay/DIY-Keyhole-Light


In-Circuit Testing Firmware:


After soldering together a symphony of components on our PCB, it's only natural to want to see if everything is firing on all cylinders. So, buckle up and join me on this testing adventure!

  1. Ultrasonic Sensor: First up on our testing checklist is the trusty ultrasonic sensor. This little gadget is our eyes and ears, helping us detect when someone's getting up close and personal with our door. With a few quick measurements and a bit of tinkering, we'll make sure it's primed and ready to go.
  2. WiFi LED: Next, let's shed some light on our WiFi status. Our handy LED indicator is like a beacon in the night, letting us know when we're connected to the digital world. A quick flicker here and there, and we'll be ready to surf the web like pros.
  3. WiFi Button: Ah, the WiFi button – our gateway to connectivity nirvana. With a simple press, we can initiate the magical process of connecting to the interwebs. Let's give it a few clicks and ensure it's doing its job with finesse.
  4. NEOPIXEL LED: Last but not least, it's time to unleash the mesmerizing glow of our Neopixel LED. This little gem is the pièce de résistance, adding a splash of color and flair to our creation. With a rainbow of hues at our fingertips, let's make sure it's ready to dazzle.

Once we've run the gamut of tests and confirmed that each component is pulling its weight, we'll be one step closer to firmware nirvana. So, grab your multimeter and your favorite testing tunes – it's time to make some magic happen!

QUICK TIP: Most of the ESP32s don't have an Arduino Bootloader, which means we won't be able to directly upload the code on ESP32, for which I have made a custom connector, refer to the diagram attached in this step for connections.

Find the "Boot" header on your connector.

Press and hold "Boot."

While holding "Boot," press "Enable" and then release both.

I know this process is kind of annoying but bare with me guys its gonna be worth the effort.


Main Firmware.


Alright, let's talk about the main firmware!


We want our Door Key Light to greet guests with a mesmerizing display before guiding them to the keyhole with a steady glow. To achieve this, we'll need a custom animation pattern that captures the essence of hospitality and functionality.

  1. Animation: To bring our vision to life, I turned to the FASTLED animator website. With its intuitive interface, I whipped up a custom green animation using frame-by-frame design. By specifying the number of LEDs, frames, and frames per second, I tailored the animation to fit our Door Key Light perfectly.
  2. Fine-Tuning the Parameters: Once the animation was complete, it was time to fine-tune the parameters for our specific LED setup. With a few tweaks and adjustments, I ensured that every pixel would dance to the beat of our carefully choreographed animation.
  3. Proximity: Now, let's talk distance. Using a combination of low, high, and low trigger pulses sent at precise intervals to the sensor's trigger pin, we can calculate the distance to the nearest object. With a bit of math and the speed of sound equation, we're able to pinpoint the distance in centimeters.
  4. Adding Deep Sleep Capability: But wait, there's more! We're not just about dazzling animations – we're also all about efficiency. That's why we're incorporating deep sleep capability using the ESP-IDF's handy functions. After waking up, computing the distance, and performing our magic, we'll put the microcontroller to sleep for a set period. Talk about energy-saving smarts!
  5. Dynamic Functionality: With the groundwork laid, our code will dynamically respond to the user's proximity. If the distance is within the desired range, the animation will kick into gear, setting the stage for a warm welcome. But if things get a little too close for comfort, we'll switch to a static white light, guiding guests safely to the keyhole.

With each line of code, we're not just creating a Door Key Light – we're crafting an experience. So buckle up, folks. The journey to illumination is about to get a whole lot brighter!

Step 6: Fusion 360: Its Time to Make Your Case!

Alright, folks, let's talk about the unsung hero of our project – the 3D case.

Using Autodesk's Fusion 360, I dove into the world of enclosure design, navigating through a maze of complications to create a housing that would snugly accommodate our components. Here's the scoop:

  • Complicated Placement, Clever Solutions: With our LED, button, and WiFi indicator nestled snugly on the bottom, and the battery and charger standing perpendicular towards the door's wall, things got a little tight. Add in the ultrasonic sensor running parallel, and you've got yourself a real puzzle. But fear not – with a dash of creativity and a sprinkle of determination, I managed to find a layout that worked like a charm.


  • A Tight Fit, Literally: Let me tell you, folks – fitting all those components into a compact space was no easy feat. Every millimeter counted, and I wasn't about to let a little thing like size stand in the way of perfection. With Fusion 360 as my trusty sidekick, I crafted a case that was as sleek as it was functional.


  • From Design to Reality: Once the design was finalized, it was time to bring it to life. Cue the Ultimaker 3D printer – my partner in crime for this part of the journey. And let me tell you, folks, I didn't just use one printer – oh no. I had 'em all running at once, churning out prints faster than you can say "innovation." Talk about efficiency!

And remember what Akshay said in class once, Akshay's Rule of Prototyping:

"If it takes more than 2 hours to manufacture for a prototype, find a better and faster method to do the same."

We implemented his theory in 3D printing.


So there you have it, folks – the story behind the case that houses our masterpiece. Whether you're using my design or crafting your own, just know that every curve, every angle, and every tight fit was crafted with care and precision. Now let's put that case to work and light up some doorways!

Key Light_enclosure

Step 7: Assemble It!

Once we are armed with all the necessary components and our board is flashed with the latest firmware, it's time to bring everything together in a harmonious union.

  1. Preparation: Before diving into the assembly, ensure all components are at the ready. Double-check the integrity of each part to avoid any last-minute hiccups.
  2. Glueing the Charge Control Module: Our first order of business is securing the Charge Control Module in place. Apply a dab of hot glue to firmly affix it to the designated spot on the PCB.
  3. Connecting the Battery: With the Charge Control Module in place, it's time to establish the connections between module and the battery. Link the output of the Charge Control Module to the input of the battery on our PCB.
  4. Completing the Circuit: Now, let's seal the deal. Connect the positive and negative terminals of the battery to their respective counterparts on the PCB, ensuring a snug fit to guarantee optimal conductivity.
  5. Final Touches: With all connections secure, it's time to slide the battery into its designated slot within the enclosure. Once snugly in place, carefully close the lid, ensuring a tight seal to protect our precious components.

And there you have it – with a few deft maneuvers and a touch of finesse, our DIY Door Key Light is ready to shine bright and guide the way. Let's step back, admire our handiwork, and revel in the satisfaction of a job well done. 💡🔧

Step 8: Conclusion

And there you have it – the journey from a dimly lit doorway to a beacon of innovation is complete. Through meticulous planning, creative problem-solving, and a fair share of trial and error, we've transformed a simple idea into a functional reality.

So here's to the DIY Door Key Light – a shining example of what happens when we dare to imagine, create, and illuminate the world around us. Here's to the next adventure, the next challenge, and the next opportunity to make our mark on the world.

And hey, before you go, don't forget to follow Mission Critical on YouTube and Instructables for more exciting projects, tips, and tutorials to fuel your creative endeavors. Until next time, my friends – stay illuminated. 💡🌟


If you enjoyed this blog post or project, consider supporting our work by subscribing to our Youtube Channel and following our Social media handles, your support means a lot to us and motivates us to keep making awesome content!

Social Media Handles: PatreonTwitterInstagramFacebook.

Fix It Contest

Participated in the
Fix It Contest