<em id="ri2my"></em>
  • <em id="ri2my"></em>
    <em id="ri2my"><label id="ri2my"><nav id="ri2my"></nav></label></em>
  • <em id="ri2my"><label id="ri2my"></label></em>
    <div id="ri2my"></div>
    1. <em id="ri2my"><label id="ri2my"></label></em>
    2. <em id="ri2my"><ol id="ri2my"></ol></em>
      <em id="ri2my"></em>

      1. nodemcu 例程,獲取溫濕度

        作者:shuxiansheng | 更新時間:2020-03-01 | 瀏覽量:771

        wifi.setmode(wifi.STATION)
        cfg = {}
        cfg.ssid =
        cfg.pwd =
        wifi.sta.config(cfg)
        wifi.sta.connect(cfg)
                        
        device_id =
        Product_id=
        AuthInfo=
        UPbroker =
        UPport =
        time1 = tmr.create()              
        time2 = tmr.create()     
        Temp_Humi_Pin = 5      
        UPbroker =     
        UPport =
             
        ip = wifi.sta.getip()     
            if wifi.sta.getip() == nil then 
                print("Disconnect,Waiting For IP...")
            else
                time1:stop()     
                print("連接成功")
               
              
                client_TempHumiLed = mqtt.Client("device_id",120,"Product_id","AuthInfo",false)
                client_TempHumiLed:connect(UPbroker,UPport,0,0,function(client)
                    print(" connect success!")
                end)
               
                time2:alarm(1500, tmr.ALARM_AUTO, Up_AC_Message)
            end
        end
        function Up_AC_Message()
            status,temp,humi,temp_dec,humi_dec = dht.read11(Temp_Humi_Pin)
            weather = {}                                                
            weather.temperature = temp    
            weather.humidity = humi    
            ok,weather_message = pcall(sjson.encode, weather)
            header = string.char(3, 0, string.len(weather_message))..weather_message
            client_TempHumiLed:publish("$dp",header,0,0,function(client)
                print("PUBLISH weather SUCCESS!")
            end)
        end
        time1:alarm(1000, tmr.ALARM_AUTO, Reconnect)  

        評論:共3條

        天從人愿 評論于:2020-03-03 09:25:08
        還可以
        aaronwang 評論于:2020-03-06 18:07:10
        謝謝大佬
        deng 評論于:2020-05-31 07:26:47
        大佬,有空能幫忙解答一下嗎?自己填寫的那部分還不太懂,可以的話加一下好友,謝謝!969439474
        返回頂部

        <em id="ri2my"></em>
      2. <em id="ri2my"></em>
        <em id="ri2my"><label id="ri2my"><nav id="ri2my"></nav></label></em>
      3. <em id="ri2my"><label id="ri2my"></label></em>
        <div id="ri2my"></div>
        1. <em id="ri2my"><label id="ri2my"></label></em>
        2. <em id="ri2my"><ol id="ri2my"></ol></em>
          <em id="ri2my"></em>

          1. 免费高清视频