ESPHome 2026.5.0-dev
Loading...
Searching...
No Matches
internal_temperature_ln882x.cpp
Go to the documentation of this file.
1#ifdef USE_LN882X
2
4
5extern "C" {
6uint16_t hal_adc_get_data(uint32_t adc_base, uint32_t ch);
7}
8
10
12 static constexpr uint32_t ADC_BASE = 0x40000800U;
13 static constexpr uint32_t ADC_CH0 = 1U;
14 static constexpr uint16_t ADC_MASK = 0xFFF;
15 static constexpr float ADC_TEMP_SCALE = 2.54f;
16 static constexpr float ADC_TEMP_OFFSET = 278.15f;
17 uint16_t raw = hal_adc_get_data(ADC_BASE, ADC_CH0);
18 float temperature = (raw & ADC_MASK) / ADC_TEMP_SCALE - ADC_TEMP_OFFSET;
19 this->publish_state(temperature);
20}
21
22} // namespace esphome::internal_temperature
23
24#endif // USE_LN882X
uint8_t raw[35]
Definition bl0939.h:0
void publish_state(float state)
Publish a new state to the front-end.
Definition sensor.cpp:68
uint16_t hal_adc_get_data(uint32_t adc_base, uint32_t ch)
static void uint32_t
uint16_t temperature
Definition sun_gtil2.cpp:12