Skip to the content
2 layers91.2 × 18 mmShapdesk rev2, the printed circuit board in 3D

ESPHome firmware for Shapdesk standing desks: Wi-Fi control, height monitoring, and Home Assistant integration on ESP32-C3.

Size
91.2 × 18 mm
Copper layers
2
Thickness
1.6 mm
Parts
31
Nets
33
Pads
91
Tracks, vias
158, 21
Pours
6
Routed
Yes
KiCad
KiCad 10.0 (file 20260206)
Created
28 Oct 2026
Updated
28 Oct 2026

Overview

Shapdesk rev2 is an open-source printed circuit board by evgkg, from the evgkg/shapdesk-esphome repository on GitHub, published under the MIT licence. It is a 2-layer board of 91.2 × 18 mm with 31 parts on 33 nets, routed with 158 tracks and 21 vias.

It is built around the ME6211C33M5G-N and MMBT3904. Its parts include 16 resistors, 7 transistors, 2 capacitors, 2 ICs and 1 connector. It belongs with the home automation and IoT and radio and wireless boards and the ESP32 and RISC-V boards of this library.

Main components

2

README

README.md

Shapdesk ESPHome

English · Русский

A small add-on that connects a Shapdesk standing desk to Home Assistant over Wi-Fi. An ESP32-C3 SuperMini board lives in a little 3D-printed box on the back of the original handset. It presses the handset's buttons for you and reads the desk height from the data the handset sends over UART. In Home Assistant the desk shows up through ESPHome: raise and lower it, send it to a height, recall presets 1–4 and press M.

The buttons on the handset still work as before, and the desk controller's own protections stay in place.

HandsetAdd-on on the backUSB-C for flashing

Contents

How it works

The handset's buttons are wired as a matrix: each button connects one of the T5/T4 lines to one of the T3 lines. T3, T4 and T5 are three small SOT-23 parts on the handset board, and their legs are handy places to solder to. The add-on has a transistor across each button. When the ESP switches a transistor on, it shorts the button, and the handset can't tell that apart from a finger press.

Button matrix

The handset also keeps sending data on its RX line (5 V UART, 9600 8N1): the desk position and what's on the display. The add-on only listens; it never sends anything to the handset.

KeyButtonGPIO on rev2GPIO on rev1
K1▲ up55
K2▼ down36
K3preset 177
K4preset 2010
K5preset 3100
K6preset 411
K7M43
UART RXhandset data, through a 10k/18k divider64
USBlogs and flashing18/1918/19

Each GPIO drives an MMBT3904 transistor through a 4.7 kΩ resistor, and a 100 kΩ resistor from base to emitter keeps the transistor off until the GPIO is set up. GPIO2/8/9/20/21 are free. The add-on runs off the handset's 5 V through an ME6211 3.3 V regulator; you can plug in USB at the same time.

What's where

text
shapdesk.yaml              ESPHome config (settings at the top)
components/shapdesk/       ESPHome component in C++; the main logic doesn't depend on ESPHome
tests/                     PC tests: handset data parsing, height, moving to a height
hardware/pcb/              rev2 board in KiCad 10, Gerber files, make_fab.bat
hardware/enclosure/        enclosure and connector retainer (STL and STEP)
hardware/bom.csv           parts list
docs/assembly.md           step-by-step build
docs/images/               photos and diagrams

Hardware

Board revisions

rev1rev2 (this repository)
Madeat home, single layer with wire jumpersby a PCB factory, 2 layers, solder mask, silkscreen
Keys K1…K7GPIO 5, 6, 7, 10, 0, 1, 3GPIO 5, 3, 7, 0, 10, 1, 4
UART RXGPIO4GPIO6
In the firmwareboard_revision: "1"board_revision: "2"

Only rev2 files are published. rev1 is mentioned here because the firmware still supports it.

rev2 hasn't been ordered or tested in hardware yet. The circuit is the same as on the working rev1, but the board layout and the GPIO assignment are new.

