Driver for the Texas Instruments OPT3001 sensor.
More...
Driver for the Texas Instruments OPT3001 sensor.
The TI OPT3001 (Ambient Light Sensor) measures the intensity of visible light with a spectal response comparable to the human eye, with simultaneous rejection of infrared light. The conversion time, mode of conversion and the interrupt reporting mechanism mode can be set by the sensor initialization. After initialization the raw sensor values can be read. The ambient light can be calculated as follows:
Result register translation into lux:
Where LSB_Size:
The calculation is wrapped from TI OPT3001 Ambient Light Sensor (ALS) datasheet (Rev. C).
This driver provides [S]ensor [A]ctuator [U]ber [L]ayer capabilities.
◆ anonymous enum
OPT3001 specific return values.
Enumerator |
---|
OPT3001_OK | Success, no error.
|
OPT3001_ERROR_BUS | I2C bus error.
|
OPT3001_ERROR_DEV | Internal device error.
|
OPT3001_ERROR | General error.
|
Definition at line 112 of file opt3001.h.
◆ opt3001_init()
Initialize the OPT3001 sensor driver.
- Parameters
-
[out] | dev | device descriptor of sensor to initialize |
[in] | params | configuration parameters |
- Returns
- 0 on success
-
-OPT3001_ERROR_BUS on I2C bus error
-
-OPT3001_ERROR_DEV if sensor test failed
◆ opt3001_read_lux()
int opt3001_read_lux |
( |
const opt3001_t * |
dev, |
|
|
uint32_t * |
convl |
|
) |
| |
Read sensor's raw data and convert it to milliLux.
- Parameters
-
[in] | dev | device descriptor of sensor |
[out] | convl | ambient light in milliLux |
- Returns
- 0 on success
-
-1 on error
◆ opt3001_reset()
Reset the OPT3001 sensor while simultaneous deactivating measurements.
Afterwards the sensor should be idle.
- Parameters
-
[out] | dev | device descriptor of sensor |
- Returns
- 0 on success
-
-1 on error
◆ opt3001_set_active()
int opt3001_set_active |
( |
const opt3001_t * |
dev | ) |
|
Set active mode, this enables periodic measurements.
- Parameters
-
[in] | dev | device descriptor of sensor |
- Returns
- 0 on success
-
-1 on error