2017年8月21日 星期一
MicroPython DHT11測試 4 : Try ....except 與WDT (watch dog Timer)
#測試 4 : Try ....except 與WDT (watch dog Timer)
#=============================================================================
# leds 0 = d3 , 1 = d10 , 2 = d4 , 3 = d9 , 4 = d2 , 5 = d1
# 9 = sdd2 , 10 = sdd3
# 12 = d6 , 13 = d7 , 14 = d5 , 15 = d8 , 16 = d0
#=============================================================================
from machine import Pin
from machine import WDT
import dht
import time
import urequests
p0=Pin(4, Pin.IN)
p2=Pin(2, Pin.OUT)
d=dht.DHT11(p0)
host='http://api.thingspeak.com'
api_key='U52Q30TDQDA0G6IW'
wdt=WDT() #無參數就可以順利建立 WDT 物件
def LED_blink(s):
wdt
for i in range(1,10*s):
p2.value(1)
time.sleep_ms(50)
p2.value(0)
time.sleep_ms(50)
while True:
try:
d.measure()
t=d.temperature()
f=round(t * 9/5 + 32)
h=d.humidity()
url='%s/update?api_key=%s&field1=%s&field2=%s&field3=%s' %(host, api_key, t, f, h)
print('Temperature=', t, 'C', '/', f, 'F', 'Humidity=', h, '%')
r=urequests.get(url)
print('response=', r.text)
except:
print('urequests.get() exception occurred!')
LED_blink(16)
訂閱:
張貼留言 (Atom)
MQTT 協定與 Modbus 通訊的遠端監控與控制系統架構
MQTT 協定與 Modbus 通訊的遠端監控與控制系統架構 這張圖片展示了一個 結合 MQTT 協定與 Modbus 通訊的遠端監控與控制系統架構 (主要透過 Node-RED 進行資料整合)。 系統包含三個核心部分,其運作功能說明如下: 1. ESP32 終端設備(硬體控制層...
-
數位IC設計入門-Verilog combinational logic 8 to 1 Multiplexer 多工器 Behavioral Modeling (& Test Bench) //數位IC設計入門-Verilog combinationa...
-
python pip 不是内部或外部命令 -- 解決方法 要安裝 Pyqt5 1. 首先,開啟命令提示字元。 2. 輸入 pip3 install pyqt5 好像不能執行 ! ! 錯誤顯示 : ‘ pip3 ’ 不是內部或外部命令、可執行的程式或批...
-
Line 發報機 Python TKinter (CONFIG_LINE Message API_2.py) import serial import serial.tools.list_ports import tkinter as tk from tkinter import...

沒有留言:
張貼留言