def index(): global tempMax,tempMin,humiMax,humiMin global blinkValue, blinkType, bKeepBlinking th02_sensor = Th02.TH02(1) temp = th02_sensor.getTemperature() if(temp>tempMax): tempMax = temp if(temp<tempMin): tempMin = temp if((float(temp)>float(blinkValue)) and (blinkType=='temp')): if(bKeepBlinking==False): bKeepBlinking = True b1 = Thread(target=Blinking) b1.start() humi = th02_sensor.getHumidity() if(humi>humiMax): humiMax = humi if(humi<humiMin): humiMin = humi if((float(humi)>float(blinkValue)) and (blinkType=='humi')): if(bKeepBlinking==False): bKeepBlinking = True b1 = Thread(target=Blinking) b1.start() return render_template('Index.html', temp=temp, tempMax=tempMax, tempMin=tempMin, humi=humi, humiMax=humiMax, humiMin=humiMin)
def __init__(self): self.button = None self.encoder = None self.light = None self.relay = None self.speaker = None self.motion = None self.lcd = None # Create the Grove LED object using GPIO pin 13 self.led = grove.GroveLed(13) self.servo = None # Create the temperature sensor object using I2C self.th = th02.TH02() self.uv_sensor = None
Angle = 0 # Create the button object usind D3 button = grove.GroveButton(3) # Create the servo object using D6 gServo = servo.ES08A(6) # Initialize Jhd1313m1 at 0x3E (LCD_ADDRESS) and 0x62 (RGB_ADDRESS) myLcd = lcd.Jhd1313m1(0, 0x3E, 0x62) # Create the light sensor object using AIO pin 2 light = grove.GroveLight(2) # Create the temperature sensor object using AIO pin 2 #temp = grove.GroveTemp(2) # Create relay object using D5 relay = grove.GroveRelay(5) # Initialize TH02 temperature sensor at 0x40 gTemp = temp.TH02(0, 0x40) # Initialize servo to 0 degrees gServo.setAngle(Angle) def functionLight(bot, update): luxes = light.value() bot.sendMessage(update.message.chat_id, text='Room Light: ' + str(luxes) + ' luxes') def functionTemperature(bot, update): temperature = gTemp.getTemperature() bot.sendMessage(update.message.chat_id, text='Room Temp: ' + str(temperature) + ' Celsius')
def __init__(self, bus): self.th02_sensor = upmTh02.TH02(bus) self.temperature_celsius = 0.0 self.temperature_fahrenheit = 0.0 self.humidity = 0.0
myLcd.write('IoT') # Instantiate a Grove Moisture sensor on analog pin A1 moisture = upmMoisture.GroveMoisture(1) # Create the light sensor object using AI2 pin 2 light = grove.GroveLight(2) # Instantiate a UV sensor on analog pin A3 uv = upmUV.GUVAS12D(3); # analog voltage, usually 3.3 or 5.0 GUVAS12D_AREF = 5.0; SAMPLES_PER_QUERY = 1024; # Create the temperature sensor object using AIO pin 0 i2c_th = th02.TH02() # p = Phant(keys["publicKey"], 'device', 'temp', 'humidity', 'light', "uv", "moisture", private_key=keys["privateKey"]) device = open("/factory/serial_number").read().strip('\n') temp = i2c_th.getTemperature() humid = i2c_th.getHumidity() lux_val = light.value() uv_val = uv.value(GUVAS12D_AREF, SAMPLES_PER_QUERY) moisture_val = moisture.value() myLcd.setCursor(1, 0)
#!/usr/bin/env python # -*- coding: utf-8 -*- import mraa import thread, time import pyupm_th02 # create sensor th02 = pyupm_th02.TH02(6, 0x40) print th02.name() print th02 def input_thread(CheckInput): check = raw_input() CheckInput = CheckInput.append(check) return def mesureTempHygro(): CheckInput = [] thread.start_new_thread(input_thread, (CheckInput, )) print '\nTapez "stop" pour arrêter les mesures.\n' print 'Température :\t\t' + 'Hygrométrie :\t\t' # Loop while True: if CheckInput == ['stop']: print 'Arrêt demandé.' break if th02.getStatus(): temp = th02.getTemperature()
pressAdress = 0x60 multiAdress = 0x04 i2cBus = mraa.I2c(bus) i2cBus.frequency(I2C_STD) i2cBus.frequency(I2C_FAST) mraa.printError(i2cBus.frequency(I2C_FAST)) MRAA: SUCCESS press = pyupm_mpl3115a2.MPL3115A2(bus, pressAdress) temp = pyupm_htu21d.HTU21D(bus, tempAddress) uv = pyupm_guvas12d.GUVAS12D(0) air = pyupm_mq135.MQ135(1) ch4 = pyupm_gas.MQ4(2) th02 = pyupm_th02.TH02(bus, tempAddress) i2cBus.address(tempAddress) temp.resetSensor () temp.sampleData() RH = temp.getCompRH() temperature = temp.getTemperature() hygro = temp.getHumidity () print '\t%.3f\t\t'%temperature + '%.3f\t\t'%hygro + '%.3f'%RH i2cBus.address(pressAdress) press.sampleData() temperatureP = press.getTemperature() pressure = press.getPressure() pressea = press.getSealevelPressure() alt = press.getAltitude()