parent
fc06da73f2
commit
e7d210c8cc
|
@ -42,12 +42,12 @@ double return_voltage_value(int pin_no)
|
|||
double ADCVoltage = 0;
|
||||
double inputVoltage = 0;
|
||||
double avg = 0;
|
||||
for (int i = 0; i < 150; i++)
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
tmp = tmp + analogRead(pin_no);
|
||||
}
|
||||
avg = tmp / 150;
|
||||
ADCVoltage = ((avg * 3.3) / (4095)) + 0.112;
|
||||
avg = tmp / 50;
|
||||
ADCVoltage = ((avg * 3.3) / (4095)) + 0.225;
|
||||
inputVoltage = ADCVoltage / (R2_VOLTAGE / (R1_VOLTAGE + R2_VOLTAGE)); // formula for calculating voltage in i.e. GND
|
||||
return inputVoltage;
|
||||
}
|
||||
|
@ -285,7 +285,7 @@ void loop()
|
|||
if (touch_touched[i]) {
|
||||
Serial.print(i);
|
||||
Serial.print(" control touched\t");
|
||||
running_type = touch_touched_times[i] % 6;
|
||||
running_type = touch_touched_times[1] % 6;
|
||||
Serial.println(running_type);
|
||||
|
||||
switch (i) {
|
||||
|
@ -396,7 +396,7 @@ void TenthSecondsSinceStartTask() //100ms
|
|||
bool battery_low = 0;
|
||||
void OnSecond()
|
||||
{
|
||||
#if defined(BAT_VOLTAGE_SENSE_PIN) //电池电压检测
|
||||
#if defined(INPUT_VOLTAGE_SENSE_PIN) //电池电压检测
|
||||
bat_voltage = return_voltage_value(INPUT_VOLTAGE_SENSE_PIN);
|
||||
if (bat_voltage < min_voltage && !battery_low) {
|
||||
battery_low = 1;
|
||||
|
@ -594,4 +594,4 @@ void StartWebServer()
|
|||
{
|
||||
ESP32Server.begin();
|
||||
ESP32Server.onNotFound(handleNotFound);//将所有请求导向自己处理的代码
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue