Gradiometer - A Handheld Magnetic Gradiometer on an ESP32-S3
Hi, I'm Jess.
See, I wanted to be able to see the magnetic field of something small and nuanced. In part, to confirm the validity of my Sitter physics engine, and also to help me with my various guitar pickup related experiments.
So, what the heck is a gradiometer?
Well, you know how a compass always points north? That's because of the Earth's magnetic field, which is basically everywhere, all the time, going through your desk and your house and you. A magnetometer measures that field right where it's sitting, how strong it is and which way it points. The thing is, it can't tell you where any of it is coming from. The Earth, the wiring in your walls, the magnet on your fridge... it all just adds up into one number, and if what you're looking for is small and close by, the rest of it is noise.
Now, take two of them, and put them a little ways apart. Anything far away hits both of them just about the same, so if you subtract one reading from the other, it cancels out. It's equal and opposite, so the net is 0. But anything close to the board hits the nearer sensor harder than the other one, so it doesn't cancel, and what's left over is the gradient: how fast the field changes over distance. That's what a gradiometer measures.
It's an ESP32-S3 with two TMAG5170 3D Hall-effect sensors, which are the two halves of the gradiometer, plus a VL53L4CX time-of-flight sensor so it knows how far away the thing it's pointed at is, and every reading can be tied to the distance it was taken at. Each sensor gets its own power rail off of an NCP163 regulator that the ESP32 can switch on and off. And then I added a display and some hardware buttons.
The firmware is written in embassy-rs. The two magnetometers share one SPI bus, each with its own chip select, which means they get read one after the other and not at the exact same moment. For a gradiometer that matters, since the whole point is subtracting two readings that are supposed to be from the same instant, and if the field moves in between them, that shows up in the difference like it's real. So I read them back to back with as little in between as I can, which keeps that gap small enough that it doesn't get in the way of what I'm measuring.
I can see through the entire design process from making a PCB from scratch, assembling it myself, programming the board, understanding the chips, writing a powerful multiplatform application for interfacing...
The app is just called Gradiometer. It connects to the board and shows the readings from both sensors live, along with the gradient between them.

Developed for: macOS, iOS and iPadOS
- Jess