8 namespace gp2y1010au0f {
10 static const char *
const TAG =
"gp2y1010au0f";
11 static const float MIN_VOLTAGE = 0.0f;
12 static 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)
virtual void turn_on()
Enable this binary output.
virtual void turn_off()
Disable this binary output.
void set_timeout(const std::string &name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a unique name.
uint32_t sample_duration_
voltage_sampler::VoltageSampler * source_
virtual float sample()=0
Get a voltage reading, in V.
void publish_state(float state)
Publish a new state to the front-end.
output::BinaryOutput * led_output_
uint32_t sample_wait_before_
Implementation of SPI Controller mode.
void IRAM_ATTR HOT delayMicroseconds(uint32_t us)
float voltage_multiplier_
void dump_config() override