ESPHome  1.17.2
mcp3008.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "esphome/core/esphal.h"
8 
9 namespace esphome {
10 namespace mcp3008 {
11 
12 class MCP3008 : public Component,
13  public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW, spi::CLOCK_PHASE_LEADING,
14  spi::DATA_RATE_75KHZ> { // Running at the slowest max speed supported by the
15  // mcp3008. 2.7v = 75ksps
16  public:
17  MCP3008() = default;
18 
19  void setup() override;
20  void dump_config() override;
21  float get_setup_priority() const override;
22  float read_data(uint8_t pin);
23 
24  protected:
25 };
26 
28  public:
29  MCP3008Sensor(MCP3008 *parent, std::string name, uint8_t pin, float reference_voltage);
30 
31  void set_reference_voltage(float reference_voltage) { reference_voltage_ = reference_voltage; }
32  void setup() override;
33  void update() override;
34  void dump_config() override;
35  float get_setup_priority() const override;
36  float sample() override;
37 
38  protected:
40  uint8_t pin_;
42 };
43 
44 } // namespace mcp3008
45 } // namespace esphome
void dump_config() override
Definition: mcp3008.cpp:16
float get_setup_priority() const override
Definition: mcp3008.cpp:9
Abstract interface for components to request voltage (usually ADC readings)
This class simplifies creating components that periodically check a state.
Definition: component.h:210
void setup() override
Definition: mcp3008.cpp:11
float read_data(uint8_t pin)
Definition: mcp3008.cpp:21
void set_reference_voltage(float reference_voltage)
Definition: mcp3008.h:31
Library based on https://github.com/miguelbalboa/rfid and adapted to ESPHome by . ...
Definition: a4988.cpp:4
Base-class for all sensors.
Definition: sensor.h:33