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
$

沒有留言:

張貼留言

零成本學 ESP32!在 Wokwi 打造你的第一個微型氣象站 (ESP32 + DHT22 + 1602 LCD)

零成本學 ESP32!在 Wokwi 打造你的第一個微型氣象站(溫度 濕度) (ESP32 + DHT22 + 1602 LCD) 想學物聯網(IoT)與 ESP32 電子實作,卻擔心接線與電壓規範搞砸嗎?透過強大的線上模擬器 Wokwi ,我們不需要花費任何硬體費用,打開瀏覽器...