diff --git a/openrtx/include/interfaces/platform.h b/openrtx/include/interfaces/platform.h index 360fa595..d2a8ca9a 100644 --- a/openrtx/include/interfaces/platform.h +++ b/openrtx/include/interfaces/platform.h @@ -54,7 +54,7 @@ void platform_init(); void platform_terminate(); /** - * This function reads and returns the current battery voltage. + * This function reads and returns the current battery voltage in volt. */ float platform_getVbat(); diff --git a/platform/targets/MD-UV380/platform.c b/platform/targets/MD-UV380/platform.c index e9f386e8..bda70ec2 100644 --- a/platform/targets/MD-UV380/platform.c +++ b/platform/targets/MD-UV380/platform.c @@ -118,7 +118,12 @@ void platform_terminate() float platform_getVbat() { - return adc1_getMeasurement(0); + /* + * Battery voltage is measured through an 1:3 voltage divider and + * adc1_getMeasurement returns a value in mV. Thus, to have effective + * battery voltage multiply by three and divide by 1000 + */ + return adc1_getMeasurement(0)*3.0f/1000.0f; } float platform_getMicLevel() diff --git a/platform/targets/MD380/platform.c b/platform/targets/MD380/platform.c index d4d35c4d..9ccb0626 100644 --- a/platform/targets/MD380/platform.c +++ b/platform/targets/MD380/platform.c @@ -85,7 +85,12 @@ void platform_terminate() float platform_getVbat() { - return adc1_getMeasurement(0); + /* + * Battery voltage is measured through an 1:3 voltage divider and + * adc1_getMeasurement returns a value in mV. Thus, to have effective + * battery voltage multiply by three and divide by 1000 + */ + return adc1_getMeasurement(0)*3.0f/1000.0f; } float platform_getMicLevel()