How to connect APM Power Meter to Cleanflight and INAV

This topic was eluding me for some time now. It’s time fix the problem and finally present a short tutorial how to connect 90A APM Power Meter for flight controller boards like Naza32, SP Racing F3 or any other running Cleanflight / Betaflight / INAV software and equipped with Current Meter ADC input.

I will not show where to connect APM Power Meter to flight controller, since this differs from board to board. Some boards have dedicated pins, on some boards PWM input pins are used for Current Meter ADC. You have to refer FC documentation and / or flight controller software documentation.

Pinout of APM Power Meter is pretty simple. Battery power leads, power leads for motors (module measures power going from battery to motors) and 4 THT pins:

  • 5V – supplying 5V obviously, so it can be used as a BEC
  • Current – voltage on this pin depends on current flow. It is 0V when 0A goes through the module, and 5V when 90A goes through it. This is a pin we have to connect to flight controller
  • Voltage – this is input voltage divided by 2. So, 12.6V on input will result in 6.3V on this pin. In our case it is useless, so we can ignore it
  • GND – ground

There is also a 6pin JST connector. When JST is used, then its lines are (from top to bottom like on a picture above): 5V, 5V, Current, Voltage, GND, GND.

Like I mentioned, this module outputs 5V when 90A is measured. This creates a problem. All STM32F3 boards runs 3.3V. While they might be 5V tolerant, analog inputs will not accept 5V!. This is why, we have to scale analog 0-5V to 0-3.3V or less. Or less is quite important here. 0-2.5V would do too. And 1/2 voltage divider is super simple. Just look here:

Two resistors and that’s all! I’ve used 220kOhm resistors here. In theory you can use any other resistance, but there is a catch: both INA169 and ADC input have some internal resistance that interacts with voltage divider. If you will use too small resistors, it would no longer be 1/2. Bottom line, I’ve found out that 220kOhm does pretty good job.

Software

Once APM Power Module is connected to flight controller, we have to enable and configure it. Use Configurator software and enable it.

There is one more step we have to take: calibrate the meter. This is done via Scale the output voltage to milliamps [1/10th mV/A] setting. Default value of 400 will not work of course in our case.

In theory, our meter provides 55.5mV/A, so the case should be 555. We have divided it by 2, so scale should be somewhere around 277. Since ADC also has some internal resistance that interacts with the divider, I’ve discovered, that scale of 180 (for 220kOhm resistors) is the point of entry for further calibration.

Calibration

Without quite expensive stand-alone current meter, proper calibration can not be done. But, there is a simplified version that gives pretty good results too. Since most battery changers displays how much current were put into battery, we can use that value and calibrate APM Power Module. It will not be super accurate, but accurate enough for amateur usage.

In our case, procedure would look like this:

  • Take a fully charged battery, put it into UAV and go flying
  • Fly for about 30% of normal flight time you get from this battery
  • Land, connect UAV to Configurator software and write down how much current our meter reported. Do not power cycle before writing that down!
  • Disconnect battery, go home and put into the charger and do full change (with balance) on low current
  • When done, write down how much current charger put into the battery

Example data might look like this:

  • Current Scale: 180
  • Charge measured by Power Meter: 1800mAh
  • Charge measured by Charger: 1600mAh

If charge reported by the charger is lower that the one reported by flight controller, we have to raise Current Scale. If it is bigger, we have to lower it. You can use following equation:

[New Scale] = ([Charge Meausred By Meter] / [Charge Measure By Charger]) * [Current Scale]

So, in this case: (1800 / 1600) * 180 = 202

Update FC configuration with new scale and repeat whole procedure to confirm. If both charge values will be pretty close to each other (few percents), calibration is done.

4 thoughts on “How to connect APM Power Meter to Cleanflight and INAV

  1. Hi! This tutorial is awesome! I’ll try it. I’ve connected the APM Power Module Current output directly to my SP Racing F3 Current Input, and I just can’t make it work… It always measure the current incorrectly.

    So, can you tell something about the “Offset in milivolts to miliamps” variable?

    Thanks

    1. In most cases you could just ignore offset. To calibrate it you would need a calibrated current meter and compare results over time. Not possible to do only with charger method

Leave a Reply

Your email address will not be published.