“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


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.


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.



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!


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!

DIY Standing Desk Part II: The Desk Design

In part 1 I outlined my goal to build an electric standing desk, along with my initial experiment with controlling a linear actuator.  Next up was designing the desk.

In designing the desk, I decided early on that I wanted to use the surface of the desk I already have – an L-shaped desk from Ikea.  The challenge then became designing the elevating legs that will lift the desk, but keep it stable at the same time.

The design below is what I’m going to start with.  I also thought about using scissor lifts, but decided to give this a try first.

I should also note that designing this was a good excuse to head to the neighborhood nano-brewery for a ‘board meeting’ with my dad, who knows way more about building physical things than I do. 🙂

Here is the desk in the ‘sitting’ position:


And here is what each of the three actuator legs will look like, extended:


These drawings were created with SketchUp.

The outside legs will be connected with 24″ drawer slides.  The actuator will push down (rather than up) in order to keep the wires from having to extend down to the foot of the desk.

Some things I’m worried about/still need to figure out:

  • Will it be stable enough?
  • Will it be too heavy?  Each actuator can lift up to 150lbs, so with 3 actuators it should be plenty strong… but there’s a lot of wood on there.
  • Where do I need to watch out for little fingers getting pinched, and how can I protect against that?

Next up: building the first leg and seeing how it works!

DIY Standing Desk Part I: Running a linear actuator from an Arduino

I’ve been using a standing desk on and off for well over a year now.  At the time I started I was thinking about buying a GeekDesk or similar, but decided to try out standing first.  The Ikea Standing Desk recipe from Colin Nederkoom worked great.

Fast forward a year.  I found that I enjoyed using the standing desk, but it wasn’t all that well suited to switching between sitting and standing because the monitors don’t raise/lower with me (without some distracting manual moves).  Ultimately this ended up meaning that I preferred the sitting position that had the two monitors.

Around Christmas 2014 I started looking at adjustable desks again, and was close to buying one.  But sometime during the process of deciding what to buy I decided it would be WAY COOLER to make one myself.  And if I made it myself I could write software for it.  And if I could write software for it then I could make it do ANYTHING I WANT (squat-thrust mode, anyone?).

The basic plan is to:

  • Use the desk surface I already have (an Ikea L-shaped desk) and just build a lift for it
  • Control it either via Arduino or Raspberry Pi (or both)
  • Use 3 Linear Actuators, one each for 3 legs

Before going ahead to buy all the parts, I decided to get one leg working to prove the concept out.  After a few misfires (forgot to buy a power supply, wire that was too large – 18 gauge seems to fit the relays I have nicely, but 16 gauge did not) – I got it working!

Firgelli Automations has a blog post that outlines how to connect up 2 SPDT relays to an Arduino to allow it to both extend and retract.  In my case I elected to get some RobotGeek relays, and while I was at it got their workbench and Arduino Sensor Shield as well (much neater than wiring everything through a breadboard as I had done previously).  The actuator I have is a Firgelli Automations Sleek Rod Tubular Actuator, with a 150lb force and 18″ stroke.

Anyway – step 1 is looking good.  Next I plan to try running the Actuator directly from the Raspberry Pi, and make a decision about whether to use a dumb actuator like the one I have, or to go with a feedback actuator.

By the way – the software for the desk (work in progress!) is posted on github:  https://github.com/brentonc/RobotDesk