ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
veml6040.h
Go to the documentation of this file.
1#pragma once
2
6
7namespace esphome::veml6040 {
8
9// Register values for the IT bits of the configuration register, taken from the VEML6040 datasheet.
10// Each step doubles the integration time and halves the lux per count.
19
21 public:
23 float color_temperature_offset)
24 : glass_attenuation_factor_(glass_attenuation_factor),
25 color_temperature_offset_(color_temperature_offset),
27
28 void setup() override;
29 void dump_config() override;
30 void update() override;
31
32 void set_red_sensor(sensor::Sensor *sensor) { this->red_sensor_ = sensor; }
33 void set_green_sensor(sensor::Sensor *sensor) { this->green_sensor_ = sensor; }
34 void set_blue_sensor(sensor::Sensor *sensor) { this->blue_sensor_ = sensor; }
35 void set_white_sensor(sensor::Sensor *sensor) { this->white_sensor_ = sensor; }
38
39 protected:
40 bool read_channel_(uint8_t reg, uint16_t &counts);
41 uint32_t integration_time_ms_() const { return 40u << this->integration_time_; }
42
52 bool data_ready_{false};
53};
54
55} // namespace esphome::veml6040
This class simplifies creating components that periodically check a state.
Definition component.h:519
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:144
I2CRegister reg(uint8_t a_register)
calls the I2CRegister constructor
Definition i2c.h:164
Base-class for all sensors.
Definition sensor.h:47
bool read_channel_(uint8_t reg, uint16_t &counts)
Definition veml6040.cpp:63
sensor::Sensor * illuminance_sensor_
Definition veml6040.h:47
VEML6040Component(VEML6040IntegrationTime integration_time, float glass_attenuation_factor, float color_temperature_offset)
Definition veml6040.h:22
void set_blue_sensor(sensor::Sensor *sensor)
Definition veml6040.h:34
uint32_t integration_time_ms_() const
Definition veml6040.h:41
void set_color_temperature_sensor(sensor::Sensor *sensor)
Definition veml6040.h:37
void set_illuminance_sensor(sensor::Sensor *sensor)
Definition veml6040.h:36
void set_white_sensor(sensor::Sensor *sensor)
Definition veml6040.h:35
const VEML6040IntegrationTime integration_time_
Definition veml6040.h:51
sensor::Sensor * color_temperature_sensor_
Definition veml6040.h:48
void set_red_sensor(sensor::Sensor *sensor)
Definition veml6040.h:32
void set_green_sensor(sensor::Sensor *sensor)
Definition veml6040.h:33
IntegrationTime501 integration_time
@ VEML6040_INTEGRATION_TIME_1280MS
Definition veml6040.h:17
@ VEML6040_INTEGRATION_TIME_160MS
Definition veml6040.h:14
@ VEML6040_INTEGRATION_TIME_80MS
Definition veml6040.h:13
@ VEML6040_INTEGRATION_TIME_40MS
Definition veml6040.h:12
@ VEML6040_INTEGRATION_TIME_320MS
Definition veml6040.h:15
@ VEML6040_INTEGRATION_TIME_640MS
Definition veml6040.h:16
static void uint32_t