ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
mcp3008_sensor.cpp
Go to the documentation of this file.
1#include "mcp3008_sensor.h"
2
3#include "esphome/core/log.h"
4
5namespace esphome::mcp3008 {
6
7static const char *const TAG = "mcp3008.sensor";
8
10 ESP_LOGCONFIG(TAG,
11 "MCP3008Sensor:\n"
12 " Pin: %u\n"
13 " Reference Voltage: %.2fV",
14 this->pin_, this->reference_voltage_);
15}
16
18 float value_v = this->parent_->read_data(pin_);
19 value_v = (value_v * this->reference_voltage_);
20 return value_v;
21}
22
23void MCP3008Sensor::update() { this->publish_state(this->sample()); }
24
25} // namespace esphome::mcp3008
void publish_state(float state)
Publish a new state to the front-end.
Definition sensor.cpp:68