We all had our projects during one of the many lockdowns and an ‘Alexa Enabled Secret Bar’ was mine! This project started out with building two industrial sideboards for the corner of my dining room. The question: what to do with dead space in the corner? The answer: a pop up unit that made full use of that space. And hence, the idea for an Alexa Enabled Secret Bar was born.
In this 3 part series of posts, I’m going to give you a good idea on how to build your own version of an Alexa enabled secret bar. But, at the end of the day, this is just a stepper motor hooked up to a WIFI enabled controller. So I am sure there are many other projects you could do with this method. Automated blinds, window/door openers, extending shelve….you get the idea! I’d be really interested to hear about any project to get up to.
If you haven’t already, check out the video of the finished project. I started writing this post but it has quickly grown! So I have split this into 3 separate posts:
- The Mechanics
- The Electronics
- The Firmware & Software
So if you are following on from the Mechanics post, now I have a stepper motor wired up to a leadscrew, I needed something to control it. It’s at this point that the Alexa side of things started to pop into my head. Absolutely no point whatsoever….but why not! But first things first, we need a stepper motor driver, a controller, some switches and lets throw some lights in for the hell of it!
Initially I experimented with a A Pololu DRV8825 and an ESP32-DevKitC microcontroller (ESP32-WROOM-32). Take a look at my post on How to ‘Control a Stepper Motor From Alexa’ for how to get started with this one. Remember I mentioned that the problem with using the leadscrew was speed? Well, this is where the little DRV8825 fell over. It definitely worked, but it was like watching paint dry. So I opted for the much more powerful TB6600 stepper motor driver. You can check out my post on how to wire this up but the below diagram should set you off in the right direction. Alternative, jump to the bottom of this post for a completed wiring diagram of the whole project.
Now I have the stepper motor, driver and ESP32 all in place. I needed a switch to allow me to home the motor. For this I used a straight forward levered microswitch. I mounted this on an adjustable bracket so I could adjust the home position with relative ease. The ESP32 already has some pull down resistors so we don’t need to worry about switch bouncing. The homing switch can therefore be simply hooked up to one of the GPIO pins. The below diagram shows a microswitch hooked up to the 3.3v line, Ground and GPIO 16:
LED Strip Lights
The next thing I wanted was some LED strip lights. I opted for the 5050 RGBWW LED strip lights. These are standard R(ed)G(reen)B(lue) LED strip with an addition strip of W(arm)White LEDs. Now the tricky bit here is the fact that the LED strips are 0-12v, whereas the ESP32 is 0-3.3v on the GPIO. Not to mention, the ESP might be ok driving a single LED, but there is no way it would drive a whole strip.
So after a bit of digging around and some help from the guys over at Github, I decided to use some TIP120 transistors to drive the LED strip The idea here is that the transistor allows the 12v line to be switched very quickly. This allows the PWM control on the ESP to control the brightness of the LEDs. A circuit like the below is how you would control 12v 5050 LED strips from a ESP32 using PWM. Here I have used GPIO pin 14, 27 and 26 for R, G and B respectively. In addition to this, we need to add some resistors to the transistor bases. Finally, don’t forget to tie the ground of the 12v line to the ground on the ESP32 (just like we did for the stepper motor driver).
Final point to note is that this diagram is for RGB LED Strip, not a RGBWW strip. This is just because I couldn’t find a RGBWW strip in the component library – sorry about that! I’m sure you are able to work out the extra wiring needed by copying the RGB lines. I used GPIO pin 25 for the WW.
Capacitive Touch Switch
The final piece of the puzzle was a physical switch to open the bar. The last thing I wanted was a none responsive Alexa standing between me and my fine whiskey collection! To keep with the Alexa enable secret bar approach, I decided to use a capacitive touch switch instead of a push switch. This way, the switch will just look like a plaque or a part of the sideboard. Luckily, the ESP32 already has touch sensor pins defined so it is easy to wire these up. I simply took a length of cable and stripped off a long length of the insulation at one end. Then I trapped this under a stainless steel plate to act as the touch plate. The other end of the cable was wired into GPIO13.
Final Assembly & Power
All of this was hacked together on a breadboard for testing followed by being bodged together on some PCB stripboard. The result certainly works, but it is not neat! To try redeem myself, I’ve put together the below circuit diagram which should point you in the right direction for the completed circuit. Note that this diagram uses the DRV8825 stepper motor driver as I described in my earlier post. However, if you need a bit more power you can swap out for the TB6600 stepper driver like in the first section of this post.
In terms of power supply, I used a 12v transformer for the LEDs and Stepper Driver. To power the ESP32, I simply used the built in USB. Not the neatest solution but this was convent for me since the mains socket I was plugging the 12v transformer into also had a USB output. If you don’t have a handy USB outlet, there are plenty of 12v to 5v transformers or 12v to USB outlets you could use.
Well, that is it for part 2: Electronics. Part 3: Firmware and Software soon to follow!