Пример #1
0
# Imports from mraa and upm libraries
#------------------------------------
import mraa
import thread, time, math

import pyupm_htu21d

# Constant declarations
#----------------------
# i2c bus 1 on RaspBerryPI
bus1 = 0
tempAddress = 0x40

# create sensors on the bus 1
htu21df = pyupm_htu21d.HTU21D(bus1)

#htu21df = pyupm_htu21d.HTU21D(bus1, tempAddress)


#Functions
#---------
# HTU21D-F
#*********
def htuReset():
    htu21df.resetSensor()
    time.sleep(2)
    return


def htuTest():
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import thread, time
import pyupm_htu21d
import mraa

# i2c bus
bus = 1
tempAddress = 0x40
#check = raw_input()

# create sensor on the bus
htu21df = pyupm_htu21d.HTU21D(bus, tempAddress)


def reset():
    htu21df.resetSensor()
    time.sleep(2)
    return


def test():
    htu21df.testSensor()
    time.sleep(2)
    return


def input_thread(CheckInput):
    check = raw_input()
    CheckInput = CheckInput.append(check)
Пример #3
0
I2C_STD = 0
I2C_FAST = 1
I2C_HIGH = 2 
tempAddress = 0x40
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()