How do I correctly power my analog speed meter with an ESP32?

Oct 29, 2026 Last reply: 14 hours ago 5 Replies

First reply

cporter82

You should definitely lean into the PWM approach for smooth movement, but you won't want to hardcode a lookup table for every single speed. The goal is interpolation between known points to avoid jumps. Think of it like mapping a curve instead of just finding discrete steps.…

Read the full reply

I just managed to salvage an old wind speed dial and I need some advice on powering it. It was originally meant for a generator and I'm trying to get it to show live data from a weather station using an ESP32. The meter has these terminals that are basially internal resistance taps.



I think I figured out that if I pull the wrong tap, the needle barely moves. If I use the higher resistance tap, I can actually move the needle, but the current drawn is really tiny. I am using one of the GPIO pins on the ESP32 to drive it.



My main question is about the software side. Since I can't use a massive current and I need fine control, should I be calculating the exact PWM duty cycle needed for a specific speed? Or is there a simpler way to map the microcontroller's output to the meter's specific resistance curve without having to hard code a table for every single RPM reading. I want the needle to glide smoothly between readings, not jump all over the place.


You should definitely lean into the PWM approach for smooth movement, but you won't want to hardcode a lookup table for every single speed. The goal is interpolation between known points to avoid jumps. Think of it like mapping a curve instead of just finding discrete steps. You need a control loop that constantly adjusts the duty cycle based on the desired speed. If your weather station gives you a new value, you calculate what the required voltage or current should be for that speed, then find the two closest known data points in your table. Then you mathematically blend the duty cycle settings of those two points to get a smooth transition. That prevents the needle from snapping from one value to the next, which is what gives it that gliding feeling you want. Since the meter response is linear between those known taps, a simple linear interpolation will handle most of the movement. Just treat your established data points as coordinates, where one axis is the desired speed and the other is the specific PWM value needed to hit that speed. When the input speed changes, you find where that new speed sits between two existing coordinate points and calculate the weighted average of the PWM values at those two points. This keeps the action fluid.

It is critical that you have a good baseline of readings first. Since you are using a continuous variable like speed, you need enough test points across the operating range to build a reliable curve. If you only test at 0, 30, 60, and 100, the needle will look jittery at 55. Once you have that set of known good points, then the interpolation software can take over and make it look professional. Don't just rely on eye-balling the adjustment; log the exact duty cycle you used every time you nail a reading to build a better calibration dataset. This method works becasue the microcontroller is just acting as a translator between the physics of the meter and the data coming in from your station. You aren't trying to brute force the voltage; you are finding the precise signal level that the meter requires at that exact moment. It turns a simple output into a finely tuned control system.

I dealt with a similar project hooking up an old pressure gauge to an Arduino years ago, and the biggest hurdle wasn't the math. The ESP32 GPIO pins just can't safely push enough current to move those vintage needles reliably, even if you are just driving a small resistance tap. For me, adding a small NPN transistor to buffer the signal made all the difference. It let me step up the drive current safely and hit the exact voltage points I needed to test my curve without frying the microcontroller. You're likely better off driving the transistor rather than trying to strain the GPIO pin directly.

I've run into this with older voltmeter setups too. The ESP32's internal ADC isn't great at handling noisy signals, even if the voltage looks stable. If you are driving that resistance tap, you should add a simple capacitor right across the meter terminals. This helps smooth out the electrical ripple from the ESP32's switching before it hits the delicate internal mechanism. I found that smoothing the input voltage really cut down on the needle jitter I was seeing on a salvaged analog water level gauge.

I’m not sure about relying on simple linear interpolation to map that drive signal. While the voltage might change linearly, the actual mechanical movement of those old dials is almost never perfectly linear across the whole range. When you push the current a little bit, the needle might jump way more than the math predicts.

I once tried doing something similar with an old solenoid valve and noticed the actuation pressure didn't scale evenly with the electrical input signal. You’ll prolly end up with a 'dead zone' or a sudden spike in speed that your math won't account for unless you model the entire physical curve, wich gets much more complicated than just blending two points.

Update: I stuck a capacitor across the meter terminals like one of you suggested and the needle judder is way down, so that was a win. But the nonlinearity comment really hit home. Near zero mine barely twitches, then halfway up it swings fast. I started logging the duty cycle against needle position by hand to build my own curve. Does anyone else find the low end needs a bit of a nudge before it even starts moving?

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required