ESPHome 2025.6.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,
14 "MCP3008Sensor:\n"
15 " Pin: %u\n"
16 " Reference Voltage: %.2fV",
17 this->pin_, this->reference_voltage_);
18}
19
21 float value_v = this->parent_->read_data(pin_);
22 value_v = (value_v * this->reference_voltage_);
23 return value_v;
24}
25
26void MCP3008Sensor::update() { this->publish_state(this->sample()); }
27
28} // namespace mcp3008
29} // 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:20
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7