8namespace gp2y1010au0f {
10static const char *
const TAG =
"gp2y1010au0f";
11static const float MIN_VOLTAGE = 0.0f;
12static const float MAX_VOLTAGE = 4.0f;
15 LOG_SENSOR(
"",
"Sharp GP2Y1010AU0F PM2.5 Sensor",
this);
16 ESP_LOGCONFIG(TAG,
" Sampling duration: %" PRId32
" ms", this->
sample_duration_);
18 LOG_UPDATE_INTERVAL(
this);
30 ESP_LOGD(TAG,
"ADC read voltage: %.3f V (mean from %" PRId32
" samples)", mean, this->
num_samples_);
34 int16_t pm_2_5_value = 170 * mean;
56 if (std::isnan(read_voltage))
59 if (read_voltage < MIN_VOLTAGE || read_voltage > MAX_VOLTAGE)
void set_timeout(const std::string &name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a unique name.
void dump_config() override
uint32_t sample_wait_before_
uint32_t sample_duration_
float voltage_multiplier_
output::BinaryOutput * led_output_
voltage_sampler::VoltageSampler * source_
virtual void turn_off()
Disable this binary output.
virtual void turn_on()
Enable this binary output.
void publish_state(float state)
Publish a new state to the front-end.
virtual float sample()=0
Get a voltage reading, in V.
Providing packet encoding functions for exchanging data with a remote host.
void IRAM_ATTR HOT delayMicroseconds(uint32_t us)