Alexa Controlled Solenoid Using WEMO D1 Mini

It really is amazing. It's not that hard to have an alexa echo control a micro-processor. The world is your oyster. This instructable takes you through the steps to control a solenoid. You can use this same process to control whatever you want. In my case, I used the solenoid to push an elevator button. I made two of these, one for the upstairs elevator button, and one for the downstairs elevator button.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Get Your Parts

Ingredients:

Alexa Echo Dot (or Echo)

WEMO D1 mini -- Be careful not to get the WEMO D1 mini LITE. I accidentally did this thinking I was saving money, but it didn't work correctly.

L293D -- A relay is typically used, but I had a bunch of these laying around, and they worked.

Breadboard

9V Battery Connector

Female Pin Headers -- optional

Solenoid

wires

9V Battery

Step 2: Mix It Together

I soldered this together on the perfboard. This particular board is nice because it is laid out like a breadboard with rails and sets of holes that are connected.

First, I soldered female headers onto the perfboard for the WEMO to plug into. Originally, I also soldered female headers for the L293D to plug into. However, I discovered, that the L293D does not plug into the headers with a good connection, so I soldered it directly onto the board.

Then I soldered wires to to the board to make connections:
1. Red wire from WEMO 5V to L293D Enable pin
2. Black wire from WEMO ground to L293D ground pin (5)
3. Yellow wire from WEMO D1 pin to L293D input2 pin (7)
4. battery cap wires - black to WEMO ground, red to L293D Vs pin (8)
5. solenoid wires -- black to WEMO ground, any color to L293D output2 pin (6) -- NOTE: I used wire with a 2-pin female connection at the end. I can plug the solenoid into this. I soldered male pins to the end of each solenoid wire.

There was no reason that I connected to Input/Output 2, I could have done Input/Output 1. In fact, I could have controlled 4 solenoids instead of just the one, but one was all I needed for this project.

Step 3: Code

You can use the Arduino IDE to program the WEMO.

There are some steps to get the WEMO working with the arduino IDE, and you can follow them in this excellent instructable...https://www.instructables.com/id/Wemos-ESP8266-Get...

Next, you have to get the WEMO working with the Echo...
The reason for the WEMO is that it is WIFI enabled - and, you can use some easily available code to make it behave like a wemo belkin switch. This is an easy way to interface it with the amazon echo.

First, go to:
https://github.com/kakopappa/arduino-esp8266-alexa... and download the belkin simulation code. Put this code where all your other arduino projects are located. Then bring up the wemos.ino file in the arduino ide. The only file that needs to be modified is the wemos.ino file. Basically, all you need to do in this file is:

1. Set your SSID and password to your wifi
2. Define your switch; (Switch *kitchen = NULL;)
3. Initialize your switch; (kitchen = new Switch("kitchen lights", 81, kitchenLightsOn, kitchenLightsOff); upnpBroadcastResponder.addDevice(*kitchen); )
4. Add to Loop section; (kitchen->serverLoop(); )
5. Make your callback for both On and Off and put whatever you want in the callback: bool kitchenLightsOn() { Serial.println("Switch 2 turn on ..."); isKitchenLightstsOn = true; return isKitchenLightstsOn; }

You'll see all this in the sample wemos.ino code. Just replace the Switch-es in that file with whatever you want to make a switch. In my case, I renamed everything "BasementButton". My basementButtonOn() callback changes pin D1 to HIGH. See the code I included as an example.

Step 4: Application

In my case, I wanted the solenoid to push an elevator button. To do this, I needed some kind of bracket to hold the solenoid over the elevator button. So, this is my first foray into the 3D printer world. I went to tinkercad.com and made an account. You can use their tool to build 3D designs in the cloud and then export your design to a *.stl file which can be printed out. I found tinkercad to be very intuitive to use. You drag shapes into the drawing area to build the design you want. When you first set up your account, it has a very good tutorial to get you started. It just gets a little trickier when you need to make sure it has the correct dimensions.

I was able to print the bracket out through the kindness of a friend who has a 3D printer. But there are various companies that can do it for you, too. Some libraries will even do it.

Step 5: Put It Together and Done

I mounted the bracket/solenoid over the elevator button and put the WEMO in a plastic box on top of the button. After uploading the code to the WEMO, you have to get Alexa to discover it. Just say "Alexa find devices". Once she finds it you can say "Alexa turn on DEVICENAME" or "Alexa turn off DEVICENAME". This activates the callback into the code and turns on the solenoid. In my case, I have a "elevator up" device and a "basement button" device. It's a little wordy, but it works. Also, it doesn't entirely make sense to "turn on" and "turn off", but I'm not sure that it can be changed.

Microcontroller Contest

Participated in the
Microcontroller Contest

Be the First to Share

    Recommendations

    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    2 Discussions

    None
    Reamer Babes

    5 months ago on Step 5

    I'm trying to control my elevator with Alexa as well. Speaking "turn on the elevator" is quick to set up but not natural. With some setup, it is possible to invoke intent with "use elevator" and "ask elevator to come" from the alexa developer console, but I'm still researching how to connect Amazon cloud with my microcontroller. Please let me know if you are able to find anything!

    1 reply
    None
    gluckcReamer Babes

    Reply 5 months ago

    Since publishing this, the connection with Alexa got flaky. So I found another method that still used the WEMO. If you go to sinric.com, there are instructions for downloading some code from github and modifying to what you want in order to connect your microcontroller with alexa. It's pretty similar to what I posted here. Since using sinric, I've been able to use voice-activation for the elevator for about a year now with no issues. It still is using "Alexa turn on elevator in kitchen' to activate it -- which is cumbersome -- but it works, so I am happy.