tsl2561 - Driver for light-to-digital converter TSL2561

group tsl2561

ESP-IDF driver for TSL2561 light-to-digital converter.

Ported from esp-open-rtos

Copyright (C) 2016 Brian Schwind https://github.com/bschwind

Copyright (C) 2018 Ruslan V. Uss

unclerus@gmail.com

BSD Licensed as described in the file LICENSE

Defines

TSL2561_I2C_ADDR_GND
TSL2561_I2C_ADDR_FLOAT

Default I2C address.

TSL2561_I2C_ADDR_VCC

Enums

enum tsl2561_integration_time_t

Integration time.

Values:

enumerator TSL2561_INTEGRATION_13MS

13ms

enumerator TSL2561_INTEGRATION_101MS

101ms

enumerator TSL2561_INTEGRATION_402MS

402ms, default

enum tsl2561_gain_t

Gain.

Values:

enumerator TSL2561_GAIN_1X

Default.

enumerator TSL2561_GAIN_16X
enum tsl2561_package_t

Values:

enumerator TSL2561_PACKAGE_CS
enumerator TSL2561_PACKAGE_T_FN_CL

Functions

esp_err_t tsl2561_init_desc(tsl2561_t *dev, uint8_t addr, i2c_port_t port, gpio_num_t sda_gpio, gpio_num_t scl_gpio)

Initialize device descriptor.

Return

ESP_OK on success

Parameters
  • dev: Device descriptor

  • addr: I2C device address, TSL2561_I2C_ADDR_... const

  • port: I2C port

  • sda_gpio: SDA GPIO pin

  • scl_gpio: SCL GPIO pin

esp_err_t tsl2561_free_desc(tsl2561_t *dev)

Free device descriptor.

Return

ESP_OK on success

Parameters
  • dev: Device descriptor

esp_err_t tsl2561_init(tsl2561_t *dev)

Initialize device.

Return

ESP_OK on success

Parameters
  • dev: Device descriptor

esp_err_t tsl2561_set_integration_time(tsl2561_t *dev, tsl2561_integration_time_t integration_time)

Set device integration time.

Return

ESP_OK on success

Parameters
  • dev: Device descriptor

  • integration_time: Integration time

esp_err_t tsl2561_set_gain(tsl2561_t *dev, tsl2561_gain_t gain)

Set device gain.

Return

ESP_OK on success

Parameters
  • dev: Device descriptor

  • gain: Gain

esp_err_t tsl2561_read_lux(tsl2561_t *dev, uint32_t *lux)

Read light intensity from device.

Return

ESP_OK on success

Parameters
  • dev: Device descriptor

  • lux: Light intensity, lux

struct tsl2561_t
#include <tsl2561.h>

Device descriptor.