Class that stores state and functions for interacting with TSL2561 Light Sensor.
More...
#include <Adafruit_TSL2561_U.h>
|
| Adafruit_TSL2561_Unified (uint8_t addr, int32_t sensorID=-1) |
| Constructor. More...
|
|
boolean | begin (void) |
| Initializes I2C and configures the sensor with default Wire I2C (call this function before doing anything else) More...
|
|
boolean | begin (TwoWire *theWire) |
| Initializes I2C and configures the sensor with provided I2C device (call this function before doing anything else) More...
|
|
boolean | init () |
| Initializes I2C connection and settings. Attempts to determine if the sensor is contactable, then sets up a default integration time and gain. Then powers down the chip. More...
|
|
void | enableAutoRange (bool enable) |
| Enables or disables the auto-gain settings when reading data from the sensor. More...
|
|
void | setIntegrationTime (tsl2561IntegrationTime_t time) |
| Sets the integration time for the TSL2561. Higher time means more light captured (better for low light conditions) but will take longer to run readings. More...
|
|
void | setGain (tsl2561Gain_t gain) |
| Adjusts the gain on the TSL2561 (adjusts the sensitivity to light) More...
|
|
void | getLuminosity (uint16_t *broadband, uint16_t *ir) |
| Gets the broadband (mixed lighting) and IR only values from the TSL2561, adjusting gain if auto-gain is enabled. More...
|
|
uint32_t | calculateLux (uint16_t broadband, uint16_t ir) |
| Converts the raw sensor values to the standard SI lux equivalent. More...
|
|
bool | getEvent (sensors_event_t *) |
| Gets the most recent sensor event. More...
|
|
void | getSensor (sensor_t *) |
| Gets the sensor_t data. More...
|
|
Class that stores state and functions for interacting with TSL2561 Light Sensor.
◆ Adafruit_TSL2561_Unified()
Adafruit_TSL2561_Unified::Adafruit_TSL2561_Unified |
( |
uint8_t |
addr, |
|
|
int32_t |
sensorID = -1 |
|
) |
| |
Constructor.
- Parameters
-
addr | The I2C address this chip can be found on, 0x29, 0x39 or 0x49 |
sensorID | An optional ID that will be placed in sensor events to help keep track if you have many sensors in use |
◆ begin() [1/2]
boolean Adafruit_TSL2561_Unified::begin |
( |
void |
| ) |
|
Initializes I2C and configures the sensor with default Wire I2C (call this function before doing anything else)
- Returns
- True if sensor is found and initialized, false otherwise.
◆ begin() [2/2]
boolean Adafruit_TSL2561_Unified::begin |
( |
TwoWire * |
theWire | ) |
|
Initializes I2C and configures the sensor with provided I2C device (call this function before doing anything else)
- Parameters
-
theWire | A pointer to any I2C interface (e.g. &Wire1) |
- Returns
- True if sensor is found and initialized, false otherwise.
◆ init()
boolean Adafruit_TSL2561_Unified::init |
( |
| ) |
|
Initializes I2C connection and settings. Attempts to determine if the sensor is contactable, then sets up a default integration time and gain. Then powers down the chip.
- Returns
- True if sensor is found and initialized, false otherwise.
◆ enableAutoRange()
void Adafruit_TSL2561_Unified::enableAutoRange |
( |
bool |
enable | ) |
|
Enables or disables the auto-gain settings when reading data from the sensor.
- Parameters
-
enable | Set to true to enable, False to disable |
◆ setIntegrationTime()
Sets the integration time for the TSL2561. Higher time means more light captured (better for low light conditions) but will take longer to run readings.
- Parameters
-
time | The amount of time we'd like to add up values |
◆ setGain()
Adjusts the gain on the TSL2561 (adjusts the sensitivity to light)
- Parameters
-
gain | The value we'd like to set the gain to |
◆ getLuminosity()
void Adafruit_TSL2561_Unified::getLuminosity |
( |
uint16_t * |
broadband, |
|
|
uint16_t * |
ir |
|
) |
| |
Gets the broadband (mixed lighting) and IR only values from the TSL2561, adjusting gain if auto-gain is enabled.
- Parameters
-
broadband | Pointer to a uint16_t we will fill with a sensor reading from the IR+visible light diode. |
ir | Pointer to a uint16_t we will fill with a sensor the IR-only light diode. |
◆ calculateLux()
uint32_t Adafruit_TSL2561_Unified::calculateLux |
( |
uint16_t |
broadband, |
|
|
uint16_t |
ir |
|
) |
| |
Converts the raw sensor values to the standard SI lux equivalent.
- Parameters
-
broadband | The 16-bit sensor reading from the IR+visible light diode. |
ir | The 16-bit sensor reading from the IR-only light diode. |
- Returns
- The integer Lux value we calcuated. Returns 0 if the sensor is saturated and the values are unreliable, or 65536 if the sensor is saturated.
Returns
◆ getEvent()
bool Adafruit_TSL2561_Unified::getEvent |
( |
sensors_event_t * |
event | ) |
|
Gets the most recent sensor event.
- Parameters
-
event | Pointer to a sensor_event_t type that will be filled with the lux value, timestamp, data type and sensor ID. |
- Returns
- True if sensor reading is between 0 and 65535 lux, false if sensor is saturated
◆ getSensor()
void Adafruit_TSL2561_Unified::getSensor |
( |
sensor_t * |
sensor | ) |
|
Gets the sensor_t data.
- Parameters
-
sensor | A pointer to a sensor_t structure that we will fill with details about the TSL2561 and its capabilities |
The documentation for this class was generated from the following files: