Skip to content

davidknezic/desk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

↕️ HomeKit-enabled Office Desk

Making a height-adjustable office desk controllable by Siri using Apple's HomeKit framework.

Office Desk controlled by Siri Office Desk controlled using Home app

Table of contents

Intro

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!

Prerequisites

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.

Motor controller DIN-7

Additionally, you'll need soldering equipment or a breadboard with jumper wires in order to interconnect all the components.

Desk module

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.

Desk hardware

Module parts list

Part Vendor
Arduino Micro with Headers - 5V 16MHz 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 XBee Module - Series 1
The wireless communicator.
Adafruit
XBee Adapter kit - v1.1 XBee Adapter kit - v1.1
The adapter that makes using the XBee module as simple as possible.
Adafruit
Premium Female/Female Jumper Wires Premium Female/Female Jumper Wires
Great for connecting your circuit to the DIN 7-pole socket and plug.
Adafruit
Break-apart Male Headers Break-apart Male Headers
Pins for making sockets to the hand switch and motor controller.
Adafruit
Lumberg 7-pole DIN Circular Socket 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 Lumberg 7-pole DIN Circular Plug (0131 07-1)
The plug that will connect to the motor controller.
Farnell

Module assembly

desk module schema

Module software

  1. Get the Arduino IDE.

  2. Connect your Arduino Micro to your computer.

  3. Put the DeskControl.ino firmware onto your Arduino.

HomeKit bridge

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.

HomeKit bridge

Bridge parts list

Part Vendor
Raspberry Pi 3 - Model B 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 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 XBee Module - Series 1
The wireless communicator.
Adafruit
XBee Adapter kit - v1.1 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 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

Bridge assembly

HomeKit bridge schema

Bridge software

  1. Make sure you have the latest version of Raspbian running on your Raspberry Pi.

  2. ssh into the 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.

  3. Install the latest version of Go.

  4. 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/
  5. 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
  6. Get the dependencies and build the executable.

    go get
    go build bridge.go
  7. Run ./bridge.

Follow these steps to make the bridge software run automatically on each reboot of your Raspberry Pi:

  1. Copy the init script.

    sudo ln -s ~/go/src/github.com/davidknezic/desk/init.d/desk /etc/init.d/desk
  2. Update your rc.d scripts.

    sudo update-rc.d desk defaults

Attribution

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.

License

This project is licensed under MIT (c) David Knezić unless otherwise specified.