Ejemplo n.º 1
0
    def __init__(self, param='0', id=None, label=BMP085_STR, verbose=False):
        Sensor.__init__(self, param, id, label, verbose)

        bus_nb = parse_number(param, 0)

        if self.verbose:
            print 'DBG: BMP085 sensor \'{}\' bus number {:d}'.format(
                label, bus_nb)

        bmp = BMP085(busnum=bus_nb)

        self.temperature = bmp.read_temperature()
        self.pressure = bmp.read_pressure()
        self.altitude = bmp.read_altitude()
Ejemplo n.º 2
0
    def __init__(self, param='0', id=None, label=HTU21D_STR, verbose=False):
        Sensor.__init__(self, param, id, label, verbose)

        bus_nb = parse_number(param, 0)

        if self.verbose:
            print 'DBG: HTU21D sensor \'{}\' bus number {:d}'.format(
                label, bus_nb)

        self.dev = None
        try:
            self.dev = I2CSystem(self.__HTU21DF_I2CADDR, bus_nb)

            self.__htu_reset()
            self.temperature = self.__read_temperature()

            self.__htu_reset()
            self.humidity = self.__read_humidity(self.temperature)
        finally:
            if self.dev is not None:
                self.dev.close()
Ejemplo n.º 3
0
    def __init__(self, sensor_type='22', pin='4', id=None, label=DHT_STR, verbose=False):
        Sensor.__init__(self, pin, id, label, verbose)
        self.sensor_type_nb = parse_number(sensor_type, 22)
        self.pin = pin

        if self.sensor_type_nb == 11:
            sensor = Adafruit_DHT.DHT11
        elif self.sensor_type_nb == 2302:
            sensor = Adafruit_DHT.AM2302
        else :
            sensor = Adafruit_DHT.DHT22

        if self.verbose:
            print 'DBG: DHT{} sensor \'{}\' pin {}'.format(
                self.sensor_type_nb, label, pin)

        self.humidity, self.temperature = Adafruit_DHT.read_retry(sensor, pin)

        if self.verbose:
            print 'DBG: Temperature = {:.2f} °C'.format(self.temperature)
            print 'DBG: Humidity    = {:.2f} %'.format(self.humidity)
Ejemplo n.º 4
0
 def generate_id(self, param):
     return '{}_{}'.format(parse_number(param, default=0), HTU21D_STR)