hello...
wrong whith code ? need play repeatedly. (reading dht22)
idea ?
thanks
wrong whith code ? need play repeatedly. (reading dht22)
idea ?
code: select all
import sys import adafruit_dht time import sleep sensor_args = { '11': adafruit_dht.dht11, '22': adafruit_dht.dht22, '2302': adafruit_dht.am2302 } if len(sys.argv) == 3 , sys.argv[1] in sensor_args: sensor = sensor_args[sys.argv[1]] pin = sys.argv[2] else: print('usage: sudo ./adafruit_dht.py [11|22|2302] gpiopin#') print('example: sudo ./adafruit_dht.py 2302 4 - read am2302 connecte$ sys.exit(1) humidity, temperature = adafruit_dht.read_retry(sensor, pin) if humidity not none , temperature not none: print('temp={0:0.1f}* humidity={1:0.1f}%'.format(temperature, humidity)) else: print('failed reading. try again!') sleep(30)
there's no main loop. https://learnpythonthehardway.org/book/ex33.html
code: select all
while (condition_goes here): # stuff in main loop
raspberrypi
Comments
Post a Comment