ESP8266低功耗解决的其中一个问题(芯片发热,影响旁边的温湿度芯片) |
您所在的位置:网站首页 › 服务器为什么会发热 › ESP8266低功耗解决的其中一个问题(芯片发热,影响旁边的温湿度芯片) |
这个项目的这个问题困扰了自己好长时间了,ESP8266芯片发热,导致了旁边的温湿度传感器采集不了空气中的温度....采集的温度是芯片发热的温度 一直采集出来的是30多度......尽管空气温度10几度 其实我的方式很简单很简单,先应对现在的问题,现在没有时间做的更好一点了,测试更完善来不及了..... 由于设备的功能只是采集,采集完上传 我的做法其实很简单.....延时休眠,启动采集,延时休眠,启动采集,延时休眠 但是这种做法就不能实时的接收数据了...不过还好现在没有接收处理部分(主要是现在的接收处理现在并不是必须的)... 1S定时器 如果MQTT连接成功,就采集温湿度数据,第一次的不要,第二次的发送出去,如果判断cnt>=2 就让芯片休眠10分钟(就不会执行用户程序了) 如果cntTime>=10说明10S内都没有执行上面采集发送的操作,则芯片休眠5分钟 代码语言:javascript复制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();注: 代码语言:javascript复制node.dsleep(600000000,1) 执行该函数,设备休眠10分钟以后,会自动重新启动 不过您需要 GPIO16 和 RST 连接上![]() |
今日新闻 |
点击排行 |
|
推荐新闻 |
图片新闻 |
|
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭 |