Making a height-adjustable office desk controllable by Siri using Apple's HomeKit framework.
A while ago I bought a height-adjustable desk. It was supposed to make my often long hours sitting in front of my computer programming things a little bit healthier by allowing me to get up and stand from time to time. However, this really only lasted a couple of weeks until I almost forgot that I could change my desk's height.
Then, a couple of months ago I got the idea that the only way for me to stand up would be if my desk would force me to do it. I thought about ways to automate my desk's electronics and did some research. Luckily, someone has already been experimenting with this idea and a very similar desk, too. That person also managed to analyze the protocol between the manual hand switch and the motor controller with the help of some electrical engineers.
With this I went ahead and started building the devices and software necessary to make my desk controllable using Apple's HomeKit framework. That way I could set up scenes and automatically trigger them, for example changing my desk's position every two hours.
Additionally, I could now save my preferred sitting and standing heights and trigger them using Siri!
You'll need a height-adjustable desk with a LogicData Compact or a compatible motor controller. The motor controller is attached to the bottom of the desk. The hand switch should be connected to the controller with a DIN-7 connector.
Additionally, you'll need soldering equipment or a breadboard with jumper wires in order to interconnect all the components.
The desk module is linked between the hand switch and the motor controller. It passes through any signals from the hand switch, so you can still control the desk manually using buttons. It also adds an Arduino and XBee module, which allow you to send and receive signals remotely from the bridge and ultimately from HomeKit.
Part | Vendor | |
---|---|---|
Arduino Micro with Headers - 5V 16MHz The perfect device to link between the motor controller and the hand switch, as it's 5V and very small. |
Adafruit | |
XBee Module - Series 1 The wireless communicator. |
Adafruit | |
XBee Adapter kit - v1.1 The adapter that makes using the XBee module as simple as possible. |
Adafruit | |
Premium Female/Female Jumper Wires Great for connecting your circuit to the DIN 7-pole socket and plug. |
Adafruit | |
Break-apart Male Headers Pins for making sockets to the hand switch and motor controller. |
Adafruit | |
Lumberg 7-pole DIN Circular Socket (0122 07-1) The socket that will connect to the hand switch. |
Farnell | |
Lumberg 7-pole DIN Circular Plug (0131 07-1) The plug that will connect to the motor controller. |
Farnell |
-
Get the Arduino IDE.
-
Connect your Arduino Micro to your computer.
-
Put the
DeskControl.ino
firmware onto your Arduino.
The bridge is a Raspberry Pi device that connects to the local network and exposes at least one height-adjustable desk through HomeKit. It also contains a XBee module which is used to send and receive commands to and from the desk module.
Part | Vendor | |
---|---|---|
Raspberry Pi 3 - Model B Probably the best device for the bridge, it's fast and comes with on-board wifi. |
Adafruit | |
Adafruit Perma-Proto HAT for Pi Mini Kit A prototyping HAT for soldering the components onto. If you prefer to use a breadboard, this is unnecessary. |
Adafruit | |
XBee Module - Series 1 The wireless communicator. |
Adafruit | |
XBee Adapter kit - v1.1 The adapter that makes using the XBee module as simple as possible. |
Adafruit | |
8GB SD Card with Raspbian Jessie Operating System For the Raspberry Pi. Can alternatively use an empty card and copy the OS onto it. |
Adafruit |
-
Make sure you have the latest version of Raspbian running on your Raspberry Pi.
-
Don't overlook this message:
For headless setup, SSH can be enabled by placing a file named 'ssh', without any extension, onto the boot partition of the SD card.
-
Set up your go workspace by running these lines and adding them to
~/.bashrc
.export PATH="$PATH:$GOROOT/bin" export GOROOT=/usr/local/go export GOPATH=/home/pi/go/
-
Clone this repo and switch into it. Don't rename the destination folder.
git clone https://github.com/davidknezic/desk ~/go/src/github.com/davidknezic/desk cd ~/go/src/github.com/davidknezic/desk
-
Get the dependencies and build the executable.
go get go build bridge.go
-
Run
./bridge
.
Follow these steps to make the bridge software run automatically on each reboot of your Raspberry Pi:
-
Copy the init script.
sudo ln -s ~/go/src/github.com/davidknezic/desk/init.d/desk /etc/init.d/desk
-
Update your rc.d scripts.
sudo update-rc.d desk defaults
Borislav Bertoldi has
made a similar project using a USB-connected remote. He has developed
the DeskControl.ino
file.
Joe F. has helped reverse-engineer the signals sent by the motor controller.
This project is licensed under MIT (c) David Knezić unless otherwise specified.