ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
gp2y1010au0f.h
Go to the documentation of this file.
1#pragma once
2
7
8namespace esphome::gp2y1010au0f {
9
11 public:
12 void update() override;
13 void loop() override;
14 void dump_config() override;
15 float get_setup_priority() const override {
16 // after the base sensor has been initialized
17 return setup_priority::DATA - 1.0f;
18 }
19
21 void set_voltage_refs(float offset, float multiplier) {
22 this->voltage_offset_ = offset;
23 this->voltage_multiplier_ = multiplier;
24 }
26
27 protected:
28 // duration in ms of the sampling phase
30 // duration in us of the wait before sampling
31 // ref: https://global.sharp/products/device/lineup/data/pdf/datasheet/gp2y1010au_appl_e.pdf
33 // duration in us of the wait after sampling
34 // it seems no need to delay on purpose since one ADC sampling takes longer than that (300-400 us on ESP8266)
35 // uint32_t sample_wait_after_ = 40;
36 // the sampling source to read voltage from
38 // ADC voltage reading offset
39 float voltage_offset_ = 0.0f;
40 // ADC voltage reading multiplier
41 float voltage_multiplier_ = 1.0f;
42 // the binary output to control the sampling LED
44
45 float sample_sum_ = 0.0f;
47 bool is_sampling_ = false;
48};
49
50} // namespace esphome::gp2y1010au0f
This class simplifies creating components that periodically check a state.
Definition component.h:585
void set_voltage_refs(float offset, float multiplier)
void set_led_output(output::BinaryOutput *output)
void set_adc_source(voltage_sampler::VoltageSampler *source)
float get_setup_priority() const override
voltage_sampler::VoltageSampler * source_
Base-class for all sensors.
Definition sensor.h:47
Abstract interface for components to request voltage (usually ADC readings)
constexpr float DATA
For components that import data from directly connected sensors like DHT.
Definition component.h:43
static void uint32_t