Known issue (rev1): the desk moves down while flashing

On the ESP32-C3, GPIO6 has a weak internal pull-up switched on during reset and in the bootloader (ESP32-C3 datasheet, table 2-1, the note about EFUSE_DIS_PAD_JTAG). On rev1 that GPIO presses "down". While the chip sits in the bootloader — a few seconds when you flash over USB — the pull-up turns the transistor on and the desk drives down. The firmware can't do anything about it, because it isn't running yet.

  • Fixing rev1: solder a 4.7 kΩ resistor between GPIO6 and GND. It overpowers the pull-up, so "down" stays released. Until you do, unplug the cable from J1 before flashing, or at least make sure the desk can't hit anything.
  • On rev2 the keys use GPIO 0, 1, 3, 4, 5, 7 and 10, none of which has a pull-up at reset. UART RX moved to GPIO6, where the pull-up doesn't matter. The GPIOs are assigned in the order that keeps the board traces straight. The firmware is set up for rev2 by default (board_revision: "2").

With the wrong revision set, the firmware drives the wrong GPIOs: keys get mixed up and the add-on can't see the height. So check the boot log (see below) before the first test on the desk. The firmware turns off the pull-up on whichever GPIO RX is connected to, so even with the wrong revision that pin can't press a button.

rev2 board

Top (ESP32-C3 SuperMini and J1)Bottom (all the small parts)

Schematic: hardware/pcb/shapdesk_rev2_schematic.pdf. KiCad 10 project: hardware/pcb/shapdesk_rev2.kicad_pro.

Ordering the PCB

hardware/pcb/shapdesk_rev2_gerbers.zip can be uploaded as is to any PCB maker (JLCPCB, PCBWay, etc.):

  • 2 layers, 1.6 mm thick, 91.2 × 18 mm, any mask colour, HASL finish is fine.
  • All SMD parts (0603, 0805, SOT-23) are on the bottom side.
  • The thinnest track and the smallest gap are 0.25 mm, vias are 0.8/0.4 mm — standard for any PCB maker.

If you change the board, hardware/pcb/make_fab.bat rebuilds the Gerber files and the ZIP (needs KiCad 10).

Parts list

Full list with board references: hardware/bom.csv.

QtyPartPackageWhere
1ESP32-C3 SuperMini (soldered on the pin headers it comes with)moduleU1
1ME6211C33M5G-N, 3.3 V regulatorSOT-23-5U2
210 µF ceramic capacitor, 10 V or more0805C1, C2
7MMBT3904 NPN transistorSOT-23Q1–Q7
7100 kΩ0603R1–R7
74.7 kΩ0603R8–R14
110 kΩ0603R15
118 kΩ0603R16
1right-angle pin header 2×5, 2.54 mmthrough-holeJ1
1 + 9Dupont 2×5 female housing and crimp contacts2.54 mmcable
9thin stranded wirecable
3 + 3heat-set insert M2 × 2.5 × 3.2 and M2 × 8 button-head hex screw (ISO 7380)board into the enclosure
2 + 2heat-set insert M3 × 4 × 4 and M3 × 6 button-head hex screw (ISO 7380)enclosure onto the handset
1 + 1printed enclosure and connector retainerFDMhardware/enclosure/

3D-printed parts

hardware/enclosure/ has STL files for printing and STEP files in case you want to change something:

  • shapdesk_enclosure — the box, 132 × 25.5 × 14.9 mm. The M2 inserts for the board go into its three standoffs. The two holes in the flange (Ø3.4 mm) take the M3 screws that hold it on the handset.
  • shapdesk_connector_retainer — a spacer between the Dupont plug and the enclosure wall, so the plug can't work its way off J1.

Wiring to the handset

Nine wires go from J1 to the handset board: GND, RX and 5 V to the pads at the board edge, and the other six to the legs of T3, T4 and T5, two per part.

Where to solder

The whole build, step by step, is in docs/assembly.md.

Firmware

