ESP32-CAM
Public Member Functions | List of all members
TSL2591 Class Reference

#include <tsl2591.h>

Public Member Functions

 TSL2591 (uint8_t i2cAddress, uint8_t sdaPin, uint8_t sclPin)
 Construct a new TSL2591::TSL2591 object. More...
 
boolean begin (void)
 Starts I2C communication with sensor. More...
 
void enable (void)
 Enables device. More...
 
void disable (void)
 Disables the device. More...
 
uint16_t getLuminosity (uint8_t channel)
 Reads luminosity from selected channel (Visible and/or IR) More...
 
uint32_t getFullLuminosity (void)
 Reads luminosity from both channels (Visible and IR) More...
 
float calculateLux (uint16_t ch0, uint16_t ch1)
 Calculates lux value from both channels (Visible and IR) readings. More...
 
void setGain (tsl2591Gain_t gain)
 Set light sensor gain. More...
 
void setTiming (tsl2591IntegrationTime_t integration)
 Set light sensor integration time. More...
 
tsl2591IntegrationTime_t getTiming ()
 Get light sensor integration time. More...
 
tsl2591Gain_t getGain ()
 Get light sensor gain. More...
 
uint8_t getStatus (void)
 Reads the device status byte. More...
 
unsigned char readByte (unsigned char address)
 Read byte as char from I2C. More...
 
boolean writeByte (unsigned char address, unsigned char value)
 Write byte to I2C. More...
 
uint8_t readUInt (unsigned char address)
 Read two bytes as integer from I2C. More...
 
 TSL2591 (uint8_t i2cAddress, uint8_t sdaPin, uint8_t sclPin)
 
boolean begin (void)
 
void enable (void)
 
void disable (void)
 
uint16_t getLuminosity (uint8_t channel)
 
uint32_t getFullLuminosity (void)
 
float calculateLux (uint16_t ch0, uint16_t ch1)
 
void setGain (tsl2591Gain_t gain)
 
void setTiming (tsl2591IntegrationTime_t integration)
 
tsl2591IntegrationTime_t getTiming ()
 
tsl2591Gain_t getGain ()
 
uint8_t getStatus (void)
 
unsigned char readByte (unsigned char address)
 
boolean writeByte (unsigned char address, unsigned char value)
 
uint8_t readUInt (unsigned char address)
 

Constructor & Destructor Documentation

◆ TSL2591() [1/2]

TSL2591::TSL2591 ( uint8_t  i2cAddress,
uint8_t  sdaPin,
uint8_t  sclPin 
)

Construct a new TSL2591::TSL2591 object.

Parameters
i2cAddress
sdaPin
sclPin

◆ TSL2591() [2/2]

TSL2591::TSL2591 ( uint8_t  i2cAddress,
uint8_t  sdaPin,
uint8_t  sclPin 
)

Member Function Documentation

◆ begin() [1/2]

boolean TSL2591::begin ( void  )

Starts I2C communication with sensor.

Checks device ID Sets default integration time and gain

Returns
boolean

◆ begin() [2/2]

boolean TSL2591::begin ( void  )

◆ calculateLux() [1/2]

float TSL2591::calculateLux ( uint16_t  ch0,
uint16_t  ch1 
)

◆ calculateLux() [2/2]

float TSL2591::calculateLux ( uint16_t  ch0,
uint16_t  ch1 
)

Calculates lux value from both channels (Visible and IR) readings.

Parameters
ch0
ch1
Returns
float

◆ disable() [1/2]

void TSL2591::disable ( void  )

◆ disable() [2/2]

void TSL2591::disable ( void  )

Disables the device.

PowerOff

◆ enable() [1/2]

void TSL2591::enable ( void  )

Enables device.

PowerOn + ADC + Interrupts

◆ enable() [2/2]

void TSL2591::enable ( void  )

◆ getFullLuminosity() [1/2]

uint32_t TSL2591::getFullLuminosity ( void  )

◆ getFullLuminosity() [2/2]

uint32_t TSL2591::getFullLuminosity ( void  )

Reads luminosity from both channels (Visible and IR)

Returns
uint32_t

◆ getGain() [1/2]

tsl2591Gain_t TSL2591::getGain ( )

Get light sensor gain.

Necessary beacause class member _gain is private

Returns
tsl2591Gain_t

◆ getGain() [2/2]

tsl2591Gain_t TSL2591::getGain ( )

◆ getLuminosity() [1/2]

uint16_t TSL2591::getLuminosity ( uint8_t  channel)

Reads luminosity from selected channel (Visible and/or IR)

Parameters
channel
Returns
uint16_t

◆ getLuminosity() [2/2]

uint16_t TSL2591::getLuminosity ( uint8_t  channel)

◆ getStatus() [1/2]

uint8_t TSL2591::getStatus ( void  )

Reads the device status byte.

Returns
uint8_t

◆ getStatus() [2/2]

uint8_t TSL2591::getStatus ( void  )

◆ getTiming() [1/2]

tsl2591IntegrationTime_t TSL2591::getTiming ( )

◆ getTiming() [2/2]

tsl2591IntegrationTime_t TSL2591::getTiming ( )

Get light sensor integration time.

Necessary beacause class member _integration is private

Returns
tsl2591IntegrationTime_t

◆ readByte() [1/2]

unsigned char TSL2591::readByte ( unsigned char  address)

◆ readByte() [2/2]

unsigned char TSL2591::readByte ( unsigned char  address)

Read byte as char from I2C.

Parameters
address
Returns
unsigned char

◆ readUInt() [1/2]

uint8_t TSL2591::readUInt ( unsigned char  address)

Read two bytes as integer from I2C.

Parameters
address
Returns
uint8_t

◆ readUInt() [2/2]

uint8_t TSL2591::readUInt ( unsigned char  address)

◆ setGain() [1/2]

void TSL2591::setGain ( tsl2591Gain_t  gain)

◆ setGain() [2/2]

void TSL2591::setGain ( tsl2591Gain_t  gain)

Set light sensor gain.

Parameters
gain

◆ setTiming() [1/2]

void TSL2591::setTiming ( tsl2591IntegrationTime_t  integration)

Set light sensor integration time.

Parameters
integration

◆ setTiming() [2/2]

void TSL2591::setTiming ( tsl2591IntegrationTime_t  integration)

◆ writeByte() [1/2]

boolean TSL2591::writeByte ( unsigned char  address,
unsigned char  value 
)

◆ writeByte() [2/2]

boolean TSL2591::writeByte ( unsigned char  address,
unsigned char  value 
)

Write byte to I2C.

Parameters
address
value
Returns
boolean

The documentation for this class was generated from the following files: