“Alexa, raise my desk to 15 inches”

Last year, I built a DIY Raspberry Pi controlled electric standing desk.  It was a great project and I’ve gotten a ton of use from it.

To move the desk, I simply had to:

  1. Launch PuTTY on my computer
  2. PuTTY to the raspberry pi
  3. Log in
  4. Navigate to the directory where the program was running
  5. type sudo python3 robotdesk.py
  6. Tell it what height to move to

It works and is definitely better than sitting all day… but we can do better than that, right?

Yes, we can.  My desk is now voice-activated via Amazon Alexa!

Isn’t that better?

How does it work?

There are 3 parts to the integration:

  1. Alexa Skill
  2. Azure-hosted API
  3. Desk Controller

voicesolution

Alexa Skill

Amazon has an SDK for the Amazon Echo family devices called the “Alexa Skills Kit“.  In short, the Alexa skill contains 3 things:

  1. The things your skill can do (called intents)
  2. Sample ‘utterances’ and how they map to the intents
  3. Instructions on how to call your program

Your program can either be an Amazon Lambda program, or it can be a HTTPS API that the Alexa service will post a message to.

It’s easy to set up a simple skill to get started.  Check out the Amazon developers site for how tos, tutorials, etc.  Or if you want to learn in a bit more structured way, check out “Developing Alexa Skills for Amazon Echo” on Pluralsight.

The speech assets for my desk are on github.

API

The API is simple and does 2 things:

  1. Receives commands from the Alexa service and translates the intent and parameters to a desk command
  2. Responds to the desk controller’s requests for command.  The desk is using a long-polling mechanism to get commands.

The code is here (disclaimer: this is hack-it-together code, not production quality!)

Desk Controller

The desk controller uses the python program I had previously created to control the desk, but adds long-polling to get commands, rather than waiting for someone to type into the console.

What’s Next?

The program has lots of room for improvement, the Amazon process for certifying skills is rigorous, and the interactions with the desk will get better as I find the terms that I want to use to control it.

Have feedback?  I’d love to hear it.  Leave a comment or reach me @_brentonc on twitter.

Standing Desk: Wiring 6 relays to 2 GPIO pins

A comment on a video about my desk recently asked,

I’d like to know how you wired up everything (the pi to the relayboard) using 2 GPIO pins. Could you please take a picture and upload it to your blog?

Good question, Jake.  Here’s a picture.

wiring-numbered

 

But that’s not too clear, let’s break it down.

  1. This gray band connects the RPi to the breadboard to make it easy to make multiple connections.  But you can connect directly from the pins to the breadboard; just make sure you bring power and ground as well.  And you’ll beed male/female connecting wires to make the connection.
  2. Connect the 5v power (red wire above) and ground (black wire above) to the power/gnd pins on the relay.
  3. The breadboard lets us connect multiple wires to a single pin.  When that pin is ‘on’ all three connected wires are signaled.  In the picture above, the 3 green wires on one pin; the 3 blue wires are connected to a second pin.
  4. The green and blue wires are connected to the relays in alternating pairs.  Each one turns on one relay when signaled, so each time the pin on the RPi is on it triggers 3 relays in my case (one for each actuator in my desk).
  5. For each of my actuators I use two relays.  This allows the signal to be reversed by flipping which switch is on, thereby telling the actuator to extend or contract.

So, after all this, the code to extend, retract, and stop is easy!

comments

Good luck!

Desk uptime

Well, we are moving to a new place on the other side of Wisconsin, near the mighty Mississippi.  And that means I need to dismantle the robot desk for transport.

Final uptime?  72 days, 2 hours, and 52 minutes.  Not bad.

Sleep tight Desk, I’ll see you in a few days.  shutdown -h now.

Standing Desk Accessories – Anti-fatigue mat

I’ve been using my DIY motorized standing desk for a couple weeks now, and am really enjoying it.  I’ve been standing more than I thought I would, but when I get tired the flexibility to lower to a sitting height is really nice.

One thing I’ve noticed that at the end of the day my legs are quite tired, and my feet bothering me a little.  Thankfully my anti-fatigue mat arrived last night.  After one day using it, I can already feel a big difference.  My feet feel much better, and while my legs are still a little tired, it seems to be a little less so than the other days.

The mat is pretty heavy duty and looks like it will last a while.  Standing on it feels soft and firm at the same time, and almost like it molds to the feet.  I’ve used it barefoot thus far, but will likely see what the experience with shoes is soon.

This is just the first day’s impression, but thus far it seems like a good investment.

By the way – I’m glad that my desk gives me fine grained control on the height so I can get the adjustment perfect with the various mat/shoes/etc arrangements I’ve been exploring!

DIY Motorized Desk Powered by Raspberry Pi is Operational!

It’s alive!

This has been a long time in the making, and I’ve posted a number of times during the process:

This has been an incredibly fun project.  It definitely would have been faster and probably more cost effective to just buy a desk or table lift, but the journey was well worth it.

DIY Motorized Standing Desk Part V: Test with 3 actuators controlled from Raspberry Pi

Edit: here is the final operational desk, utilizing the 3 actuators

I have the control board for my DIY motorized standing desk wired up, and ran a test of the board controlling 3 linear actuators at the same time.  I knew the wiring and software worked for 1 actuator, but this was the first time that I connected more than one actuator up.  The desk will be lifted by 3 actuators so I needed to be sure this worked.

Here it is, worked on the first try and nothing caught on fire!

One thing of note – I had initially planned to control each actuator independently from the Raspberry Pi, with each relay signaled from a different GPIO pin.

However, in the midst of wiring the control board up I realized that it was possible that a software bug, crash, or other unforeseen scenario on the Pi could theoretically result in actuators moving in different directions, and that would be a Very Bad Thing (images of broken desks, shattered monitors, and crushed babies come to mind).

So they are all wired now on 2 GPIO pins (one for the “A” relays, and one for the “B” relays).

So now the leg apparatus’ are built, and the control board is working.  Next step: put it all together!