SmartDesk: Transform Your Desk to Transform Your Health.

by Maarten Schaep in Circuits > Raspberry Pi

47 Views, 1 Favorites, 0 Comments

SmartDesk: Transform Your Desk to Transform Your Health.

IMG_20250618_214247838~2 (2).jpg

For my project at MCT in Howest, I made SmartDesk, it is a smart device that you can put on top of any standing desk (or normal desk). It measures the time you stand and sit. You can also see insights like weekly history and the evolution compared to the previous week. It also supports multiple users using an RFID scanner and a login system using JWT.


Everyone knows that people sit too much, so I wanted to make something that could help people sit less. People often buy height adjustable desks to try to stand more. Like many people, I often forget to switch positions and end up sitting all day. So I wanted to make something to fix that, something to blend into your life that gives you insights in how much you stand and sit in a day and the evolution of it. I also wanted to make it remind you to change positions or even change it automatically.

Supplies

To make SmartDesk you need the following supplies:

  1. 1x Raspberry Pi 5 (I used the 4GB model, but you can use any model, a Pi 4 should also work)
  2. 1x Micro sd card (Minimum 16GB)
  3. 1x Raspberry Pi power supply
  4. Flat cable and T GPIO extension board(optional but useful)
  5. 2x servo motors
  6. 1x passive buzzer
  7. 1x rfid-sensor (rc522) (with badge)
  8. 1x ultrasonic sensor (hc-sr04)
  9. 1x Time of Flight sensor (VL53L0X)
  10. 1x Breadboard power supply 3.3V and 5V
  11. 1x AC/DC adaptor 12V
  12. 1x OLED display (ssd1309)
  13. 2x Breadboard
  14. 1x Arduino Uno R3 (with USB A-B cable)
  15. 1x Logic level shifter (for 3.3V to 5V and vice versa)
  16. wires
  17. a button (if you have a Pi 5 this is optional as you can also use the built in button to shutdown the device)
  18. resistors (100Ohm, 220Ohm, 1kOhm, 2kOhm)
  19. screws
  20. 2x hinges
  21. 10x angle brackets
  22. wood (12mm MDF)
  23. wood glue
  24. electrical tape (to cover the angle brackets)

And the folowing tools:

  1. Soldering iron (some of the components' pins aren't soldered yet)
  2. Drill
  3. jigsaw
  4. screwdriver


The total price if you already have a desk is around 200 euros. If you still need a desk the total price will be around 650 euros.

You can find more info and links in the BOM attached.

Electronics

SchaepMaarten_fritzing_breadboard_final.png
SchaepMaarten_fritzing_schematic_final.png
IMG_20250616_163554004 (2).jpg

Connect all the electronics according to the included schemas (pdfs's are attached if you want to zoom in).

The wires that connect the arduino to the Raspberry Pi are optional as you can also plug in the USB A-B cable to the Pi and communicate that way.

Color code:

  1. Red: 5V
  2. Orange: 3.3V
  3. Black: GND


Cutting the Wood

IMG_20250609_095123550.jpg
IMG_20250609_095027713.jpg
IMG_20250609_094950312.jpg
IMG_20250609_094958540.jpg
IMG_20250609_094944527.jpg
IMG_20250609_095011724.jpg
IMG_20250609_094725258.jpg
IMG_20250616_214540219.jpg

Cut the following pieces out of wood:

  1. 23.5cm x 15cm with a 3cmx3cm hole 6 cm from the top for the RFID tag
  2. 4cm x 15cm
  3. 31.5cm x 15cm
  4. 28.5cm x 15cm with a hole of 4cmx2cm 3 cm from the side, 1cm from the bottom
  5. 20cm x 15cm
  6. 10cm x 15cm with the long sides angled at 30 degrees and a small hole for the wires of the oled and 2 round holes for the ultrasonic sensor
  7. 2x 35cm (right) x 26cm (top) x (20cm, 9cm 30 degrees, 5cm)(left) x 21.5cm bottom
  8. 23cm x 3cm with a hole of 14x 1.2 2 cm from the side and another hole 1.5x1 2cm from the other side
  9. 23cm x 3cm with a hole of 1.5x1 2 cm from the side and 2 other small 1x2 holes for the wires of the servomotors
  10. (optional) thin wooden planks to change the height of the SmartDesk depending on the height of the buttons of your standing desk

Connecting Everything

IMG_20250609_121645826.jpg
IMG_20250609_101407904.jpg
IMG_20250609_100559199.jpg
IMG_20250609_101410269.jpg
IMG_20250609_102141259.jpg
IMG_20250609_100546049.jpg
IMG_20250609_104839231.jpg
IMG_20250618_210434088.jpg

Attach the sides to the base plate

Use angle brackets to attach all the sides to the base plate, and use additional angle brackets to attach the sides to eachother to improve the sturdiness.

Attach the cover using hinges

Use 2 hinges to attach the cover to the long side.

Make the servomotors enclosure

Take the 2 small wooden planks with holes for the servos and glue them together. After they are glued together, glue this to the base plate.

Screw the components into the rest of the enclosure

Finally screw the RFID and OLED into the wood. Optionally you can also screw in the Time of Flight sensor and the ultrasonic sensor, but they should be secure enough to not need screws. You can also screw in the raspberry pi and arduino if you want.

Code

mockup.png

Info

I used FastAPI for the backend server, the webserver runs via apache2. The frontend is made using vanilla JavaScript, CSS and HTML. I used MySQL/MariaDB for the database.


Features

Hardware:

  1. Badging system to keep track of multiple users
  2. Keeps track of desk height and presence.
  3. Shows current status on the OLED display
  4. Servo motors to automatically change height or manually via the web dashboard
  5. Buzzer to give feedback to the user
  6. A button to poweroff the device

Web dashboard (mobile first):

  1. Login and registration system
  2. Dashboard page to see current status, daily data (how much time spent sitting and standing), poweroff the device, change height
  3. An analytics page to see weekly data and evolution, split into sitting and standing
  4. A settings page to change sitting/standing goals, preferred height and set up reminders


Installation steps

  1. Write Raspberry OS to you micro SD card. You can do so by downloading the official raspberry pi imager. (Don't forget to enable SSH if you want to connect to it via another PC/laptop instead of using an external display and keyboard)
  2. Install apache2 (run: apt install apache2 -y), also give apache the correct permission so it can serve the website
  3. Install mariadb (run: apt install mariadb-server mariadb-client -y)
  4. run mysql_secure_installation to secure mysql
  5. press enter when asked for root password as there is none (unless you already changed that, if so enter the current root password)
  6. it now asks some more questions, you can choose whether you want them or not, I did y on everything
  7. use SET PASSWORD = PASSWORD('your_password'); and replace your_password with a password that you choose (remember this one as it is important to connect with the db)
  8. Execute the sql script


Downloading the code

Clone the repository. You can do so easily by connecting to the raspberry pi using SSH in Visual Studio Code. To do that you need to install the extension Remote SSH. After you are connected you can use the built-in github feature to clone a repository.


Creating a venv

Create a venv once you are in the repo by executing: python3 -m venv venv


Installing packages

Install the requirements by running: pip install -r requirements.txt


Configuration

Rename config_example.py to config.py and use the password and username of the database (Password from the secure_installation step and username is by default root).


Database

smartdesk.png

In the image above you can find the database scheme, you can also find the .sql file on my github.