7 static const char *
const TAG =
"mcp3008";
12 ESP_LOGCONFIG(TAG,
"Setting up mcp3008");
17 ESP_LOGCONFIG(TAG,
"MCP3008:");
18 LOG_PIN(
" CS Pin:", this->
cs_);
22 uint8_t data_msb, data_lsb = 0;
24 uint8_t command = ((0x01 << 7) |
35 int data = data_msb << 8 | data_lsb;
37 return data / 1023.0f;
47 ESP_LOGCONFIG(TAG,
"MCP3008Sensor:");
48 ESP_LOGCONFIG(TAG,
" Pin: %u", this->
pin_);
void dump_config() override
float get_setup_priority() const override
const float DATA
For components that import data from directly connected sensors like DHT.
float get_setup_priority() const override
This class simplifies creating components that periodically check a state.
uint8_t transfer_byte(uint8_t data)
void dump_config() override
void publish_state(float state)
Publish a new state to the front-end.
float read_data(uint8_t pin)
const float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
MCP3008Sensor(MCP3008 *parent, uint8_t pin, float reference_voltage)