22 #include <Adafruit_I2CDevice.h> 23 #include <Adafruit_Sensor.h> 26 #define TSL2591_VISIBLE (2) 27 #define TSL2591_INFRARED (1) 28 #define TSL2591_FULLSPECTRUM (0) 30 #define TSL2591_ADDR (0x29) 32 #define TSL2591_COMMAND_BIT \ 35 #define TSL2591_CLEAR_INT (0xE7) 37 #define TSL2591_TEST_INT (0xE4) 40 #define TSL2591_WORD_BIT (0x20) 41 #define TSL2591_BLOCK_BIT (0x10) 43 #define TSL2591_ENABLE_POWEROFF (0x00) 44 #define TSL2591_ENABLE_POWERON (0x01) 45 #define TSL2591_ENABLE_AEN \ 47 #define TSL2591_ENABLE_AIEN \ 50 #define TSL2591_ENABLE_NPIEN \ 55 #define TSL2591_LUX_DF (408.0F) 56 #define TSL2591_LUX_COEFB (1.64F) 57 #define TSL2591_LUX_COEFC (0.59F) 58 #define TSL2591_LUX_COEFD (0.86F) 62 TSL2591_REGISTER_ENABLE = 0x00,
63 TSL2591_REGISTER_CONTROL = 0x01,
64 TSL2591_REGISTER_THRESHOLD_AILTL = 0x04,
65 TSL2591_REGISTER_THRESHOLD_AILTH = 0x05,
66 TSL2591_REGISTER_THRESHOLD_AIHTL = 0x06,
67 TSL2591_REGISTER_THRESHOLD_AIHTH = 0x07,
68 TSL2591_REGISTER_THRESHOLD_NPAILTL =
70 TSL2591_REGISTER_THRESHOLD_NPAILTH =
72 TSL2591_REGISTER_THRESHOLD_NPAIHTL =
74 TSL2591_REGISTER_THRESHOLD_NPAIHTH =
76 TSL2591_REGISTER_PERSIST_FILTER = 0x0C,
77 TSL2591_REGISTER_PACKAGE_PID = 0x11,
78 TSL2591_REGISTER_DEVICE_ID = 0x12,
79 TSL2591_REGISTER_DEVICE_STATUS = 0x13,
80 TSL2591_REGISTER_CHAN0_LOW = 0x14,
81 TSL2591_REGISTER_CHAN0_HIGH = 0x15,
82 TSL2591_REGISTER_CHAN1_LOW = 0x16,
83 TSL2591_REGISTER_CHAN1_HIGH = 0x17,
88 TSL2591_INTEGRATIONTIME_100MS = 0x00,
89 TSL2591_INTEGRATIONTIME_200MS = 0x01,
90 TSL2591_INTEGRATIONTIME_300MS = 0x02,
91 TSL2591_INTEGRATIONTIME_400MS = 0x03,
92 TSL2591_INTEGRATIONTIME_500MS = 0x04,
93 TSL2591_INTEGRATIONTIME_600MS = 0x05,
99 TSL2591_PERSIST_EVERY = 0x00,
100 TSL2591_PERSIST_ANY = 0x01,
101 TSL2591_PERSIST_2 = 0x02,
102 TSL2591_PERSIST_3 = 0x03,
103 TSL2591_PERSIST_5 = 0x04,
104 TSL2591_PERSIST_10 = 0x05,
105 TSL2591_PERSIST_15 = 0x06,
106 TSL2591_PERSIST_20 = 0x07,
107 TSL2591_PERSIST_25 = 0x08,
108 TSL2591_PERSIST_30 = 0x09,
109 TSL2591_PERSIST_35 = 0x0A,
110 TSL2591_PERSIST_40 = 0x0B,
111 TSL2591_PERSIST_45 = 0x0C,
112 TSL2591_PERSIST_50 = 0x0D,
113 TSL2591_PERSIST_55 = 0x0E,
114 TSL2591_PERSIST_60 = 0x0F,
119 TSL2591_GAIN_LOW = 0x00,
161 Adafruit_I2CDevice *i2c_dev = NULL;
163 void write8(uint8_t r);
164 void write8(uint8_t r, uint8_t v);
165 uint16_t read16(uint8_t reg);
166 uint8_t read8(uint8_t reg);
173 boolean _initialized;
low gain (1x)
Definition: Adafruit_TSL2591.h:120
void getSensor(sensor_t *)
Gets the overall sensor_t data including the type, range and resulution.
Definition: Adafruit_TSL2591.cpp:467
#define TSL2591_ADDR
Default I2C address.
Definition: Adafruit_TSL2591.h:30
medium gain (428x)
Definition: Adafruit_TSL2591.h:122
void setTiming(tsl2591IntegrationTime_t integration)
Setter for sensor integration time setting.
Definition: Adafruit_TSL2591.cpp:191
Class that stores state and functions for interacting with TSL2591 Light Sensor.
Definition: Adafruit_TSL2591.h:131
bool getEvent(sensors_event_t *)
Gets the most recent sensor event.
Definition: Adafruit_TSL2591.cpp:435
Adafruit_TSL2591(int32_t sensorID=-1)
Instantiates a new Adafruit TSL2591 class.
Definition: Adafruit_TSL2591.cpp:58
void setGain(tsl2591Gain_t gain)
Setter for sensor light gain.
Definition: Adafruit_TSL2591.cpp:164
void registerInterrupt(uint16_t lowerThreshold, uint16_t upperThreshold, tsl2591Persist_t persist)
Set up the interrupt to go off when light level is outside the lower/upper range. ...
Definition: Adafruit_TSL2591.cpp:366
void clearInterrupt(void)
Clear interrupt status.
Definition: Adafruit_TSL2591.cpp:393
medium gain (25x)
Definition: Adafruit_TSL2591.h:121
float calculateLux(uint16_t ch0, uint16_t ch1)
Calculates the visible Lux based on the two light sensors.
Definition: Adafruit_TSL2591.cpp:220
tsl2591Gain_t
Enumeration for the sensor gain.
Definition: Adafruit_TSL2591.h:118
void disable(void)
Disables the chip, so it's in power down mode.
Definition: Adafruit_TSL2591.cpp:146
boolean begin(TwoWire *theWire, uint8_t addr=TSL2591_ADDR)
Setups the I2C interface and hardware, identifies if chip is found.
Definition: Adafruit_TSL2591.cpp:81
tsl2591Persist_t
Enumeration for the persistance filter (for interrupts)
Definition: Adafruit_TSL2591.h:97
uint16_t getLuminosity(uint8_t channel)
Reads the raw data from the channel.
Definition: Adafruit_TSL2591.cpp:336
void enable(void)
Enables the chip, so it's ready to take readings.
Definition: Adafruit_TSL2591.cpp:128
uint8_t getStatus()
Gets the most recent sensor event from the hardware status register.
Definition: Adafruit_TSL2591.cpp:412
tsl2591Gain_t getGain()
Getter for sensor light gain.
Definition: Adafruit_TSL2591.cpp:183
uint32_t getFullLuminosity()
Reads the raw data from both light channels.
Definition: Adafruit_TSL2591.cpp:300
tsl2591IntegrationTime_t getTiming()
Getter for sensor integration time setting.
Definition: Adafruit_TSL2591.cpp:210
tsl2591IntegrationTime_t
Enumeration for the sensor integration timing.
Definition: Adafruit_TSL2591.h:87