The Scroll Ruler: an AtomS3R on its Atomic Battery Base, with the Unit Scroll plugged in underneath and the screen reading 0.0 cm
Back to projects
Internship project

Scroll Ruler

I built this digital ruler during my internship at M5Stack from an AtomS3R and a Unit Scroll. You press the scroll wheel down and roll it along whatever you want to measure, and the screen shows the distance in centimetres.

Built with
ESP32-S3PlatformIO

Internship project at M5Stack, November 2026. M5Stack AtomS3R, Atomic Battery Base, Unit Scroll, C++.

Demo

I filmed this at my desk, first calibrating it over 10 cm of a ruler and then measuring three lengths along the same ruler.

Try it

This copy of the ruler runs the same logic as the firmware and starts on its calibration screen. Drag the Unit Scroll along the ruler to roll it with the wheel pressed down, which counts, or click the ruler to lift it and set it down somewhere else, which doesn’t. Tapping the screen saves a calibration or zeroes the reading, and holding it for a second starts a new calibration.

Calibrating: 0 steps so far. Roll exactly 10 centimetres with the wheel pressed, then release.

A calibration that isn’t exactly 10 cm throws every reading off by the same amount, here as on the real ruler.

How to use it

The AtomS3R’s whole screen is its button, so the ruler has only two controls: the scroll wheel, which you press down while you roll it, and the screen, which you tap or hold.

Measure

You press the wheel down and roll it forward, and the distance counts only while the wheel stays pressed, with the Unit Scroll’s LED glowing green and the reading turning green too. Releasing the wheel stops the count, and rolling backwards while it is pressed takes distance off again.

Tapping the screen sets the reading back to zero, and holding it for about a second starts a new calibration.

Rolling the 10 cm
Released, ready to save

Calibrate

The first time it starts, and whenever you ask it to, the ruler measures 10 cm to learn how far the wheel travels per step. You press the wheel and roll it exactly 10 cm along a real ruler, then release it and tap the screen to save the number of steps it counted.

Pressing the wheel again keeps adding to the same roll, and holding the screen starts it over. The calibration stays in flash, so it survives a power cut, and the direction you rolled it in becomes forward.

How fine it measures

The wheel only has so many steps in a turn, so the ruler measures in steps rather than smoothly. Mine counted 49 steps for 10 cm, which makes each step about 2 mm, and the screen shows the exact step length under every reading so you know how much to trust the last digit.

How it works

The Unit Scroll has its own small chip that counts the wheel’s steps and reads its button, and the AtomS3R asks it for both over I2C through the Grove port a hundred times a second. Each read returns the steps since the last one, and they only count toward the distance while the wheel is pressed.

I kept the ruler’s logic, which is the calibration and the distance maths, in one file with no hardware code in it, so eleven unit tests check it on a computer before it goes onto the device. If the Unit Scroll comes unplugged the screen says so, and it picks the unit back up as soon as it is plugged in again.

Hardware

  • AtomS3Rruns the ruler on its ESP32-S3, and its 0.85-inch screen is also its button.
  • Atomic Battery Baseholds the battery, so the ruler needs no cable.
  • Unit Scrollis the wheel you roll, with a push button and an RGB LED, and it plugs into the AtomS3R’s Grove port.
The ruler held up after the second run, its screen reading 8.2 cm, above the ruler it rolled along
After the second run in the demo

Setting one up

  1. Stack the AtomS3R on the Atomic Battery Base and plug the Unit Scroll into the AtomS3R’s Grove port.

  2. Open Flashdeck in Chrome or Edge, choose Scroll Wheel Ruler, plug the AtomS3R in over USB-C and press Install, which flashes the firmware straight from the browser.

  3. It starts on the calibration screen, so press the wheel and roll it exactly 10 cm along a ruler, then release it and tap the screen to save.

The GitHub repository has the firmware’s code, its unit tests and a download of the firmware image for flashing with esptool instead.

The AtomS3R on this page is rendered from M5Stack’s own model in M5_Hardware (MIT licence, copyright M5Stack), and its screens are drawn from the firmware’s own layout.

More to explore

Other projects

Personal
OCR Reader with DrumNet, an OCR water meter solution

OCR Reader

A battery-powered water meter reader where a 693K-parameter DrumNet pipeline on an ESP32-S3 reads the drums and reports over LoRaWAN, built on a custom KiCad PCB inside a 3D-printed shell.

Personal
Project June rover

Project June

A 5G rover with three live camera feeds, GPS, a laser pointer and seven sensors, driven from a web console.

Internship
Pip, a cyan desk pet, on the M5Stack Tab5

Pip

A desk pet on an M5Stack Tab5 whose brain is the DeepSeek Harness on my server, so it can drive a browser, build its own apps and watch my other agents.