ESPHome 2026.3.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 {
6namespace mcp3008 {
7
8static const char *const TAG = "mcp3008.sensor";
9
11 ESP_LOGCONFIG(TAG,
12 "MCP3008Sensor:\n"
13 " Pin: %u\n"
14 " Reference Voltage: %.2fV",
15 this->pin_, this->reference_voltage_);
16}
17
19 float value_v = this->parent_->read_data(pin_);
20 value_v = (value_v * this->reference_voltage_);
21 return value_v;
22}
23
24void MCP3008Sensor::update() { this->publish_state(this->sample()); }
25
26} // namespace mcp3008
27} // namespace esphome
void publish_state(float state)
Publish a new state to the front-end.
Definition sensor.cpp:65
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7