ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
bh1745.h
Go to the documentation of this file.
1#pragma once
2
6
7namespace esphome::bh1745 {
8
9enum class MeasurementTime : uint8_t {
16};
17
18enum class AdcGain : uint8_t {
19 ADC_GAIN_1X = 0,
20 ADC_GAIN_2X = 1,
21 ADC_GAIN_16X = 2,
22};
23
25 SUB_SENSOR(red_counts)
26 SUB_SENSOR(green_counts)
27 SUB_SENSOR(blue_counts)
28 SUB_SENSOR(clear_counts)
29 SUB_SENSOR(illuminance)
30 SUB_SENSOR(color_temperature)
31
32 public:
33 void setup() override;
34 void dump_config() override;
35 void update() override;
36
37 void set_measurement_time(MeasurementTime measurement_time) { this->measurement_time_ = measurement_time; }
38 void set_adc_gain(AdcGain adc_gain) { this->adc_gain_ = adc_gain; }
39 void set_glass_attenuation_factor(float factor) { this->glass_attenuation_factor_ = factor; }
40
42 void enable_interrupt_output() { this->interrupt_output_ = true; }
43 void set_interrupt_state(bool on);
44
45 protected:
47 float lux_scale_{1.0f}; // 160 / (gain * integration time * glass attenuation), set in setup()
50 bool busy_{true}; // cleared once the chip is configured after the reset
51 bool interrupt_output_{false};
52};
53
54} // namespace esphome::bh1745
virtual void setup()
Where the component's initialization should happen.
Definition component.cpp:84
This class simplifies creating components that periodically check a state.
Definition component.h:514
MeasurementTime measurement_time_
Definition bh1745.h:48
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:132