ESPHome 2025.5.0
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
13 ESP_LOGCONFIG(TAG, "MCP3008Sensor:");
14 ESP_LOGCONFIG(TAG, " Pin: %u", this->pin_);
15 ESP_LOGCONFIG(TAG, " Reference Voltage: %.2fV", 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
float get_setup_priority() const override
void publish_state(float state)
Publish a new state to the front-end.
Definition sensor.cpp:39
const float DATA
For components that import data from directly connected sensors like DHT.
Definition component.cpp:19
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7