Data Structures | |
| struct | veml7700_config_t |
| Configuration structure for the VEML7700 sensor. More... | |
| struct | veml7700_dev_t |
| Device handle structure for the VEML7700 sensor. More... | |
Macros | |
| #define | VEML7700_I2C_ADDR (0x10) |
| Default I²C address for VEML7700 sensors. | |
Typedefs | |
| typedef uint8_t | i2c_addr_t |
| Type for I²C addresses. | |
| typedef uint32_t | ill_lx_t |
| Type for illuminance [lx]. | |
| typedef void * | veml7700_handle_t |
| Opaque handle for a VEML7700 sensor. | |
Functions | |
| veml7700_handle_t | veml7700_i2c_create (i2c_bus_handle_t bus, i2c_addr_t dev_addr) |
| Create a VEML7700 device handle for I²C communication. | |
| veml7700_handle_t | veml7700_i2c_init (i2c_bus_handle_t bus, i2c_addr_t dev_addr) |
| Initialize the VEML7700 sensor over I²C. | |
| void | veml7700_i2c_delete (veml7700_handle_t sensor) |
| Deinitialize the VEML7700 sensor and free resources. | |
| esp_err_t | veml7700_i2c_probe (veml7700_handle_t sensor) |
| Probe if the sensor exist on the I²C bus. | |
| esp_err_t | veml7700_i2c_write_config (veml7700_handle_t sensor, veml7700_config_t *cfg) |
| Write the configuration to the sensor. | |
| esp_err_t | veml7700_i2c_read_config (veml7700_handle_t sensor, veml7700_config_t *cfg) |
| Read the sensor configuration. | |
| esp_err_t | veml7700_i2c_read_ambient_light (veml7700_handle_t sensor, ill_lx_t *val) |
| Read ambiant light value from the sensor. | |
| esp_err_t | veml7700_i2c_read_white_channel (veml7700_handle_t sensor, ill_lx_t *val) |
| Read white channel value from the sensor. | |
| esp_err_t | veml7700_i2c_read_interrupt_status (veml7700_handle_t sensor, bool *low, bool *high) |
| Read the interrupt status from the sensor. | |
Integration Time Constants | |
Integration times for the VEML7700 sensor. | |
| #define | VEML7700_INTEGRATION_TIME_25MS (0b1100) |
| 25 ms | |
| #define | VEML7700_INTEGRATION_TIME_50MS (0b1000) |
| 50 ms | |
| #define | VEML7700_INTEGRATION_TIME_100MS (0b0000) |
| 100 ms | |
| #define | VEML7700_INTEGRATION_TIME_200MS (0b0001) |
| 200 ms | |
| #define | VEML7700_INTEGRATION_TIME_400MS (0b0010) |
| 400 ms | |
| #define | VEML7700_INTEGRATION_TIME_800MS (0b0011) |
| 800 ms | |
Gain Constants | |
Gain settings for the VEML7700 sensor. | |
| #define | VEML7700_GAIN_1 (0b00) |
| x1 gain | |
| #define | VEML7700_GAIN_2 (0b01) |
| x2 gain | |
| #define | VEML7700_GAIN_DIV_8 (0b10) |
| /8 gain | |
| #define | VEML7700_GAIN_DIV_4 (0b11) |
| /4 gain | |
Power Saving Mode Constants | |
Power saving modes for the sensor. | |
| #define | VEML7700_POWER_SAVING_MODE_500MS (0b00) |
| 500 ms interval | |
| #define | VEML7700_POWER_SAVING_MODE_1000MS (0b01) |
| 1000 ms interval | |
| #define | VEML7700_POWER_SAVING_MODE_2000MS (0b10) |
| 2000 ms interval | |
| #define | VEML7700_POWER_SAVING_MODE_4000MS (0b11) |
| 4000 ms interval | |
Persistence Protection Constants | |
Number of consecutive samples before triggering an interrupt. | |
| #define | VEML7700_PERSISTENCE_PROTECTION_1 (0b00) |
| 1 sample | |
| #define | VEML7700_PERSISTENCE_PROTECTION_2 (0b01) |
| 2 samples | |
| #define | VEML7700_PERSISTENCE_PROTECTION_4 (0b10) |
| 4 samples | |
| #define | VEML7700_PERSISTENCE_PROTECTION_8 (0b11) |
| 8 samples | |
I²C ESP-IDF driver for the Vishay VEML7700 ambiant light sensor.
Adapted from https://github.com/esp-idf-lib/veml7700/tree/78c39579d6d5b1a0cc06e3af6da78fe41e181792 under ISC license.
Uses the new ESP-IDF I²C interface.
| struct veml7700_config_t |
Configuration structure for the VEML7700 sensor.
| struct veml7700_dev_t |
Device handle structure for the VEML7700 sensor.
| Data Fields | ||
|---|---|---|
| veml7700_config_t | cfg | Sensor configuration. |
| i2c_addr_t | dev_addr | I²C address of the sensor. |
| i2c_bus_device_handle_t | i2c_dev | I²C device handle. |
| #define VEML7700_GAIN_1 (0b00) |
x1 gain
| #define VEML7700_GAIN_2 (0b01) |
x2 gain
| #define VEML7700_GAIN_DIV_4 (0b11) |
/4 gain
| #define VEML7700_GAIN_DIV_8 (0b10) |
/8 gain
| #define VEML7700_I2C_ADDR (0x10) |
Default I²C address for VEML7700 sensors.
| #define VEML7700_INTEGRATION_TIME_100MS (0b0000) |
100 ms
| #define VEML7700_INTEGRATION_TIME_200MS (0b0001) |
200 ms
| #define VEML7700_INTEGRATION_TIME_25MS (0b1100) |
25 ms
| #define VEML7700_INTEGRATION_TIME_400MS (0b0010) |
400 ms
| #define VEML7700_INTEGRATION_TIME_50MS (0b1000) |
50 ms
| #define VEML7700_INTEGRATION_TIME_800MS (0b0011) |
800 ms
| #define VEML7700_PERSISTENCE_PROTECTION_1 (0b00) |
1 sample
| #define VEML7700_PERSISTENCE_PROTECTION_2 (0b01) |
2 samples
| #define VEML7700_PERSISTENCE_PROTECTION_4 (0b10) |
4 samples
| #define VEML7700_PERSISTENCE_PROTECTION_8 (0b11) |
8 samples
| #define VEML7700_POWER_SAVING_MODE_1000MS (0b01) |
1000 ms interval
| #define VEML7700_POWER_SAVING_MODE_2000MS (0b10) |
2000 ms interval
| #define VEML7700_POWER_SAVING_MODE_4000MS (0b11) |
4000 ms interval
| #define VEML7700_POWER_SAVING_MODE_500MS (0b00) |
500 ms interval
| typedef uint8_t i2c_addr_t |
Type for I²C addresses.
| typedef uint32_t ill_lx_t |
Type for illuminance [lx].
| typedef void* veml7700_handle_t |
Opaque handle for a VEML7700 sensor.
| veml7700_handle_t veml7700_i2c_create | ( | i2c_bus_handle_t | bus, |
| i2c_addr_t | dev_addr ) |
Create a VEML7700 device handle for I²C communication.
Allocates and initializes a device handle but does not configure the sensor.
| [in] | bus | Handle to the I²C bus. |
| [in] | dev_addr | I²C address of the VEML7700 sensor. |
@retvale veml7700_handle_t Handle to the sensor.
| NULL | On failure. |
veml7700_i2c_delete() to free resources later. | void veml7700_i2c_delete | ( | veml7700_handle_t | sensor | ) |
Deinitialize the VEML7700 sensor and free resources.
| [in,out] | sensor | The sensor handle returned by veml7700_i2c_init() or veml7700_i2c_create(). |
| veml7700_handle_t veml7700_i2c_init | ( | i2c_bus_handle_t | bus, |
| i2c_addr_t | dev_addr ) |
Initialize the VEML7700 sensor over I²C.
Sets up default configuration and prepares the sensor for measurements.
| [in] | bus | Handle to the I²C bus. |
| [in] | dev_addr | I²C address of the VEML7700 sensor. |
| veml7700_handle_t | Handle to the sensor. |
| NULL | On failure. |
veml7700_i2c_delete() to free resources later. | esp_err_t veml7700_i2c_probe | ( | veml7700_handle_t | sensor | ) |
Probe if the sensor exist on the I²C bus.
| [in] | sensor | The sensor handle. |
| ESP_OK | On success. |
| ESP_ERR_INVALID_ARG | If any parameter is NULL. |
| ESP_FAIL | Sending command error, slave doesn't ACK the transfer. |
| ESP_ERR_INVALID_STATE | I²C driver not installed or not in master mode. |
| ESP_ERR_TIMEOUT | Operation timeout because the bus is busy. |
| esp_err_t veml7700_i2c_read_ambient_light | ( | veml7700_handle_t | sensor, |
| ill_lx_t * | val ) |
Read ambiant light value from the sensor.
| [in] | sensor | The sensor handle. |
| [out] | val | Pointer to store the ambiant light value. |
| ESP_OK | On success. |
| ESP_ERR_INVALID_ARG | If any parameter is NULL. |
| ESP_FAIL | Sending command error, slave doesn't ACK the transfer. |
| ESP_ERR_INVALID_STATE | I²C driver not installed or not in master mode. |
| ESP_ERR_TIMEOUT | Operation timeout because the bus is busy. |
| esp_err_t veml7700_i2c_read_config | ( | veml7700_handle_t | sensor, |
| veml7700_config_t * | cfg ) |
Read the sensor configuration.
| [in] | sensor | The sensor handle. |
| [out] | cfg | Pointer to store the configuration. |
| ESP_OK | On success. |
| ESP_ERR_INVALID_ARG | If any parameter is NULL. |
| ESP_FAIL | Sending command error, slave doesn't ACK the transfer. |
| ESP_ERR_INVALID_STATE | I²C driver not installed or not in master mode. |
| ESP_ERR_TIMEOUT | Operation timeout because the bus is busy. |
| esp_err_t veml7700_i2c_read_interrupt_status | ( | veml7700_handle_t | sensor, |
| bool * | low, | ||
| bool * | high ) |
Read the interrupt status from the sensor.
| [in] | sensor | The sensor handle. |
| [out] | low | Pointer to store the low threshold passed indicator. |
| [out] | high | Pointer to store the high threshold passed indicator. |
| ESP_OK | On success. |
| ESP_ERR_INVALID_ARG | If any parameter is NULL. |
| ESP_FAIL | Sending command error, slave doesn't ACK the transfer. |
| ESP_ERR_INVALID_STATE | I²C driver not installed or not in master mode. |
| ESP_ERR_TIMEOUT | Operation timeout because the bus is busy. |
| esp_err_t veml7700_i2c_read_white_channel | ( | veml7700_handle_t | sensor, |
| ill_lx_t * | val ) |
Read white channel value from the sensor.
| [in] | sensor | The sensor handle. |
| [out] | val | Pointer to store the white channel value. |
| ESP_OK | On success. |
| ESP_ERR_INVALID_ARG | If any parameter is NULL. |
| ESP_FAIL | Sending command error, slave doesn't ACK the transfer. |
| ESP_ERR_INVALID_STATE | I²C driver not installed or not in master mode. |
| ESP_ERR_TIMEOUT | Operation timeout because the bus is busy. |
| esp_err_t veml7700_i2c_write_config | ( | veml7700_handle_t | sensor, |
| veml7700_config_t * | cfg ) |
Write the configuration to the sensor.
| [in] | sensor | The sensor handle. |
| [in] | cfg | The configuration descriptor. |
| ESP_OK | On success. |
| ESP_ERR_INVALID_ARG | If any parameter is NULL. |
| ESP_FAIL | Sending command error, slave doesn't ACK the transfer. |
| ESP_ERR_INVALID_STATE | I²C driver not installed or not in master mode. |
| ESP_ERR_TIMEOUT | Operation timeout because the bus is busy. |