#include #include #include #include "Adafruit_TSL2591.h" #include Adafruit_TSL2591 tsl = Adafruit_TSL2591(2591); // pass in a number for the sensor identifier (for your use later) const uint8_t i2caddr = 0x29; TwoWire tsl2w = TwoWire(0); void setup() { Serial.begin(115200); Log.begin(LOG_LEVEL_NOTICE, &Serial); tsl2w.setPins(22, 23); if (tsl.begin(&tsl2w, i2caddr)) { Log.notice(F("Found a TSL2591 sensor")); } tsl.setTiming(TSL2591_INTEGRATIONTIME_300MS); } void printLux(tsl2591Gain_t gain) { tsl.setGain(gain); uint32_t lum = tsl.getFullLuminosity(); uint16_t ir, full; ir = lum >> 16; full = lum & 0xFFFF; float lux = tsl.calculateLux(full, ir); Log.notice(F("2 - g=%d l=%F i=%d f=%d" CR), gain, lux, ir, full); } void loop() { Log.notice(F("----------------------------" CR)); printLux(TSL2591_GAIN_LOW); printLux(TSL2591_GAIN_MED); printLux(TSL2591_GAIN_HIGH); delay(1000); }