The method in this instructable can be used for any button, but for this instance we have an elevator that we want to call using the Amazon Alexa. I have a previous instructable where I used a solenoid controlled by Alexa to do the same thing, but this is more elegant and works better. The button still works as is, but you can also use Alexa to control it.
The ultimate idea is this --- when you push a button, you complete a circuit. For this instructable, I'm using an alexa/microcontroller/relay combination to complete the circuit. It's not replacing the button. Pressing the button will still complete the circuit. But in addition, when you call Alexa, she signals the microcontroller, and the microcontroller sends a signal to the relay which then completes the circuit.
The items needed are:
power cord for the WeMos D1 mini
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Find the Poles of the Button
I took off the elevator plate and found that I could pull it out just by unplugging a telephone plug connector. On the back of the elevator plate was the workings for the button, a processor, and a screen for number display. Luckily the push button had a screw terminal for the wires. No cutting or soldering necessary! However, there were 4 terminals and I had to decide which 2 were for the button. It seems to me that 99% of all buttons use a tact switch with some kind of plate cover, so when I looked on the button plate I could kind of see where the legs of the button were soldered and to which terminal they went to. So, I guessed that those two terminals were the ones I wanted. To test this, I plugged in the elevator plate and touched either end of a wire to each terminal. Sure enough, this completed the circuit, the button lit up and the elevator door opened.
Step 2: Wire It Up
This circuit is 'Normally Open'. When you push the button, you want it to close the circuit. So, the wires from the button go to the relay. One goes to the COM terminal, and the other to the NO (Normally Open) terminal.
Next, the wires from the other end of the relay connect to the microprocessor. It's pretty simple...
DC- of the relay to GND of the microprocessor
DC+ of the relay to 5V of the microprocessor
IN of the relay to any digital pin on the microprocessor
After I checked that everything was working ok, I hot-glued the relay and WeMos processor to the back of the elevator plate.
Step 3: Code It Up
This is both easy and difficult and the same time. If I had to code up myself all the handshaking with the Amazon Alexa, it would be way beyond my skill level. Thankfully, someone has already done it.
Sign up for Sinric here. This site has everything needed. You can register your 'device' on this page so that it is given a unique device name that Alexa can communicate with. Then you can use the sample code to upload to the WeMos and just substitute in your device name, your WiFi, and the code to enact when Alexa turns on/off your device. In my case it was simply adding a pinMode(myRelayPin,HIGH); delay(700); pinMode(myRelayPin,LOW); to send a signal to the relay to complete the circuit.
Step 4: Make It Even More Useful
I followed these steps for both the upstairs and downstairs button. At this point you can have Alexa press the button for the floor you're on, then give a second command to press the button to the floor you are going to. But really, that's too cumbersome.
I downloaded the Alexa App on my phone. From there I can go to the main menu, select 'Routines' and create a routine for the elevator. For example, when I say "Alexa, going down" Alexa will signal the button in the kitchen, she will say "Going Down" (I need her to pause briefly and having her say something gives the delay I need), then she will signal the button in the basement. With one command, everything is done.