Example #1
0
HEAT_LOW = 20
COOL_HI = 30
COOL_LOW = 27
HUMIDITY_HI = 50
HUMIDITY_LOW = 45
CO2_LOW = 1000
CO2_HIGH = 1500
CO2_SAFETY = 2000

cooling_enable = 1
dehumidifier_enable = 1
safety_enable = 0
bus_lock = 0
run = 1
air_sensor = BME280(p_mode=BME280_OSAMPLE_8, t_mode=BME280_OSAMPLE_2, h_mode=BME280_OSAMPLE_1, filter=BME280_FILTER_16)
light_sensor = TSL2591()
co2_sensor = MHZ16()
co2_sensor_starting = 1
co2_restart_hour = 0
relays = MCP23017()
degrees = 0
pascals = 0
humidity = 0
ppm = 0
lux = 0
hours = 0
minutes = 0
seconds = 0
start_delay = 1
co2_sensor_restart_count = 0
co2_restart_wait = 0
import sys
sys.path.append('./TSL2591')

import time
import sys

import TSL2591

tsl = TSL2591.Tsl2591()  # initialize
full, ir = tsl.get_full_luminosity(
)  # read raw values (full spectrum and ir spectrum)
lux = tsl.calculate_lux(full, ir)  # convert raw values to lux
print(lux, full, ir)
print()


def test(int_time=TSL2591.INTEGRATIONTIME_100MS, gain=TSL2591.GAIN_LOW):
    tsl.set_gain(gain)
    tsl.set_timing(int_time)
    full_test, ir_test = tsl.get_full_luminosity()
    lux_test = tsl.calculate_lux(full_test, ir_test)
    print('Lux = %f  full = %i  ir = %i' % (lux_test, full_test, ir_test))
    print("integration time = %i" % tsl.get_timing())
    print("gain = %i \n" % tsl.get_gain())


for i in [
        TSL2591.INTEGRATIONTIME_100MS, TSL2591.INTEGRATIONTIME_200MS,
        TSL2591.INTEGRATIONTIME_300MS, TSL2591.INTEGRATIONTIME_400MS,
        TSL2591.INTEGRATIONTIME_500MS, TSL2591.INTEGRATIONTIME_600MS
]:
Example #3
0
import time
import sys
import os

import logging
import TSL2591

logging.basicConfig(level=logging.INFO)

sensor = TSL2591.TSL2591()
# sensor.SET_InterruptThreshold(0xff00, 0x0010)

try:
    while True:
        lux = sensor.Lux
        print('Lux: %d' % lux)
        sensor.TSL2591_SET_LuxInterrupt(50, 200)
        infrared = sensor.Read_Infrared
        print('Infrared light: %d' % infrared)
        visible = sensor.Read_Visible
        print('Visible light: %d' % visible)
        full_spectrum = sensor.Read_FullSpectrum
        print('Full spectrum (IR + visible) light: %d\r\n' % full_spectrum)

except KeyboardInterrupt:
    logging.info("ctrl + c:")
    sensor.Disable()
    exit()