The firmware is ESPHome (esp-idf framework) with the logic in its own C++ component. It talks to Home Assistant over the encrypted ESPHome API and is found on the network automatically (mDNS). It can be updated over Wi-Fi and starts a backup access point if your Wi-Fi isn't reachable. No MQTT needed. The code that reads the handset and drives the desk to a height doesn't depend on ESPHome and is covered by tests that run on a PC. The ESPHome version is pinned in requirements.txt.

Install and flash

In PowerShell, in the project folder:

powershell
python -m venv .venv
.\.venv\Scripts\python -m pip install -r requirements.txt
Copy-Item secrets.example.yaml secrets.yaml

Put your Wi-Fi network, a password for over-the-air updates, a password for the backup access point and your own API encryption key into secrets.yaml. The template has example values that everyone can see, so replace all of them. To generate a key, check the config and build:

powershell
.\.venv\Scripts\python -c "import secrets,base64; print(base64.b64encode(secrets.token_bytes(32)).decode())"
.\.venv\Scripts\esphome config shapdesk.yaml
.\.venv\Scripts\esphome compile shapdesk.yaml

Don't forget board_revision at the top of shapdesk.yaml: "2" (the default) for the factory board from this repository, "1" for a home-made rev1.

The first flash goes over USB (use your own COM port):

powershell
.\.venv\Scripts\esphome upload shapdesk.yaml --device COM3
.\.venv\Scripts\esphome logs shapdesk.yaml --device COM3

On boot the log shows the revision and the GPIOs, for example Board rev2: K1..K7 = GPIO5/3/7/0/10/1/4, UART RX = GPIO6.

After that you can update over Wi-Fi:

powershell
.\.venv\Scripts\esphome upload shapdesk.yaml --device shapdesk.local

If shapdesk.local can't be found, use the IP address. If the add-on can't join your Wi-Fi, it starts its own access point, Shapdesk Fallback (password from secrets.yaml): connect to it and pick your network. Before an over-the-air update the add-on releases all buttons. If you ever need to put the ESP into the bootloader by hand, use the BOOT and RESET buttons on the SuperMini.

In Home Assistant, open Settings → Devices & services. The add-on shows up there as a discovered ESPHome device; add it and enter the encryption key. If it doesn't show up, add the ESPHome integration by hand with the IP address and port 6053.

What you get in Home Assistant

The entity names in shapdesk.yaml are in Russian; rename them however you like.

The add-on in Home Assistant

  • Высота стола (desk height) — the current height in centimetres. It's empty while the add-on doesn't know the height yet, and for a short while after you press a preset, because the handset then shows the preset's height instead of the real one.
  • Стол (desk) — the ↑ and ↓ arrows raise and lower the desk, ■ stops it. The desk keeps moving until you stop it, for 20 seconds at most (max_hold_ms). Open the card and there's also a slider in percent: 0 % is the lowest height, 100 % the highest, anything in between is the matching height. At 0 % and 100 % the slider works the same as the ↓ and ↑ arrows.
  • Целевая высота (target height) — set a height in centimetres and the desk goes up or down to it.
  • Пресет 1–4 and M — the same as pressing those buttons on the handset.
  • Стоп (stop) — lets go of whatever button the add-on is holding and cancels a move to the target height. It doesn't stop a preset move: the desk goes to a preset on its own, nothing is holding a button.
  • Стол движется (desk moving) and Связь с пультом (handset link) — whether the desk is moving right now and whether data is coming from the handset.
  • Diagnostics: the height shown on the handset, the position in the handset's own units (hidden by default), how much handset data was accepted and rejected, Wi-Fi signal and uptime.

For automations there's an action, esphome.shapdesk_press_key: it presses key key (1–7, see the table above) and holds it for duration_ms milliseconds, for example {key: 7, duration_ms: 300}. The exact action name depends on what the device is called in HA. If the parameters are wrong, nothing is pressed and the reason goes to the log.

Settings

All settings are in the substitutions block at the top of shapdesk.yaml.

