21 #ifndef ADAFRUIT_TSL2561_H_ 22 #define ADAFRUIT_TSL2561_H_ 24 #include <Adafruit_Sensor.h> 28 #define TSL2561_VISIBLE 2 29 #define TSL2561_INFRARED 1 30 #define TSL2561_FULLSPECTRUM 0 33 #define TSL2561_ADDR_LOW (0x29) 34 #define TSL2561_ADDR_FLOAT (0x39) 35 #define TSL2561_ADDR_HIGH (0x49) 39 #define TSL2561_PACKAGE_T_FN_CL 41 #define TSL2561_COMMAND_BIT (0x80) 42 #define TSL2561_CLEAR_BIT \ 44 #define TSL2561_WORD_BIT (0x20) 45 #define TSL2561_BLOCK_BIT (0x10) 47 #define TSL2561_CONTROL_POWERON (0x03) 48 #define TSL2561_CONTROL_POWEROFF \ 51 #define TSL2561_LUX_LUXSCALE (14) 52 #define TSL2561_LUX_RATIOSCALE (9) 53 #define TSL2561_LUX_CHSCALE (10) 54 #define TSL2561_LUX_CHSCALE_TINT0 (0x7517) 55 #define TSL2561_LUX_CHSCALE_TINT1 (0x0FE7) 58 #define TSL2561_LUX_K1T (0x0040) 59 #define TSL2561_LUX_B1T (0x01f2) 60 #define TSL2561_LUX_M1T (0x01be) 61 #define TSL2561_LUX_K2T (0x0080) 62 #define TSL2561_LUX_B2T (0x0214) 63 #define TSL2561_LUX_M2T (0x02d1) 64 #define TSL2561_LUX_K3T (0x00c0) 65 #define TSL2561_LUX_B3T (0x023f) 66 #define TSL2561_LUX_M3T (0x037b) 67 #define TSL2561_LUX_K4T (0x0100) 68 #define TSL2561_LUX_B4T (0x0270) 69 #define TSL2561_LUX_M4T (0x03fe) 70 #define TSL2561_LUX_K5T (0x0138) 71 #define TSL2561_LUX_B5T (0x016f) 72 #define TSL2561_LUX_M5T (0x01fc) 73 #define TSL2561_LUX_K6T (0x019a) 74 #define TSL2561_LUX_B6T (0x00d2) 75 #define TSL2561_LUX_M6T (0x00fb) 76 #define TSL2561_LUX_K7T (0x029a) 77 #define TSL2561_LUX_B7T (0x0018) 78 #define TSL2561_LUX_M7T (0x0012) 79 #define TSL2561_LUX_K8T (0x029a) 80 #define TSL2561_LUX_B8T (0x0000) 81 #define TSL2561_LUX_M8T (0x0000) 84 #define TSL2561_LUX_K1C (0x0043) 85 #define TSL2561_LUX_B1C (0x0204) 86 #define TSL2561_LUX_M1C (0x01ad) 87 #define TSL2561_LUX_K2C (0x0085) 88 #define TSL2561_LUX_B2C (0x0228) 89 #define TSL2561_LUX_M2C (0x02c1) 90 #define TSL2561_LUX_K3C (0x00c8) 91 #define TSL2561_LUX_B3C (0x0253) 92 #define TSL2561_LUX_M3C (0x0363) 93 #define TSL2561_LUX_K4C (0x010a) 94 #define TSL2561_LUX_B4C (0x0282) 95 #define TSL2561_LUX_M4C (0x03df) 96 #define TSL2561_LUX_K5C (0x014d) 97 #define TSL2561_LUX_B5C (0x0177) 98 #define TSL2561_LUX_M5C (0x01dd) 99 #define TSL2561_LUX_K6C (0x019a) 100 #define TSL2561_LUX_B6C (0x0101) 101 #define TSL2561_LUX_M6C (0x0127) 102 #define TSL2561_LUX_K7C (0x029a) 103 #define TSL2561_LUX_B7C (0x0037) 104 #define TSL2561_LUX_M7C (0x002b) 105 #define TSL2561_LUX_K8C (0x029a) 106 #define TSL2561_LUX_B8C (0x0000) 107 #define TSL2561_LUX_M8C (0x0000) 110 #define TSL2561_AGC_THI_13MS (4850) 111 #define TSL2561_AGC_TLO_13MS (100) 112 #define TSL2561_AGC_THI_101MS (36000) 113 #define TSL2561_AGC_TLO_101MS (200) 114 #define TSL2561_AGC_THI_402MS (63000) 115 #define TSL2561_AGC_TLO_402MS (500) 118 #define TSL2561_CLIPPING_13MS \ 120 #define TSL2561_CLIPPING_101MS \ 122 #define TSL2561_CLIPPING_402MS \ 126 #define TSL2561_DELAY_INTTIME_13MS (15) 127 #define TSL2561_DELAY_INTTIME_101MS (120) 128 #define TSL2561_DELAY_INTTIME_402MS (450) 132 TSL2561_REGISTER_CONTROL = 0x00,
133 TSL2561_REGISTER_TIMING = 0x01,
134 TSL2561_REGISTER_THRESHHOLDL_LOW = 0x02,
135 TSL2561_REGISTER_THRESHHOLDL_HIGH = 0x03,
136 TSL2561_REGISTER_THRESHHOLDH_LOW = 0x04,
137 TSL2561_REGISTER_THRESHHOLDH_HIGH =
139 TSL2561_REGISTER_INTERRUPT = 0x06,
140 TSL2561_REGISTER_CRC = 0x08,
141 TSL2561_REGISTER_ID = 0x0A,
142 TSL2561_REGISTER_CHAN0_LOW = 0x0C,
143 TSL2561_REGISTER_CHAN0_HIGH = 0x0D,
144 TSL2561_REGISTER_CHAN1_LOW = 0x0E,
145 TSL2561_REGISTER_CHAN1_HIGH = 0x0F
150 TSL2561_INTEGRATIONTIME_13MS = 0x00,
151 TSL2561_INTEGRATIONTIME_101MS = 0x01,
152 TSL2561_INTEGRATIONTIME_402MS = 0x02
157 TSL2561_GAIN_1X = 0x00,
158 TSL2561_GAIN_16X = 0x10,
171 boolean begin(TwoWire *theWire);
189 boolean _tsl2561Initialised;
190 boolean _tsl2561AutoGain;
193 int32_t _tsl2561SensorID;
197 void write8(uint8_t reg, uint8_t value);
198 uint8_t read8(uint8_t reg);
199 uint16_t read16(uint8_t reg);
200 void getData(uint16_t *broadband, uint16_t *ir);
203 #endif // ADAFRUIT_TSL2561_H uint32_t calculateLux(uint16_t broadband, uint16_t ir)
Converts the raw sensor values to the standard SI lux equivalent.
Definition: Adafruit_TSL2561_U.cpp:338
void enableAutoRange(bool enable)
Enables or disables the auto-gain settings when reading data from the sensor.
Definition: Adafruit_TSL2561_U.cpp:130
void setGain(tsl2561Gain_t gain)
Adjusts the gain on the TSL2561 (adjusts the sensitivity to light)
Definition: Adafruit_TSL2561_U.cpp:166
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 ...
Definition: Adafruit_TSL2561_U.cpp:194
tsl2561IntegrationTime_t
Definition: Adafruit_TSL2561_U.h:149
void getSensor(sensor_t *)
Gets the sensor_t data.
Definition: Adafruit_TSL2561_U.cpp:504
tsl2561Gain_t
Definition: Adafruit_TSL2561_U.h:156
Adafruit_TSL2561_Unified(uint8_t addr, int32_t sensorID=-1)
Constructor.
Definition: Adafruit_TSL2561_U.cpp:56
boolean begin(void)
Initializes I2C and configures the sensor with default Wire I2C (call this function before doing anyt...
Definition: Adafruit_TSL2561_U.cpp:77
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.
Definition: Adafruit_TSL2561_U.cpp:105
void setIntegrationTime(tsl2561IntegrationTime_t time)
Sets the integration time for the TSL2561. Higher time means more light captured (better for low ligh...
Definition: Adafruit_TSL2561_U.cpp:142
bool getEvent(sensors_event_t *)
Gets the most recent sensor event.
Definition: Adafruit_TSL2561_U.cpp:476
Class that stores state and functions for interacting with TSL2561 Light Sensor.
Definition: Adafruit_TSL2561_U.h:167