Serhii Bykov

Rol Ergo Remote Control

Idea

My workplace at MacPaw have pretty neat workplaces and one of these cool things they have is desks with adjustable height so it can be switched from classic position sit position to position where you can work while standing.

In rare occasions I used stand position, but in most cases I did not used this possibility, and i wanted somehow to force myself to work in standing position at least 30 minutes a day.

First idea to solve this problem was having some alarm in specific time to remind me about stand position. Reminder was working as a charm, but after few days of using I realized that UX of my desk control board wasn’t really good.

Panel with two buttons which control height up and down

There were only two buttons for control - move desk up and bottom. I wanted to have ability to memorize current height of desk since to easy swap between sit and stand position without need to fine tune it each time for my chair position and my comfortable height for standing.

I decided that I want to connect desk to my laptop or phone somehow, but wasn’t sure how exactly do this, since I had no experience with hardware development at all.

Fortunately for me, I vented about this idea out loud to my colleagues. One of folks who was in a room is a DYI hardware enthusiast and he proposed his help to hack control board to make it smarter.

Hardware

First idea to control desk was super easy. We decided that we will connect to existing physical buttons on front panel of desk, and control desk height through it via some microcontroller as a supplementary memory module for original board. Also we somehow needed to know current height of desk, and since we didn’t wanted to reverse engineer original board we decided to use additional module to measure height.

Core items used for development:

  • ESP8266 - main board
  • HC-SR04 - ultrasonic module for measuring distance to calculate current height
  • Other stuff related to connecting modules to each other and control voltage

Coding & Tweaking

Since this was my first dive to “embedded development”, during this project I tried different approaches to implement almost same functionality. None of them was perfect and I will try to briefly describe cons and pros of each implementation.

Native implementation

First implementation of firmware for mainboard was based on my custom code that was running simple HTTP server between desk and computer. Manual approach required a some effort to connection and some simple protocol to send messages from desk about current height and request to set certain height from computer to desk.

Blynk SDK

Upgrade to Blynk SDK was quite cool, since this framework allowed me to remove all network / connectivity code and focus on solving my real problem. As a bonus I was getting WYSIWYG editor for iOS app that allowed me iterate even faster. Also Blynk framework provided me security upgrades, because my previous implementation was exposing multiple security vulnerabilities of my device.

But in certain moment of development, I’ve decided that I want to control my desk through Siri. If you want to support device control from Siri, it should be registered as Apple Home device. Unfortunately, you can’t use firmware with embedded Blynk SDK as Apple Home device. That’s how I came to next framework for my project.

ESP-OPEN-RTOS

If you want to include your device to Apple Home app, it should conform to HomeKit device protocol. After few hours of precise googling I found suitable solution for module that I used for this project - Apple HomeKit accessory server library for ESP-OPEN-RTOS.

But as I said earlier, every technical approach i tried in this project, introduced new challenges or issues.

When you’re registering your device as HomeKit-suitable, you should specify type of device. The problem is, that at current moment, Apple HomeKit have limited device types that can be controlled. There’s a lot of doors, lamps, window curtains, smart sockets but there’s no such device type as “smart desks”. Thankfully, this easy

Also while working with this framework I encountered issue with realtime updates of data. For some reason Home app wasn’t so good at updating my data realtime as my desk moving. But I was too lazy to figure out what exactly was wrong - is it issue of library that I was using (ESP-OPEN-RTOS), is it my misusage of C++, or even some limitation in HomeKit protocol.

Hardware pitfalls

  1. Ultrasonic sensor sometimes could return incorrect info which led to incorrect movement. Sometimes it could be just inaccurate position but sometimes it couldn’t figure out that table is can’t move no more (either upward or downward) and it would stuck in infinite loop of movement. Although that issue could be fixed programatically, it bugged me for a long time with different cases.
  2. For some reason, desks that we’re using, even without my “upgrade”, sometimes had trouble when only when table-leg was moving, and that caused to situations like this:

Table is inclined for 40 cm only on one side

Status

Despite the fact that was fun and even useful project I decided that I needed to sunset it for couple of reasons.

  1. All hardware stack used for this project was wacky - connection to main board of desk through buttons was unreliable, height tracking wasn’t working in 100% cases - it needed to be pointed in non-reflecting surfaces to work correctly.

  2. I found that some model of desk I was using had exact functionality I needed - ability to save current height in preset.

  3. Desk is a property of company, not mine, and I thought it won’t be good for me if in process of development, something will break.

Demo

This is demonstration of how whole thing was working after connection: