Alexa Controlled Servo

2,144

37

13

Published

Introduction: Alexa Controlled Servo

Introduction
I have a laptop on a shelf in my office that monitors several cameras that are around the outside of my house. They alert me to deliveries and visitors. While I can use a web browser to see their images it is easier to just glance at the screen on the laptop from time-to-time to see what's up.

Unfortunately the laptop's screen saver cuts in after 30 minutes and blanks the screen. That forces me stop what I am doing and press the space bar or shift key to bring the screen back.

Having a voice activated Alexa controlled "finger" that could touch a key on the keyboard is surely not the simplest solution but it sounded like a fun project. This servo device places a movable arm just above a key on the keyboard. The statement "Alexa turn on keyboard" cycles the servo arm, pressing down on the shift key & renewing the screen - nice!

The application presented here is just one way that the servo can be used. Other applications include throwing a wall switch that turns lights on/off or moving some other device, perhaps a latch on a door or cabinet. If you come up with other applications please drop me an email and let me know (dave@davebodnar.com).

Step 1: Video

There is a YouTube video here that gives an overview of this project

Step 2: Hardware

  • Wemos D1 - from BangGood and Amazon.
  • micro servo - Amazon and BangGood
  • 3300 uf, 6.3 volt electrolytic capacitor - eBay or junk box - any fairly high capacity capacitor should work (see notes in article)

Step 3: The Clamp

The "clamp" that holds it all together is shown here. The servo goes in the upper right and the Wemos goes into the holes to the left. The large tapered slot holds it to the side of the laptop. You will need to be changed the dimensions of that slot to fit your laptop. The links here are for a PDF or CorelDraw version of this clamp. The sixteen small holes for the Wemos are not electrically connected to anything - the are just there to help hold the controller in place.

Step 4: Putting It Together

The parts that I used are listed above and shown here.

Step 5: Connections

All of the connections are made by soldering right to the Wemos D1. The capacitor and 5 volt power connecting go to the 5v and G pins. The servo also connects to these pins for power. The servo's data line (the white wire in this photo) goes to pin D5. Those are the only connections that are needed. Power can be supplied from an external 5 volt power supply or, as in this case, by a USB cable plugged into the laptop. The 3300 uf capacitor was added when the Wemos crashed periodically, probably due to variations in the supply voltage. Since the cap was added the unit has been very stable. Other electrolytic caps of 1000 uf or more should work.

Step 6: Attach to Laptop

Here the Wemos & servo are mounted and the acrylic clamp has been placed on the keyboard.

Step 7: Using With Alexa

After programming with the code in this ZIP file (be sure to change the SSID and password to match your system) I told Alexa to discover devices. In a minute or so she reported that she had found a new device called keyboard. Once that is set the servo can be activated by saying "Alexa turn on keyboard" - note that there is no need to say "Alexa turn OFF keyboard" as the servo arm returns to the off position after pressing a key.

Step 8: Software Notes

If you want to change the name that Alexa uses with this device from "keyboard" to something else you need to change the word "keyboard" to your word in a number of places. To simplify this I just changed ALL instances of "keyboard" to the new word using the search and replace function (edit / find).

The code includes a routine that blinks the on-board LED on the Wemos every second. This was added to give the controller a "heart beat" during testing. If you find it unnecessary or distracting it can be deleted.

Note that a number of libraries must be added to your Arduino IDE for this sketch to compile - They are at the top of the listing in the "#include" statements. You also have to add the Wemos to the IDE (see: https://www.instructables.com/id/Wemos-ESP8266-Get... )

Step 9: Other Uses

The servo can be used to move other things as well. Thingiverse.com has several designs for a servo operated light switch including this one that can be 3D printed: https://www.thingiverse.com/thing:1156995/#comments

Share

    Recommendations

    • Oil Contest

      Oil Contest
    • Water Contest

      Water Contest
    • Clocks Contest

      Clocks Contest

    13 Discussions

    0
    user
    gluckc

    2 months ago

    Thanks for your help--

    I was able to take your instructable and morph it to do what I needed. I was very excited to discover this :)

    1 reply

    That is great news - thanks for letting me know

    dave

    0
    user
    gluckc

    2 months ago

    This is exactly what I want to do, but with a solenoid. It seems pretty easy. I just wish your Step 7 "After programming with the code" was expanded :). You have several .cpp files included. How do you get these on the wemo? Is it possible to just copy/paste the routines in these files directly in the .ino? In my limited experience, I've only programmed through the *.ino file.

    1 reply

    Sorry for any confusion - to use the files first download the ZIP file and extract it to some convenient place on your PC

    You should see a set of files that looks like the attached photo

    When you open the

    Wemos-Servo-keyboard.ino

    file you should see the associated files displayed at the top as taps

    hope that helps

    dave

    UnZippedFiles.jpg

    Why did you use GPIO14 for the servo? I'm starting on this exact circuit for another project and was going to try GPIO2 so it's closer to power.

    4 replies

    No particular reason - the sketch should work on any of the other GPIO pins

    dave

    I have reprogrammed mine with separate On/Off and a hardware push button. However, there seems to be an issue when opening the Alexa app. If the device is open in Alexa, it constantly cycles on and off. I can't find out why in the code. Is there a way to make it work with the app correctly?

    Nothing comes to mind that could be causing the problem - does the same thing happen if you use the original code without your ON/OFF & push button?

    dave

    Cool project. But wouldn't it be easier to just turn off the screen saver?

    2 replies

    Ha, yes! Tinkering is about practicality in some aspects; but so much more about fun and growing as a tinker-er.