Exemplo n.º 1
0
    def run(self):

        # Try to grab a sensor reading.  Use the read_retry method which will retry up
        # to 15 times to get a sensor reading (waiting 2 seconds between each retry).
        while True:
            try:
                if running_mode.RUNNING_MODE == 'N':
                    humidity, temperature = Adafruit_DHT.read_retry(iotUtils.TEMP_SENSOR_TYPE,
                                                                    iotUtils.TEMP_PIN)
                else:
                    humidity, temperature = iotUtils.generateRandomSensorValues()

                if temperature != iotUtils.LAST_TEMP:
                    time.sleep(PUSH_INTERVAL)
                    iotUtils.LAST_TEMP = temperature
                    #  connectAndPushData()

                iotUtils.LAST_TEMP = temperature
                print 'RASPBERRY_STATS: Temp={0:0.1f}*C  Humidity={1:0.1f}%'.format(temperature,
                                                                                    humidity)

            except Exception, e:
                print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
                print "RASPBERRY_STATS: Exception in TempReaderThread: Could not successfully " \
                      "read Temperature"
                print ("RASPBERRY_STATS: " + str(e))
                pass
                time.sleep(self.interval)
Exemplo n.º 2
0
def getSensorValue():
    return iotUtils.generateRandomSensorValues()
Exemplo n.º 3
0
def getSensorValue():
    return iotUtils.generateRandomSensorValues()