21 #ifndef ADAFRUIT_TSL2561_H_ 22 #define ADAFRUIT_TSL2561_H_ 25 #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 (0x40) 43 #define TSL2561_WORD_BIT (0x20) 44 #define TSL2561_BLOCK_BIT (0x10) 46 #define TSL2561_CONTROL_POWERON (0x03) 47 #define TSL2561_CONTROL_POWEROFF (0x00) 49 #define TSL2561_LUX_LUXSCALE (14) 50 #define TSL2561_LUX_RATIOSCALE (9) 51 #define TSL2561_LUX_CHSCALE (10) 52 #define TSL2561_LUX_CHSCALE_TINT0 (0x7517) 53 #define TSL2561_LUX_CHSCALE_TINT1 (0x0FE7) 56 #define TSL2561_LUX_K1T (0x0040) 57 #define TSL2561_LUX_B1T (0x01f2) 58 #define TSL2561_LUX_M1T (0x01be) 59 #define TSL2561_LUX_K2T (0x0080) 60 #define TSL2561_LUX_B2T (0x0214) 61 #define TSL2561_LUX_M2T (0x02d1) 62 #define TSL2561_LUX_K3T (0x00c0) 63 #define TSL2561_LUX_B3T (0x023f) 64 #define TSL2561_LUX_M3T (0x037b) 65 #define TSL2561_LUX_K4T (0x0100) 66 #define TSL2561_LUX_B4T (0x0270) 67 #define TSL2561_LUX_M4T (0x03fe) 68 #define TSL2561_LUX_K5T (0x0138) 69 #define TSL2561_LUX_B5T (0x016f) 70 #define TSL2561_LUX_M5T (0x01fc) 71 #define TSL2561_LUX_K6T (0x019a) 72 #define TSL2561_LUX_B6T (0x00d2) 73 #define TSL2561_LUX_M6T (0x00fb) 74 #define TSL2561_LUX_K7T (0x029a) 75 #define TSL2561_LUX_B7T (0x0018) 76 #define TSL2561_LUX_M7T (0x0012) 77 #define TSL2561_LUX_K8T (0x029a) 78 #define TSL2561_LUX_B8T (0x0000) 79 #define TSL2561_LUX_M8T (0x0000) 82 #define TSL2561_LUX_K1C (0x0043) 83 #define TSL2561_LUX_B1C (0x0204) 84 #define TSL2561_LUX_M1C (0x01ad) 85 #define TSL2561_LUX_K2C (0x0085) 86 #define TSL2561_LUX_B2C (0x0228) 87 #define TSL2561_LUX_M2C (0x02c1) 88 #define TSL2561_LUX_K3C (0x00c8) 89 #define TSL2561_LUX_B3C (0x0253) 90 #define TSL2561_LUX_M3C (0x0363) 91 #define TSL2561_LUX_K4C (0x010a) 92 #define TSL2561_LUX_B4C (0x0282) 93 #define TSL2561_LUX_M4C (0x03df) 94 #define TSL2561_LUX_K5C (0x014d) 95 #define TSL2561_LUX_B5C (0x0177) 96 #define TSL2561_LUX_M5C (0x01dd) 97 #define TSL2561_LUX_K6C (0x019a) 98 #define TSL2561_LUX_B6C (0x0101) 99 #define TSL2561_LUX_M6C (0x0127) 100 #define TSL2561_LUX_K7C (0x029a) 101 #define TSL2561_LUX_B7C (0x0037) 102 #define TSL2561_LUX_M7C (0x002b) 103 #define TSL2561_LUX_K8C (0x029a) 104 #define TSL2561_LUX_B8C (0x0000) 105 #define TSL2561_LUX_M8C (0x0000) 108 #define TSL2561_AGC_THI_13MS (4850) 109 #define TSL2561_AGC_TLO_13MS (100) 110 #define TSL2561_AGC_THI_101MS (36000) 111 #define TSL2561_AGC_TLO_101MS (200) 112 #define TSL2561_AGC_THI_402MS (63000) 113 #define TSL2561_AGC_TLO_402MS (500) 116 #define TSL2561_CLIPPING_13MS (4900) 117 #define TSL2561_CLIPPING_101MS (37000) 118 #define TSL2561_CLIPPING_402MS (65000) 121 #define TSL2561_DELAY_INTTIME_13MS (15) 122 #define TSL2561_DELAY_INTTIME_101MS (120) 123 #define TSL2561_DELAY_INTTIME_402MS (450) 128 TSL2561_REGISTER_CONTROL = 0x00,
129 TSL2561_REGISTER_TIMING = 0x01,
130 TSL2561_REGISTER_THRESHHOLDL_LOW = 0x02,
131 TSL2561_REGISTER_THRESHHOLDL_HIGH = 0x03,
132 TSL2561_REGISTER_THRESHHOLDH_LOW = 0x04,
133 TSL2561_REGISTER_THRESHHOLDH_HIGH = 0x05,
134 TSL2561_REGISTER_INTERRUPT = 0x06,
135 TSL2561_REGISTER_CRC = 0x08,
136 TSL2561_REGISTER_ID = 0x0A,
137 TSL2561_REGISTER_CHAN0_LOW = 0x0C,
138 TSL2561_REGISTER_CHAN0_HIGH = 0x0D,
139 TSL2561_REGISTER_CHAN1_LOW = 0x0E,
140 TSL2561_REGISTER_CHAN1_HIGH = 0x0F
146 TSL2561_INTEGRATIONTIME_13MS = 0x00,
147 TSL2561_INTEGRATIONTIME_101MS = 0x01,
148 TSL2561_INTEGRATIONTIME_402MS = 0x02
155 TSL2561_GAIN_1X = 0x00,
156 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:352
+
void enableAutoRange(bool enable)
Enables or disables the auto-gain settings when reading data from the sensor.
Definition: Adafruit_TSL2561_U.cpp:132
+
void setGain(tsl2561Gain_t gain)
Adjusts the gain on the TSL2561 (adjusts the sensitivity to light)
Definition: Adafruit_TSL2561_U.cpp:168
+
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:195
tsl2561IntegrationTime_t
Definition: Adafruit_TSL2561_U.h:144
-
void getSensor(sensor_t *)
Gets the sensor_t data.
Definition: Adafruit_TSL2561_U.cpp:500
+
void getSensor(sensor_t *)
Gets the sensor_t data.
Definition: Adafruit_TSL2561_U.cpp:499
tsl2561Gain_t
Definition: Adafruit_TSL2561_U.h:153
Adafruit_TSL2561_Unified(uint8_t addr, int32_t sensorID=-1)
Constructor.
Definition: Adafruit_TSL2561_U.cpp:55
boolean begin(void)
Initializes I2C and configures the sensor with default Wire I2C (call this function before doing anyt...
Definition: Adafruit_TSL2561_U.cpp:76
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:106
-
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:146
-
bool getEvent(sensors_event_t *)
Gets the most recent sensor event.
Definition: Adafruit_TSL2561_U.cpp:471
+
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:145
+
bool getEvent(sensors_event_t *)
Gets the most recent sensor event.
Definition: Adafruit_TSL2561_U.cpp:470
Class that stores state and functions for interacting with TSL2561 Light Sensor.
Definition: Adafruit_TSL2561_U.h:167