Making My 'Dumb' Treadmill Smart: A DIY Walking Desk Tracker with ESP32

Like many people these days, I spend a good chunk of my day working from home. To combat the sedentary nature of desk work, I integrated an old, basic treadmill into my setup, creating a walking desk. It’s great for staying active, but there was one problem: the treadmill is decidedly not smart. It has a power button, speed control and distance tracker for current session.

Being the kind of person who likes to quantify things (and tinker!), I wanted to know how much I was actually walking during the workday. Manually tracking felt cumbersome, so I decided to give my trusty old treadmill a bit of a brain transplant.

The Goal

Track treadmill usage automatically and send the data somewhere I could visualize it later.

The Hardware

The core components for this project are surprisingly simple and affordable:

  1. An ESP32-C3: I chose the ESP32-C3 specifically. It’s a fantastic little microcontroller with built-in WiFi and Bluetooth LE, plenty of processing power for this task, and it’s energy efficient. Perfect for an IoT project like this.
  2. An IR Reflective Sensor Module: These little modules (often TCRT5000 based) are great for detecting proximity or, in this case, changes in reflectivity. They emit infrared light and measure how much reflects back.

The Build: Low-Tech Meets High-Tech

Getting the sensor mounted was perhaps the most “DIY” part of the project. I needed the sensor to detect each revolution of the treadmill belt. My sophisticated mounting solution? A trusty hot glue gun!

I positioned the IR reflective sensor module on the side casing of the treadmill, pointing downwards towards the edge of the belt.

But how does it detect rotation? The black treadmill belt itself doesn’t reflect IR light well. So, I added a small, highly reflective mark on the belt. My high-tech tool for this: a white magic marker. I simply drew a thick white dot on the belt.

Now, every time the white dot passes under the sensor, the IR light reflects strongly, triggering the sensor. Each trigger equals one revolution of the belt. Simple, effective, and … permanent!

The Brains: ESP32 Code

The ESP32-C3 runs code (written using the Arduino framework) that does the following:

  1. Listens: It constantly monitors the IR sensor pin. I initially set it up using interrupts for maximum responsiveness, but included a polling fallback just in case.
  2. Counts: When the white dot triggers the sensor (a reflection is detected), it increments a counter for belt revolutions. It applies a simple debounce logic to avoid false triggers.
  3. Aggregates: It keeps track of revolutions per minute.
  4. Connects: It uses its built-in WiFi to connect to my home network.
  5. Syncs Time: It uses NTP (Network Time Protocol) to get the current accurate time, which is crucial for timestamping the data correctly.
  6. Uploads: Periodically (e.g., every few minutes or when a buffer fills up), it bundles the minute-by-minute revolution data into JSON format and sends it over HTTPS to a cloud database (I’m using Supabase for this project).

The code handles WiFi disconnections, time synchronization issues, and ensures data is buffered if the network is temporarily unavailable.

(You’ll find the complete, cleaned-up code ready for your own experiments in the download section!)

Visualizing the Data

Of course, raw data in a database isn’t very motivating. I have another simple web application that pulls the data from Supabase and displays daily/weekly/monthly walking distance and speed on a dashboard. It also pulls the data from Google Fit, so I can track my daily total walking distance.

Maybe I’ll detail that in a future post. Honestly, though, building that kind of dashboard visualization is becoming almost trivial these days. With modern AI tools, you can often generate a fully functional dashboard application in one shot without writing a single line yourself, just by describing what you need. It’s pretty amazing how quickly that space is evolving!

Conclusion

This was a fun little project that solved a real need for me. It brings modern tracking capabilities to an otherwise “dumb” piece of equipment using very accessible hardware. It’s satisfying to see the data roll in and quantify my movement throughout the workday, all thanks to a bit of hot glue, a magic marker, and the power of the ESP32.

If you have an old piece of equipment you wish were smarter, maybe a little DIY project is just what it needs!


Code for this project is available in the download section.