SettingDefaultWhat it does
board_revision2Board revision: 1 = home-made rev1, 2 = factory rev2
k3_name…k6_nameПресет 1…4Names of the preset buttons; check which preset is which on your handset
max_hold_ms20000The longest "up", "down" and M can be held, ms (1…120000)
pulse_ms300Length of a short press, ms (1…500)
start_timeout_ms3000How long to wait for the desk to start moving, ms (1…30000)
min_height, max_height66, 131Lowest and highest height the add-on will drive to, cm (50…150)
tolerance1How close to the target counts as arrived, cm (0…5)
stop_offset1How far before the target to let go of the button, cm (0…5)
adapt_offsettrueTune stop_offset automatically

Why stop_offset exists: when the button is let go, the desk keeps moving a little. So to stop exactly at the target, the button has to be let go a bit early. With adapt_offset on, after every move the firmware checks how far the desk coasted and nudges stop_offset towards it: new value = 0.75 × old + 0.25 × this time's coast (kept within 0…5 cm). Up and down are tracked separately and start again from stop_offset after a reboot. Moves where something went wrong (handset data dropped out, the desk went the wrong way, it coasted more than 5 cm) are left out.

Protection against unwanted movement

What the firmware does so the desk doesn't move by itself:

  • Nothing is pressed on power-up or reboot. The first thing the firmware does on boot is release every button, before it even joins Wi-Fi. Before the firmware starts, resistors on the board keep the transistors off.
  • Only one button at a time, with at least 50 ms between presses. If a command to press another button arrives while one is held, the add-on lets go of everything and ignores that command — just send it again.
  • No button is held longer than allowed. A separate hardware timer watches this, so the button is released even if the main program hangs or is busy. Presets are held for at most 500 ms; "up", "down" and M for at most max_hold_ms. Sending the same command again doesn't extend the time.
  • Moving to a height only starts if the add-on knows the current height for sure. The desk is stopped if the handset goes quiet for more than half a second, the desk moves the wrong way, it doesn't start within start_timeout_ms, it reaches a height limit, or the connection to Home Assistant or Wi-Fi drops.
  • Without handset data you can only move the desk up and down by hand, within max_hold_ms. Sending it to a height isn't possible.
  • The desk won't go past min_height and max_height, but it can always move back away from a limit.

What the firmware can't do:

  • "Stop" only releases buttons the add-on pressed itself. If someone is holding a button on the handset, it can't do anything about it. And if a short preset press made the handset drive the desk to the preset on its own, "Stop" won't stop that — stop it from the handset.
  • A burnt-out transistor or a completely frozen ESP is beyond what software can protect against. Always keep the handset within reach.

First test on the desk

  1. Before the first move, use a scope or logic analyser to check that the add-on presses nothing on power-up, reboot and Wi-Fi reconnect, and that a press ends on its own when the time runs out. Check that the handset buttons work as before and that Home Assistant shows the height.
  2. Press M briefly (300 ms). Then "up" and "down", 300 ms each, one at a time with a pause in between. Check that the button is released by "Stop", by losing Wi-Fi or Home Assistant, when the time runs out and before an over-the-air update.
  3. With the desk standing still, check that the height in Home Assistant matches the handset display. Recall a preset: the preset height the handset flashes on its display must not end up in Высота стола.
  4. Clear the space above and below the desk and set a height 2–3 cm above or below the current one. Note how long the desk takes to start (the handset wakes up first) and how far it coasts; adjust start_timeout_ms and stop_offset if needed. Try both directions and the height limits with a hand on the handset.
  5. Work out which preset is on which button and name them in k3_name…k6_name. There's no need to hold preset buttons for long.

Tests on a PC

You need a C++20 compiler, CMake and Ninja:

powershell
cmake -S . -B build/host -G Ninja
cmake --build build/host
ctest --test-dir build/host --output-on-failure

