ESPHome 2026.8.0-dev
Loading...
Searching...
No Matches
waveshare_io_ch32v003_sensor.cpp
Go to the documentation of this file.
2
3#include "esphome/core/log.h"
4
6
7static const char *const TAG = "waveshare_io_ch32v003.sensor";
8
10
12 ESP_LOGCONFIG(TAG,
13 "WaveshareIOCH32V003Sensor:\n"
14 " Reference Voltage: %.2fV",
15 this->reference_voltage_);
16}
17
19 uint16_t adc_value = this->parent_->get_adc_value();
20 // Convert the ADC value to voltage. 10-bit ADC
21 float voltage = adc_value * this->reference_voltage_ / 1023.0f;
22 return voltage;
23}
24
26
27} // namespace esphome::waveshare_io_ch32v003
WaveshareIOCH32V003Component * parent_
Definition helpers.h:1886
void publish_state(float state)
Publish a new state to the front-end.
Definition sensor.cpp:68
constexpr float DATA
For components that import data from directly connected sensors like DHT.
Definition component.h:45
const char *const TAG
Definition spi.cpp:7