Beispiel #1
0
    def __init__(self):
        SensorValue.__init__(self)

        self.raw_value = -1
        self.raw_high_value = 5000
        self.raw_low_value = 500
        self.unit = UNIT_RPM
Beispiel #2
0
    def __init__(self):
        SensorValue.__init__(self)

        self.raw_value = -273
        self.raw_high_value = 60
        self.raw_low_value = 20
        self.unit = UNIT_CELSIUS
Beispiel #3
0
    def __init__(self):
        SensorValue.__init__(self)

        self.raw_value = 0
        self.raw_high_value = 12
        self.raw_low_value = -12
        self.unit = UNIT_VOLT
    def gettempandhumidity(self, config):

        pin = config.configuredsensors['tempandhumidity'].port

        dht_sensor_type = 0  # change this depending on your sensor type - see header comment

        try:
            [temp, humidity] = grovepi.dht(pin, dht_sensor_type)
            print "temp =", temp, " humidity =", humidity

            sensordata = []
            sensordata.append(SensorValue(temp, 'none', 'temp', 'location'))
            sensordata.append(
                SensorValue(humidity, 'none', 'humidity', 'location'))

        except IOError:
            print "Error"
        return sensordata
    def getloudnessinfo(self, config):

        sensordata = []
        pin = config.configuredsensors['loudness'].port
        try:
            # Read the sound level
            sensor_value = grovepi.analogRead(pin)
            sensordata.append(
                SensorValue(sensor_value, 'none', 'Loudness', 'location'))

        except IOError:
            print("Error")

        return sensordata
def readdustsensor(location):
    atexit.register(grovepi.dust_sensor_dis)

    print("Reading from the dust sensor")
    grovepi.dust_sensor_en()
    while True:
        try:
                    [new_val,lowpulseoccupancy] = grovepi.dustSensorRead()
                    if new_val:
                            print(lowpulseoccupancy)
                            sensordata = SensorValue(lowpulseoccupancy, 'none', 'Dust', location)
                            writetofile(sensordata)
                    time.sleep(5) 

        except IOError:
            print ("Error")
    def getgassensorvalue(self, config):

        sensordata = []

        pin = config.configuredsensors['gas'].port

        grovepi.pinMode(pin, "INPUT")
        try:
            # Get sensor value

            sensor_value = grovepi.analogRead(pin)

            # Calculate gas density - large value means more dense gas
            density = (float)(sensor_value / 1024)
            sensordata.append(
                SensorValue(sensor_value, 'none', 'Gas', 'location'))

        except IOError:
            print("Error")

        return sensordata
    def getairqualitysensorvalue(self, config):

        sensordata = []
        pin = config.configuredsensors['airquality'].port
        grovepi.pinMode(pin, "INPUT")

        try:
            # Get sensor value
            sensor_value = grovepi.analogRead(pin)

            if sensor_value > 700:
                print("High pollution")
            elif sensor_value > 300:
                print("Low pollution")
            else:
                print("Air fresh")
            sensordata.append(
                SensorValue(sensor_value, 'none', 'airquality', 'location'))
        except IOError:
            print("Error")

        return sensordata