Implementing a calibrated ESP32 ADC reading

This commit is contained in:
code8buster
2023-05-13 20:38:37 -04:00
committed by Thomas Göttgens
parent 508cdf6060
commit d11bcda292
3 changed files with 89 additions and 28 deletions

View File

@@ -1,7 +1,8 @@
#pragma once
#include "PowerStatus.h"
#include "concurrency/OSThread.h"
#include <esp_adc_cal.h>
#include <soc/adc_channel.h>
/**
* Per @spattinson
* MIN_BAT_MILLIVOLTS seems high. Typical 18650 are different chemistry to LiPo, even for LiPos that chart seems a bit off, other
@@ -14,6 +15,10 @@
#define BAT_MILLIVOLTS_FULL 4100
#define BAT_MILLIVOLTS_EMPTY 3500
#ifdef BAT_MEASURE_ADC_UNIT
extern RTC_NOINIT_ATTR uint64_t RTC_reg_b;
#include "soc/sens_reg.h" // needed for adc pin reset
#endif
class Power : private concurrency::OSThread
{
@@ -45,4 +50,4 @@ class Power : private concurrency::OSThread
#endif
};
extern Power *power;
extern Power *power;