docs/modules/tsl2561.md
| Since | Origin / Contributor | Maintainer | Source |
|---|---|---|---|
| 2015-08-22 | Michael Lucas | Michael Lucas | tsl2561.c |
Reads sensor values from the device and returns calculated lux value.
tsl2561.getlux()
none
lux the calculated illuminance in lux (lx)status value indicating success or failure as explained below:
tsl2561.TSL2561_OKtsl2561.TSL2561_ERROR_I2CINIT can't initialize I²C bustsl2561.TSL2561_ERROR_I2CBUSY I²C bus busytsl2561.TSL2561_ERROR_NOINIT initialize I²C bus before calling functiontsl2561.TSL2561_ERROR_LASTstatus = tsl2561.init(5, 6, tsl2561.ADDRESS_FLOAT, tsl2561.PACKAGE_T_FN_CL)
if status == tsl2561.TSL2561_OK then
lux = tsl2561.getlux()
print("Illuminance: "..lux.." lx")
end
Reads the device's 2 sensors and returns their values.
tsl2561.getrawchannels()
none
ch0 value of the broad spectrum sensorch1 value of the IR sensorstatus value indicating success or failure as explained below:
tsl2561.TSL2561_OKtsl2561.TSL2561_ERROR_I2CINIT can't initialize I²C bustsl2561.TSL2561_ERROR_I2CBUSY I²C bus busytsl2561.TSL2561_ERROR_NOINIT initialize I²C bus before calling functiontsl2561.TSL2561_ERROR_LASTstatus = tsl2561.init(5, 6, tsl2561.ADDRESS_FLOAT, tsl2561.PACKAGE_T_FN_CL)
if status == tsl2561.TSL2561_OK then
ch0, ch1 = tsl2561.getrawchannels()
print("Raw values: "..ch0, ch1)
lux = tsl2561.getlux()
print("Illuminance: "..lux.." lx")
end
Initializes the device on pins sdapin & sclpin. Optionally also configures the devices address and package. Default: address pin floating (0x39) and FN package.
tsl2561.init(sdapin, sclpin[, address[, package]])
sdapin pin number of the device's I²C sda connectionsclpin pin number of the device's I²C scl connectionaddress optional address of the device on the I²C bus
tsl2561.ADDRESS_GNDtsl2561.ADDRESS_FLOAT (default when omitted)tsl2561.ADDRESS_VDDpackage optional device's package type (slight difference in lux calculation)
tsl2561.PACKAGE_CStsl2561.PACKAGE_T_FN_CL (default when omitted)status value indicating success or failure as explained below:
tsl2561.TSL2561_OKtsl2561.TSL2561_ERROR_I2CINIT can't initialize I²C bustsl2561.TSL2561_ERROR_I2CBUSY I²C bus busytsl2561.TSL2561_ERROR_NOINIT Initialize I²C bus before calling functiontsl2561.TSL2561_ERROR_LASTstatus = tsl2561.init(5, 6, tsl2561.ADDRESS_FLOAT, tsl2561.PACKAGE_T_FN_CL)
if status == tsl2561.TSL2561_OK then
lux = tsl2561.getlux()
print("Illuminance: "..lux.." lx")
end
Sets the integration time and gain settings of the device. When tls2561.init() is called, these values default to 402 ms and no gain.
tsl2561.settiming(integration, gain)
integration sets the device's integration period. Valid options are:
tsl2561.INTEGRATIONTIME_13MStsl2561.INTEGRATIONTIME_101MStsl2561.INTEGRATIONTIME_402MS (default when omitted)gain sets the device's gain. Valid options are:
tsl2561.GAIN_1X (default when omitted)tsl2561.GAIN_16Xstatus value indicating success or failure as explained below:
tsl2561.TSL2561_OKtsl2561.TSL2561_ERROR_I2CINIT can't initialize I²C bustsl2561.TSL2561_ERROR_I2CBUSY I²C bus busytsl2561.TSL2561_ERROR_NOINIT initialize I²C bus before calling functiontsl2561.TSL2561_ERROR_LASTstatus = tsl2561.init(5, 6, tsl2561.ADDRESS_FLOAT, tsl2561.PACKAGE_T_FN_CL)
if status == tsl2561.TSL2561_OK then
status = tsl2561.settiming(tsl2561.INTEGRATIONTIME_101MS, tsl2561.GAIN_16X)
end
if status == tsl2561.TSL2561_OK then
lux = tsl2561.getlux()
print("Illuminance: "..lux.." lx")
end