ESPHome 2025.5.0
Loading...
Searching...
No Matches
gp2y1010au0f.h
Go to the documentation of this file.
1#pragma once
2
7
8namespace esphome {
9namespace gp2y1010au0f {
10
12 public:
13 void update() override;
14 void loop() override;
15 void dump_config() override;
16 float get_setup_priority() const override {
17 // after the base sensor has been initialized
18 return setup_priority::DATA - 1.0f;
19 }
20
22 void set_voltage_refs(float offset, float multiplier) {
23 this->voltage_offset_ = offset;
24 this->voltage_multiplier_ = multiplier;
25 }
27
28 protected:
29 // duration in ms of the sampling phase
30 uint32_t sample_duration_ = 100;
31 // duration in us of the wait before sampling
32 // ref: https://global.sharp/products/device/lineup/data/pdf/datasheet/gp2y1010au_appl_e.pdf
33 uint32_t sample_wait_before_ = 280;
34 // duration in us of the wait after sampling
35 // it seems no need to delay on purpose since one ADC sampling takes longer than that (300-400 us on ESP8266)
36 // uint32_t sample_wait_after_ = 40;
37 // the sampling source to read voltage from
39 // ADC voltage reading offset
40 float voltage_offset_ = 0.0f;
41 // ADC voltage reading multiplier
42 float voltage_multiplier_ = 1.0f;
43 // the binary output to control the sampling LED
45
46 float sample_sum_ = 0.0f;
47 uint32_t num_samples_ = 0;
48 bool is_sampling_ = false;
49};
50
51} // namespace gp2y1010au0f
52} // namespace esphome
This class simplifies creating components that periodically check a state.
Definition component.h:301
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:57
Abstract interface for components to request voltage (usually ADC readings)
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