second commit
This commit is contained in:
22
src/adc.cpp
Normal file
22
src/adc.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
#include "adc.h"
|
||||
|
||||
//电源电压测量
|
||||
|
||||
void adc_init()
|
||||
{
|
||||
pinMode(ADC_PIN,INPUT);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user