veml7700: Driver for VEML7700 ambient light sensor
Defines
- VEML7700_I2C_ADDR
- VEML7700_INTEGRATION_TIME_25MS
- VEML7700_INTEGRATION_TIME_50MS
- VEML7700_INTEGRATION_TIME_100MS
- VEML7700_INTEGRATION_TIME_200MS
- VEML7700_INTEGRATION_TIME_400MS
- VEML7700_INTEGRATION_TIME_800MS
- VEML7700_GAIN_1
- VEML7700_GAIN_2
- VEML7700_GAIN_DIV_8
- VEML7700_GAIN_DIV_4
- VEML7700_POWER_SAVING_MODE_500MS
- VEML7700_POWER_SAVING_MODE_1000MS
- VEML7700_POWER_SAVING_MODE_2000MS
- VEML7700_POWER_SAVING_MODE_4000MS
- VEML7700_PERSISTENCE_PROTECTION_1
- VEML7700_PERSISTENCE_PROTECTION_2
- VEML7700_PERSISTENCE_PROTECTION_4
- VEML7700_PERSISTENCE_PROTECTION_8
Functions
- esp_err_t veml7700_init_desc(i2c_dev_t *dev, i2c_port_t port, gpio_num_t sda_gpio, gpio_num_t scl_gpio)
Initialize device descriptor.
Default SCL frequency is 100kHz. The I2C address is fix.
- Parameters:
dev – Pointer to I2C device descriptor
port – I2C port number
sda_gpio – SDA GPIO
scl_gpio – SCL GPIO
- Returns:
ESP_OK
on success
- esp_err_t veml7700_free_desc(i2c_dev_t *dev)
Free device descriptor.
- Parameters:
dev – Pointer to I2C device descriptor
- Returns:
ESP_OK
on success
- esp_err_t veml7700_probe(i2c_dev_t *dev)
Probe if the device exist on the bus.
- Parameters:
dev – Pointer to I2C device descriptor
- Returns:
ESP_OK
on success
- esp_err_t veml7700_set_config(i2c_dev_t *dev, veml7700_config_t *config)
Write the config to the device.
- Parameters:
dev – Pointer to I2C device descriptor
config – Pointer to the config descriptor
- Returns:
ESP_OK
on success
- esp_err_t veml7700_get_config(i2c_dev_t *dev, veml7700_config_t *config)
Read the config to the device.
- Parameters:
dev – Pointer to I2C device descriptor
config – Pointer to the config descriptor
- Returns:
ESP_OK
on success
- esp_err_t veml7700_get_ambient_light(i2c_dev_t *dev, veml7700_config_t *config, uint32_t *value_lux)
Read ambient light sensor value from the device.
- Parameters:
dev – Pointer to I2C device descriptor
config – Pointer to the config descriptor
value_lux – Pointer as return value in lux
- Returns:
ESP_OK
on success
- esp_err_t veml7700_get_white_channel(i2c_dev_t *dev, veml7700_config_t *config, uint32_t *value_lux)
Read white channel value from the device.
- Parameters:
dev – Pointer to I2C device descriptor
config – Pointer to the config descriptor
value_lux – Pointer as return value in lux
- Returns:
ESP_OK
on success
- esp_err_t veml7700_get_interrupt_status(i2c_dev_t *dev, bool *low_threshold, bool *high_threshold)
Read the interrupt status from the device.
- Parameters:
dev – Pointer to I2C device descriptor
low_threshold – Pointer to return the low threshold passed indicator
high_threshold – Pointer to return the high threshold passed indicator
- Returns:
ESP_OK
on success
- struct veml7700_config_t
#include <veml7700.h>VEML configuration descriptor.
Public Members
- uint16_t gain
control the sensitivity
- uint16_t integration_time
time to measure
- uint16_t persistence_protect
sample count before the interrupt triggers
- uint16_t interrupt_enable
enable threshold interrupt
- uint16_t shutdown
set to 1 to shutdown the device, set to 0 to wakeup
- uint16_t threshold_high
high threshold for the interrupt
- uint16_t threshold_low
low threshold for the interrupt
- uint16_t power_saving_mode
power saving mode
- uint16_t power_saving_enable
enable the pover saving mode