Over Engineered Desk
Tags: bekant, iot, workstations, wfh
Published: 2022-09-15 18:13:46

## **SAFETY DISCLAIMER**

> As the security engineer I was aware of all potential security issues - and I still am now. But what’s far more concerning me is safety - for now there is no safety system to limit the crashing power of the desk, going down on something, or someone under the desk. And, in case of the Rise of the Machines, I am doomed.

## Intro
During the pandemic I've bought myself a gift: Ikea Bekant. Purchase was made to make the 'working from home' experience bearable. Aaaand here we are - 2,5 years working like that. Why Bekant? No idea, probably it was available at that time and my wif... I like white colour. 

## The problem

The only downside was the control panel: it was required to press one of two buttons, either 'up' or 'down' for the whole time, during changing height. No fixed position for standing or sitting - that's a shame. Or a perfect opportunity for a DIY project.

## Solution, hard way
First thought, after a quick look at the desk frame, was to remove the control panel, and instead, put a microcontroller to communicate directly with motors. But as I was lacking an oscilloscope and any tools (my parents basement has it all) I needed a simpler solution. 
Some great solutions: https://github.com/trainman419/bekant
https://www.eevblog.com/forum/beginners/ikea-bekant-desk-motorised-hack/

## Solution, easy way
Second thought: Emulate the buttons! To imitate the pilot, the GPIO ports should steer the buttons, with 'safety pin' connected directly to GND.

As my Raspberry Pi zero was an overkill, not available and cold dead after another project, I've picked the old (7 years old to be precise) esp32 devkit. I've planned to do my master’s thesis using it, but... The connection is dead simple - three cables from 'pilot', esp32, micro usb cable, no fancy LEDs, no custom nor mechanical switches for operation. 

The esp32 was connected, using ingenious technique - male-to-male cables connected to the controllers' tape socket: GPIO22 to 'down', and GPIO23 to 'up' buttons, and safety pin to GND.
 
![Quick solution for tape socket](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/toset8tdzmyqdayx8hob.jpeg)


![Beautifully crafted piece of engineering](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ecjr5dtfgktmi5kf9307.jpeg)


At the instigation of my friend Piotr, I've used the Tasmota software, to integrate it with my not-so-smart home setup. Docker based Home Assistant, deployed on Orange Pi Zero 2 (that's some serious dev board!), paired with MQTT Broker Mosquitto as the brain of the system.

![The mother board](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hd0c1zjhsabss61twkxo.jpeg)

Automation - if the 'switch up' is on, set the pin high for N, where N is the empirically measured desk height for your height... in seconds, and then switch off the 'switch up'. Same with the low position. And thanks to Home Automation it was possible to set up the Siri integration. 

## Outro
With all of that engineering, time, and around 30 USD, I can irritate my wife by saying 'Hey Siri, Office down/up' every time when changing position instead of holding the button for 13 seconds.