Loading...
Searching...
No Matches

Driver for the Texas Instruments OPT3001 sensor. More...

Detailed Description

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:

\begin{eqnarray*}
        Lux &=& LSB\_Size \cdot R[11:0]
    \end{eqnarray*}

Where LSB_Size:

\begin{eqnarray*}
        LSB\_Size &=& 0.01 \cdot 2^{E[3:0]}
    \end{eqnarray*}

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.

Modules

 OPT3001 Ambient Light Sensor driver compile configuration
 

Files

file  opt3001.h
 Interface definition for the OPT3001 sensor driver.
 
file  opt3001_params.h
 Default configuration for OPT3001 devices.
 
file  opt3001_regs.h
 Register definitions for OPT3001 devices.
 

Data Structures

struct  opt3001_params_t
 Parameters needed for device initialization. More...
 
struct  opt3001_t
 Device descriptor for OPT3001 sensors. More...
 

Enumerations

enum  { OPT3001_OK , OPT3001_ERROR_BUS , OPT3001_ERROR_DEV , OPT3001_ERROR }
 OPT3001 specific return values. More...
 

Functions

int opt3001_init (opt3001_t *dev, const opt3001_params_t *params)
 Initialize the OPT3001 sensor driver.
 
int opt3001_reset (const opt3001_t *dev)
 Reset the OPT3001 sensor while simultaneous deactivating measurements.
 
int opt3001_set_active (const opt3001_t *dev)
 Set active mode, this enables periodic measurements.
 
int opt3001_read_lux (const opt3001_t *dev, uint32_t *convl)
 Read sensor's raw data and convert it to milliLux.
 

Conversion time

#define OPT3001_CONVERSION_TIME_100_MS   (0x0000)
 Conversion time of 100ms.
 
#define OPT3001_CONVERSION_TIME_800_MS   (0x0800)
 Conversion time of 800ms.
 

Macro Definition Documentation

◆ OPT3001_CONVERSION_TIME_100_MS

#define OPT3001_CONVERSION_TIME_100_MS   (0x0000)

Conversion time of 100ms.

Definition at line 57 of file opt3001.h.

◆ OPT3001_CONVERSION_TIME_800_MS

#define OPT3001_CONVERSION_TIME_800_MS   (0x0800)

Conversion time of 800ms.

Definition at line 58 of file opt3001.h.

Enumeration Type Documentation

◆ anonymous enum

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 111 of file opt3001.h.

Function Documentation

◆ opt3001_init()

int opt3001_init ( opt3001_t dev,
const opt3001_params_t params 
)

Initialize the OPT3001 sensor driver.

Parameters
[out]devdevice descriptor of sensor to initialize
[in]paramsconfiguration 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]devdevice descriptor of sensor
[out]convlambient light in milliLux
Returns
0 on success
-1 on error

◆ opt3001_reset()

int opt3001_reset ( const opt3001_t dev)

Reset the OPT3001 sensor while simultaneous deactivating measurements.

Afterwards the sensor should be idle.

Parameters
[out]devdevice 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]devdevice descriptor of sensor
Returns
0 on success
-1 on error