Files
gaoguangpu/src/adc.cpp
2026-01-15 15:00:21 +08:00

26 lines
422 B
C++

#include "adc.h"
//电源电压测量
void adc_init()
{
pinMode(ADC_PIN,ANALOG);
analogReadResolution(12);
}
float adc_read()
{
float Value =0;
float power =0;
for(uint8_t i = 0; i < 10; i++)
{
Value = analogRead(ADC_PIN);
power += (Value * 3.3 / 4095.0) * 11;
}
power = power / 10.f + 0.51;
// write_log(log_path,"power: " + String(power),10);
return power;
}