The tests cover parsing the handset data, checksums, working out the height, rejecting broken data and the counters, and they run moves to a height against a simulated desk. On Windows without a C++ compiler you can pip install ziglang and point CMake's CMAKE_CXX_COMPILER at zig.exe, with CMAKE_CXX_COMPILER_ARG1=c++.

License

MIT

Parts

31
QtyValueFootprintReferences
7100kResistor_SMD:R_0603_1608MetricR1, R2, R3, R4, R5, R6, R7
74.7kResistor_SMD:R_0603_1608MetricR8, R9, R10, R11, R12, R13, R14
7MMBT3904Package_TO_SOT_SMD:SOT-23_HandsolderingQ1, Q2, Q3, Q4, Q5, Q6, Q7
3M2Shapdesk:MountingHole_2.5mm_M2H1, H2, H3
210uFCapacitor_SMD:C_0805_2012MetricC1, C2
110kResistor_SMD:R_0603_1608MetricR15
118kResistor_SMD:R_0603_1608MetricR16
1Conn_02x05Connector_PinHeader_2.54mm:PinHeader_2x05_P2.54mm_HorizontalJ1
1ESP32-C3 SuperMiniShapdesk:ESP32-C3_SuperMini_2x08U1
1ME6211C33M5G-NPackage_TO_SOT_SMD:SOT-23-5U2

Similar boards

  • 4 layers78 × 50.9 mmCB-01, the printed circuit board in 3D

    CB-01

    ayaxan7/CB-01

    NeonCore is a cyberpunk-inspired electronic badge built around the RP2040 microcontroller. The project combines embedded hardware with custom PCB artwork, resulting in a compact development badge that is both functional…

    68 parts
  • 4 layers82 × 62 mmTelematics tracker, the printed circuit board in 3D

    Telematics tracker

    Immanueldavidckp/schematics

    CAN-connected GPS/LTE tracker for rental MEWPs (boom/scissor lifts). Powered from machine batteries with internal Li-ion backup, 2 isolated digital inputs, 2 low-side outputs, ignition sense, 6-axis IMU, and ≥6 days of…

    216 parts
  • 2 layers87.8 × 59.8 mmFreeDeck SMD 2020-02, the printed circuit board in 3D

    FreeDeck SMD 2020-02

    FreeYourStream/freedeck-hardware

    all the stuff you need to build your own FreeDeck

    37 parts772
  • 2 layers83.2 × 40 mmSmartdisplay, the printed circuit board in 3D

    Smartdisplay

    BearLaboratory/smartdisplay-hardware

    2.9寸墨水屏个人显示终端硬件显示

    46 parts175GPL-3.0
  • 2 layers35.4 × 27 mmWifiaudio, the printed circuit board in 3D

    Wifiaudio

    BearLaboratory/wifiaudio-tx-hardware

    WiFi无线麦克风硬件pcb设计

    29 parts110GPL-3.0
  • 4 layers50 × 50 mmHSCanT, the printed circuit board in 3D

    HSCanT

    cherry-embedded/HSCanT-hardware

    HSCanT is a USB to 4-channel CAN FD tool designed based on the HPM5321 chip.

    130 parts52Apache-2.0
  • 4 layers72.4 × 44.4 mmBtmdpcb v04 eval, the printed circuit board in 3D

    Btmdpcb v04 eval

    17o2/bluetooth-minidisc

    Adding built-in bluetooth connectivity to a 20-year-old Mindisc player

    115 parts45

Questions

How big is the Shapdesk rev2 PCB?

It measures 91.2 × 18 mm and has 2 copper layers, 1.6 mm thick.

What parts does the Shapdesk rev2 use?

31 parts, built around the ME6211C33M5G-N and MMBT3904. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Shapdesk rev2 KiCad files?

From the evgkg/shapdesk-esphome repository on GitHub, at the commit this page was made from: the board is hardware/pcb/shapdesk_rev2.kicad_pcb and its schematic hardware/pcb/shapdesk_rev2.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the Shapdesk rev2 design in my own project?

Its repository publishes it under the MIT licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).