Skip to content
Michael Palcowski

← All builds

DeltaShifter + DeltaCam

2026 · C++, nRF52840, ESP32-S3

Firmware that reads a magnet on my Delta's gear lever, learns where each gear sits and tells my phone. Plus a rear camera.

Why I built it

DeltaSpeedo, my iPhone dash app for the Delta, has room for a big red gear digit. Something has to tell it which gear I’m in. So I put a neodymium magnet on the gear lever and a sensor next to it.

The sensor is a TMAG5273 Hall sensor on an Adafruit board. It measures magnetic field in three directions at once, so each gear leaves its own magnetic fingerprint. The brain is a Seeed XIAO nRF52840, a thumb-sized microcontroller with Bluetooth built in. It learns the fingerprints and matches them.

How it works

  1. Read. 50 times a second, the board reads the field on all three axes, in millitesla (mT).
  2. Record. To map the car, I hold the lever in a gear and tap Record on the phone. The board averages one second of readings and saves that spot in its own flash memory, so it survives power-off and firmware updates. If the lever moved more than 1 mT, it refuses. If the spot lands within 2 mT of another gear, it warns me.
  3. Match. Once the lever holds still, the board picks the nearest recorded spot. A reading more than 10 mT from every spot shows as a dash. It doesn’t guess.
  4. Send. The gear goes to the phone over Bluetooth Low Energy as one character, repeated every second, so the phone can tell “still in 3rd” from “the board died.”

Any phone can read the gear. Changing the map needs a phone paired with a 6-digit PIN. The easy “Just Works” pairing would let any nearby phone wipe my calibration.

A desktop viewer in Python plots the field live and shows the same red digit as the app, so it doubles as a demo screen.

Chart of 68 seconds of magnetic field readings from the gear lever, with the recorded spot for each gear circled
My real drive log, plotted: 68 seconds, 50 readings a second, each dot colored by what the board picked: a gear, neutral or reverse. Circles are the spots I recorded. Neutral rests in more than one place, which is why it now gets up to three spots.

DeltaCam

Same repo, different board: a DFRobot ESP32-S3 AI Camera with a 160 degree lens, meant to sit inside the car looking out the back window. Bluetooth is far too slow for video, so it runs its own Wi-Fi network, and DeltaSpeedo shows the picture in reverse. The infrared LEDs stay off, because they’d reflect off the rear glass into the lens. It’s live view only.

What was hard

  • The tools. The compiler PlatformIO picked was Intel-only and wouldn’t run on my Apple Silicon Mac. Uploads from the Mac failed too, and the stock tool reported success anyway. A newer compiler and a small upload script fixed both.
  • The sensor library. On first power-up the sensor was found at 0x35, then every read went to 0x70, where nothing answers. The SparkFun library read two bytes into a one-byte space, and the extra byte overwrote a loop counter. Its axis math was also wrong for 255 readings out of 256. I dropped it. The firmware now talks to the chip directly and reads back every setting it writes.
  • Five versions of “which gear is this?” On the first run in the car, 2nd, 4th and reverse sat within 0.15 mT of neutral. That’s a sensor placement problem. First, the nearest spot inside a tight circle. A hand resting on the lever knocked it to a dash. Second, a small circle to enter a gear and a bigger one to stay. Engine rocking under load still knocked it out. Third, keep the gear until the lever enters another gear’s zone. Then I logged 68 seconds of driving. Every shift across the gate flashed N. And on this car the path from 4th to 5th runs right over reverse, so R showed for about 0.7 seconds mid-shift. Fourth, only change gear once the lever stops. That worked, but half a second of lag felt slow. Fifth, normal gears need 0.16 seconds of stillness and reverse needs 0.5, since I only select reverse when stopped. Typical lag is now 0.2 seconds. The last two settings came from replaying the drive log through the code.
  • Neutral wanders. The log showed neutral resting in several places, one as close to 5th as to the recorded N. So neutral gets up to three spots: left, middle and right of the gate.
  • Drift. If every reading slides the same way, from temperature or a stray field, the board could start showing 5th with the lever in neutral. Neutral can’t be the zero point to correct against, because it has no single resting place. So the fix learns the slide from 1st and 3rd, which sit far from everything else, and subtracts it. It ignores slides under 0.25 mT. Past 1.5 mT it stops and asks for a re-map.
  • The camera stalled. Its network send buffer is only 5.7 KB, so one lost packet freezes the stream for 1 to 3 seconds. At boot it now picks the least crowded of Wi-Fi channels 1, 6 and 11. On the bench, that took it from repeated stalls to a steady 5 to 10 frames per second at 1024×768.

Where it is now

The main branch has the stop-then-match rule, three neutral spots, mapping from the phone and the DeltaCam firmware. The drift correction is on a separate branch, not merged yet. Its 22 tests include a replay of my drive log with up to 1 mT of drift added. With the correction off, 7 of them fail.

Shifter Mapping screen in DeltaSpeedo
Mapping from the phone: hold the lever in a gear, tap Record.

I built it with Claude Code, Anthropic’s coding assistant. Every commit in the history is co-written with it.

More builds