Battery voltage(Battery)

method

Battery_init()

Initialized battery voltage measurement library

Get_Battery_Volotage(void)

Note: The power supply voltage output range of the Yahboom Self-balancing Robot is roughly between 8.5~12.5v

Get the actual battery voltage before voltage
The actual measurement value is a little lower than the value calculated

Return valuetype
Original voltage valuefloat

Battery_Get(uint8_t ch)

Get ADC measurement value

parametertypeAnnotation
chuint8_tADC channel
Return valuetype
Get the ADC valueuint16_t

Battery_Get_Average(uint8_t ch, uint8_t times)

Obtain ADC multiple measurement average

parametertypeAnnotation
chuint8_tADC channel
timesuint8_tMeasurement times
Return valuetype
Get the ADC valueuint16_t

Get_Measure_Volotage(void)

Get the original voltage value

Return valuetype
Original voltage valuefloat

Example


#include <bsp_battery.h>
int main()
{
    Battery_init();
    while(1){
        // Get the current power supply voltage
        float v = Get_Battery_Volotage();
    }
}