tsl4531 - Driver for digital ambient light sensor TSL4531

group tsl4531

ESP-IDF driver for digital ambient light sensor TSL4531.

Ported from esp-open-rtos

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

Copyright (C) 2019 Ruslan V. Uss

unclerus@gmail.com

BSD Licensed as described in the file LICENSE

Defines

TSL4531_I2C_ADDR

Enums

enum tsl4531_integration_time_t

Integration time.

Values:

enumerator TSL4531_INTEGRATION_400MS

Default.

enumerator TSL4531_INTEGRATION_200MS
enumerator TSL4531_INTEGRATION_100MS
enum tsl4531_part_id_t

Part IDs.

Values:

enumerator TSL4531_PART_TSL45317
enumerator TSL4531_PART_TSL45313
enumerator TSL4531_PART_TSL45315
enumerator TSL4531_PART_TSL45311

Functions

esp_err_t tsl4531_init_desc(tsl4531_t *dev, i2c_port_t port, gpio_num_t sda_gpio, gpio_num_t scl_gpio)

Initialize device descriptor.

Parameters
  • dev – Device descriptor

  • port – I2C port

  • sda_gpio – SDA GPIO pin

  • scl_gpio – SCL GPIO pin

Returns

ESP_OK on success

esp_err_t tsl4531_free_desc(tsl4531_t *dev)

Free device descriptor.

Parameters

dev – Device descriptor

Returns

ESP_OK on success

esp_err_t tsl4531_init(tsl4531_t *dev)

Initialize device.

Parameters

dev – Device descriptor

Returns

ESP_OK on success

esp_err_t tsl4531_config(tsl4531_t *dev, tsl4531_integration_time_t integration_time, bool skip_power_save)

Configure device.

Parameters
  • dev – Device descriptor

  • integration_time – Integration time

  • skip_power_save – PowerSave Mode. When true, the power save states are skipped following a light integration cycle for shorter sampling rates

Returns

ESP_OK on success

esp_err_t tsl4531_read_lux(tsl4531_t *dev, uint16_t *lux)

Read conversion results in lux.

Parameters
  • dev – Device descriptor

  • [out] lux – Conversion result in lux

Returns

ESP_OK on success

struct tsl4531_t
#include <tsl4531.h>

Device descriptor.