Setting up Voltage Measurement on new board

I’m having trouble getting the battery voltage measurement from the HAKRC Mini F4 (a clone of OmnibusF4). I’m starting from this hwdef: ArduPilot/ardupilot#11678, which works well but doesn’t have the voltage measurement set up.

In the config for Betaflight, ADC_BATT is on C01. https://github.com/betaflight/unified-targets/blob/master/configs/default/HARC-HAKRCF405.config

So in my Ardupilot hwdef.dat, I put this: PC1 BAT_VOLT_SENS ADC1 SCALE(1)
And I see in STM32F405xx.py that PC1 maps to pin 11
So I put this in hwdef.dat: define HAL_BATT_VOLT_PIN 11
(Do I need to define it in hwdef.dat, or will setting the BATT_VOLT_PIN param to 11 after the build be sufficient?)

Anyway, this doesn’t give me the voltage and I’m not sure why. It is reading something; but definitely not the voltage. It does seem to be some ADC reading though. I’ve adjusted BATT_VOLT_MULT to yield a correct voltage with a 2s battery, but then when I switch to a 3s it’s not correct.

Any ideas of what I’m doing wrong here? Or any other helpful resources on working with hwdef?

you get the solution for that ? i am also facing same issue on my omnibusf4

I figured it out. It needs to be PC2 and pin 12. Which is how it was by default in that pull request I linked! Not sure how I got confused and thought it wasn’t working…

Part of my mistake was looking at the wrong Betaflight config. The one I linked is actually for a different HAKRC autopilot. For the Mini F4, it should be this one: https://github.com/betaflight/unified-targets/blob/master/configs/default/AIRB-OMNIBUSF4.config