Exemplo n.º 1
0
 def get_measurement(self):
     """ Gets the DS18B20's lux in Celsius by reading the temp file and div by 1000"""
     tsl = TSL2561(self.i2c_address, "/dev/i2c-" + str(self.i2c_bus))
     tsl.enable_autogain()
     # tsl.set_gain(16)
     tsl.set_time(0x00)
     return tsl.lux()
Exemplo n.º 2
0
 def read(self):
     try:
         tsl = TSL2561(self.i2c_address, "/dev/i2c-" + str(self.i2c_bus))
         tsl.enable_autogain()
         # tsl.set_gain(16)
         tsl.set_time(0x00)
         self._lux = tsl.lux()
     except:
         return 1
Exemplo n.º 3
0
    def __init__(self):
        self.sensorArray = list()
        #Initialize all sensors
        self.tsl = TSL2561(0x39, "/dev/i2c-1")
        self.tsl.enable_autogain()
        self.tsl.set_time(0x00)

        self.mpl = MPL115A2(0x60, "/dev/i2c-1")
        """Add sensors metadata to Array. This has to be done manually
		because you need to set up the part number of the sensor used.
		Therefore, you have to add each measure information which means
		the kind of reading you are sensing (like light, pressure, noise, etc...)
		and the reading unity (e.g.: for temperature you can measure using
		celsius or farenheit, so you have to specify C or F according to
		the case).
		"""
        tmpSensor = Sensor(partNumber="TSL2561")
        tmpSensor.addToMetadata(readingType="light", readingUnit="lumens")
        self.sensorArray.append(tmpSensor)
        tmpSensor = Sensor(partNumber="MPL115A2")
        tmpSensor.addToMetadata(readingType="pressure", readingUnit="kPa")
        tmpSensor.addToMetadata(readingType="temperature", readingUnit="C")
        self.sensorArray.append(tmpSensor)
        print "Sensors module started. " + str(len(self.sensorArray))
Exemplo n.º 4
0
#arguments will be in a separate .ini file (sys.argv[1]) which is read in and parsed to get different argument types
inputfile = str(
    sys.argv[1]
)  #the input .ini file is given as the first argument when the python script is called

#setup hardware (only ever needs to happen once)
#set up LED indicator light via GPIO 16 (turns on whenever lights are on)
GPIO.setmode(GPIO.BCM)
GPIO.setup(16, GPIO.OUT)

#setup Heater via Powerswitch on GPIO 23
GPIO.setmode(GPIO.BCM)
GPIO.setup(23, GPIO.OUT)

#set up light moniter
tsl = TSL2561(0x39, "/dev/i2c-1")
tsl.enable_autogain()
tsl.set_time(0x00)

#Turn on temperature sensor
sensor = MCP9808.MCP9808()
sensor.begin()

#determine hostname of computer and start a day counter
hostname = subprocess.check_output(["hostname"]).strip()
lastday = 0

#define function for sending warning email if tempearture is out of range:
GMAIL_USER = "******"
GMAIL_PASS = "******"
SMTP_SERVER = "smtp.gmail.com"
Exemplo n.º 5
0
print "temperature: %0.1f" % temperature
print "humidity: %0.1f" % humidity
print "crc: %s" % crc_check
print
time.sleep(2)

print "test BMP180"
bmp = BMP180(0x77, I2C_DEVICE)
print "temperature: %0.1f" % bmp.temperature()
print "pressure: %s" % bmp.pressure()
print "altitude: %0.1f" % bmp.altitude()
print
time.sleep(2)

print "test TSL2561"
tsl = TSL2561(0x39, I2C_DEVICE)
tsl.enable_autogain()
tsl.set_time(0x00)
print "lux %s" % tsl.lux()
print
time.sleep(2)

print "test MCP9808"
mcp = MCP9808(0x18, I2C_DEVICE)
temperature = mcp.temperature()
print "temperature: %0.2f" % temperature
print
time.sleep(2)

print "test MPL115A2"
mpl = MPL115A2(0x60, I2C_DEVICE)