Awhile back I bought one of these cheap low-current ammeters (30 mA in this case) with the intention of using it to get more precise readings on how much current some of my devices were using. I promptly forgot about it for two years, and recently when looking over my hoard inventory of electronic components I came across it and had an idea: what if instead of using it to measure current, I pumped current through it using a microcontroller GPIO? Would I be able to use it as a display for data? Turns out the answer is yes!
There are a few prerequisites for this to work. First, you need an ammeter with a maximum range current that is equal to or lower than the maximum amount of current that a GPIO can output. For most ESP32-based boards, this is ~40 mA for most GPIO. You'll need to check your microcontroller's data sheet for exact spec. Next, you'll need a microcontroller with PWM-capable GPIO. This is important because the PWM duty cycle will determine how much current we push to the ammeter, which will determine where the needle goes. Lastly, you'll need a bit of creativity if deciding how to replace the stock face plate. For example, if you're trying to display C02 levels in your apartment, you probably don't want your display to show mA for the units, and you'll probably want to use a different scale than what's printed on the faceplate.
- You need a microcontroller with PWM-capable GPIO.
- You need a little bit of creativity for deciding how to replace the ammeter's face plate.
A cursory search for "low current analog ammeter" on Amazon will yield dozens of results, from at least as many brands. Generally, I look for the cheapest ones I can find at any given time, as long as they are within the max range of current provided by the microcontroller GPIO, and are the physical size I want. So far I've used ones ranging from a high end of 500μA to 30mA. Calibration for each display is as simple as changing a value in code, so you have a lot of flexibility here, though I would recommend trying to use ones that max out in the 20-30mA range, if possible. This provides a wider usage of the PWM spectrum, thus allowing for more granularity in values you can assign (for example, in my testing, with a 12-bit PWM resolution supporting a max value of 4095, the max value you can use for a 500μA display is around 300-400, while the max for a 30mA display is around 2600-3000. In practice, this hasn't been that big of a deal, but you will probably want to avoid going lower than 500μA as the range of values it will be able to display via PWM will be severely diminished.