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
$

沒有留言:

張貼留言

MQTT WS HMI 與 Wokwi ESP32 連線的資訊透過HiveMQ

MQTT WS HMI 與 Wokwi ESP32 連線的資訊透過HiveMQ     https://console.hivemq.cloud/clusters 當您進入 HiveMQ Cloud Console 的 Clusters 頁面時,您的目標是取得能讓 MQTT W...