這個項目的這個問題困擾了自己好長時間了,ESP8266芯片發熱,導致了旁邊的溫濕度傳感器采集不了空氣中的溫度....采集的溫度是芯片發熱的溫度
一直采集出來的是30多度......盡管空氣溫度10幾度
其實我的方式很簡單很簡單,先應對現在的問題,現在沒有時間做的更好一點了,測試更完善來不及了.....
由於設備的功能只是采集,采集完上傳
我的做法其實很簡單.....延時休眠,啟動采集,延時休眠,啟動采集,延時休眠
但是這種做法就不能實時的接收數據了...不過還好現在沒有接收處理部分(主要是現在的接收處理現在並不是必須的)...
1S定時器
如果MQTT連接成功,就采集溫濕度數據,第一次的不要,第二次的發送出去,如果判斷cnt>=2 就讓芯片休眠10分鍾(就不會執行用戶程序了)
如果cntTime>=10說明10S內都沒有執行上面采集發送的操作,則芯片休眠5分鍾
local status, temp, humi, temp_dec, humi_dec, globalSendData; local cnt=0 local cntTime=0 local DHT11pin = 5--DHT11 GPIO local DTH11Timer = tmr.create() DTH11Timer:register(1000, 1, function() if cnt >=2 then cntTime=0; node.dsleep(600000000,1) cnt=0; end cntTime = cntTime +1; if cntTime > 10 then cntTime=0; cnt=0; node.dsleep(300000000,1) end if MqttConnectedFlage == true then status, temp, humi, temp_dec, humi_dec = dht.read11(DHT11pin)--Gathering temperature and humidity if status == dht.OK or status == dht.ERROR_CHECKSUM then cnt = cnt +1; if cnt >=2 then cntTime=0; temp_dec = temp; humi_dec = humi; temp = temp+TempAdd; humi = humi+HumiAdd; globalSendData = "{".."data:".."TH"..",".."bit:1,".."temperature:"..temp..",".."humidity:"..humi..",temperatureok:"..temp_dec..",humidityok:"..humi_dec.."}" if Mymqtt ~= nil and MqttConnectedFlage == true then Mymqtt:publish(PublishTopic,globalSendData, 0, 0, function(client)end) end print("DHT Temperature:"..temp..";".."Humidity:"..humi) end elseif status == dht.ERROR_TIMEOUT then --print( "DHT timed out." ) --temp = 0; --humi = 0; --temp = temp+TempAdd; --humi = humi+HumiAdd; --globalSendData = "{".."data:".."TH"..",".."bit:1,".."temperature:"..temp..",".."humidity:"..humi.."}" end end tmr.softwd(60) --print( "wdclr()" ) end) DTH11Timer:start();
注:
node.dsleep(600000000,1)
執行該函數,設備休眠10分鍾以后,會自動重新啟動
不過您需要
GPIO16 和 RST 連接上


注:其實咱都知道最好的方式是可以保持着通信,就是可以處理網絡接受的數據
這個以后再搞吧,先用這種方式應急.
現在的wifi模塊一點都不會發熱了.....
以前我的PCB板子也做了處理,也是可以減小芯片發熱對溫度傳感器的影響,不過呢!這種板子的PCB板子不要密封....因為密封以后熱量就散不出去了
因為我的PCB基本上是密封的,所以只能使用休眠了

基本上分隔開PCB板的發熱部分和傳感器部分
連接傳感器的線加長....
