2017年2月8日 星期三

【MicroPython】LAB01 - DHT11 溫濕度

【MicroPython】LAB01 - DHT11 溫濕度



User@User-PC MINGW64 /c/mini3

$ cat DHT11.py
import machine
import dht
import time

d = dht.DHT11(machine.Pin(4))

for i in range (1,11) :
    a0=d.measure()
    a1=d.temperature() # eg. 23 (▒XC)
    a2=d.humidity()    # eg. 41 (% RH)

    print ('temperature {0:2d}'.format(a1))
    print ('humidity {0:2d}'.format(a2))

    time.sleep(1.0)


#=========================================
# d = dht.DHT22(machine.Pin(4))
# d.measure()
# d.temperature() # eg. 23.6 (▒XC)
# d.humidity()    # eg. 41.3 (% RH)
#=========================================
User@User-PC MINGW64 /c/mini3

$ ampy --port COM8 run DHT11.py
temperature 26
humidity 34
temperature 26
humidity 34
temperature 26
humidity 34
temperature 26
humidity 34
temperature 26
humidity 34
temperature 26
humidity 34
temperature 26
humidity 34
temperature 26
humidity 34
temperature 26
humidity 34
temperature 26
humidity 34

User@User-PC MINGW64 /c/mini3
$

沒有留言:

張貼留言

WOKWI DHT22 & LED , Node-Red + SQLite database

 WOKWI DHT22 & LED , Node-Red + SQLite database Node-Red程式 [{"id":"6f0240353e534bbd","type":"comment&...