ESPHome 2026.11.0b6
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
7ESPHOME_LOG_TAG(TAG, "waveshare_io_ch32v003.sensor");
8
10 ESP_LOGCONFIG(TAG,
11 "WaveshareIOCH32V003Sensor:\n"
12 " Reference Voltage: %.2fV",
13 this->reference_voltage_);
14}
15
17 uint16_t adc_value = this->parent_->get_adc_value();
18 // Convert the ADC value to voltage. 10-bit ADC
19 float voltage = adc_value * this->reference_voltage_ / 1023.0f;
20 return voltage;
21}
22
24
25} // namespace esphome::waveshare_io_ch32v003
WaveshareIOCH32V003Component * parent_
Definition helpers.h:2171
void publish_state(float state)
Publish a new state to the front-end.
Definition sensor.cpp:65
ESPHOME_LOG_TAG(TAG, "waveshare_io_ch32v003.sensor")