2022年9月30日 星期五

Node-Red 大里區空氣品質狀況

 Node-Red 大里區空氣品質狀況



  


 

flow.set("temp",msg.payload);

var rawdata = flow.get("temp");

 

var citynumber=rawdata.records.length;

var records_array=[];

var i;

for (i=0; i<citynumber;i++)

{

    records_array[i]=rawdata.records[i]

}

 

msg.payload=records_array;

flow.set("RECORDS",records_array);

 

return msg;a



var a = msg.payload;

 

a.forEach (function(e,i) {

   if(e.sitename =='大里') {

    msg.AQI = ' AQI=' + e['aqi'] ;

    msg.POL = ' AQI=' + e['pollutant'] ;

    msg.PM25 = ' PM2.5=' + e['pm2.5'] ;

    msg.PM25AVG = ' PM2.5 AVG=' + e['pm2.5_avg'] ;

    msg.Status = ' Status=' + e['status'] ;

    msg.PublishTime =' PublishTime='+ e['publishtime'] ;

    msg.payload='大里區'+msg.AQI+msg.PM25+msg.POL+msg.Status+msg.PublishTime;

 

    msg.AQI1 =  e['aqi'] ;

    msg.POL1 =  e['pollutant'] ;

    msg.PM251 = e['pm2.5'] ;

    msg.PM25AVG1 = e['pm2.5_avg'] ;

    msg.Status1 =  e['status'] ;

    msg.PublishTime1 = e['publishtime'] ;

   }

 } );

return msg;



 


29: object

sitename: "大里"

county: "臺中市"

aqi: "64"

pollutant: "細懸浮微粒"

status: "普通"

so2: "2.1"

co: "0.44"

o3: "28.5"

o3_8hr: "58.4"

pm10: "38"

pm2.5: "22"

no2: "22"

nox: "23.3"

no: "1.2"

wind_speed: "1.3"

wind_direc: "2"

publishtime: "2022/09/30 19:00:00"

co_8hr: "0.3"

pm2.5_avg: "20"

pm10_avg: "45"

so2_avg: "2"

longitude: "120.67844444"

latitude: "24.09961111"

siteid: "30"

 




array[86]

[0 … 9]

0: object

sitename: "基隆"

county: "基隆市"

aqi: "20"

pollutant: ""

status: "良好"

so2: ""

co: "0.19"

o3: "18"

o3_8hr: "19.1"

pm10: "18"

pm2.5: "11"

no2: "4.3"

nox: "5.7"

no: "1.4"

wind_speed: "0.9"

wind_direc: "94"

publishtime: "2022/09/30 19:00:00"

co_8hr: "0.1"

pm2.5_avg: "6"

pm10_avg: "10"

so2_avg: "0"

longitude: "121.760056"

latitude: "25.129167"

siteid: "1"

 




[{"id":"a0e05e56b90ecabf","type":"tab","label":"流程6","disabled":false,"info":"","env":[]},{"id":"784cb713.fa8498","type":"inject","z":"a0e05e56b90ecabf","name":"","repeat":"20","crontab":"","once":true,"onceDelay":"5","topic":"","payload":"","payloadType":"date","x":100,"y":140,"wires":[["ae1e2fd0.e0a9a"]]},{"id":"ae1e2fd0.e0a9a","type":"http request","z":"a0e05e56b90ecabf","name":"AQI網頁","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://data.epa.gov.tw/api/v2/aqx_p_432?api_key=e8dd42e6-9b8b-43f8-991e-b3dee723a52d&limit=1000&sort=ImportDate%20desc&format=JSON","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":240,"y":140,"wires":[["d51b6fa7448dc94c","8850bfb05c7ca503"]]},{"id":"48068d3d.60f764","type":"function","z":"a0e05e56b90ecabf","name":"大里","func":"var a = msg.payload;\n\na.forEach (function(e,i) {\n   if(e.sitename =='大里') {\n    msg.AQI = ' AQI=' + e['aqi'] ;\n    msg.POL = ' AQI=' + e['pollutant'] ;\n    msg.PM25 = ' PM2.5=' + e['pm2.5'] ;\n    msg.PM25AVG = ' PM2.5 AVG=' + e['pm2.5_avg'] ;\n    msg.Status = ' Status=' + e['status'] ;\n    msg.PublishTime =' PublishTime='+ e['publishtime'] ;\n    msg.payload='大里區'+msg.AQI+msg.PM25+msg.POL+msg.Status+msg.PublishTime;\n\n    msg.AQI1 =  e['aqi'] ;\n    msg.POL1 =  e['pollutant'] ;\n    msg.PM251 = e['pm2.5'] ;\n    msg.PM25AVG1 = e['pm2.5_avg'] ;\n    msg.Status1 =  e['status'] ;\n    msg.PublishTime1 = e['publishtime'] ;\n   }\n } );\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":450,"y":160,"wires":[["d3e21d7.40a21e","f26b5812.ee3d18","16cd5db5.17a012","83d0f322.82d48","33fc5a97.f9cd36","148f161.fc68fea","2932333a.810e1c","ffb7537c.5fcc","cbd33403.ed5f58"]]},{"id":"d3e21d7.40a21e","type":"debug","z":"a0e05e56b90ecabf","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"PM25","statusVal":"","statusType":"auto","x":760,"y":60,"wires":[]},{"id":"f26b5812.ee3d18","type":"debug","z":"a0e05e56b90ecabf","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"Status","x":760,"y":100,"wires":[]},{"id":"16cd5db5.17a012","type":"debug","z":"a0e05e56b90ecabf","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"PublishTime","x":780,"y":140,"wires":[]},{"id":"83d0f322.82d48","type":"debug","z":"a0e05e56b90ecabf","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"AQI","x":750,"y":180,"wires":[]},{"id":"2d19b1a2.c2283e","type":"comment","z":"a0e05e56b90ecabf","name":"大里區空氣品質狀況","info":"","x":110,"y":100,"wires":[]},{"id":"33fc5a97.f9cd36","type":"mqtt out","z":"a0e05e56b90ecabf","name":"大里AQI","topic":"alex9ufo/Dali/AQI","qos":"1","retain":"true","broker":"40bf4d5e.0395f4","x":560,"y":60,"wires":[]},{"id":"5e616d1c.5f5204","type":"ui_gauge","z":"a0e05e56b90ecabf","name":"","group":"ac7bd49c.51cf38","order":0,"width":"6","height":"3","gtype":"gage","title":"PM2.5 [0..35] 良好","label":"units","format":"{{value}}","min":0,"max":"80","colors":["#00b500","#e6e600","#ca3838"],"seg1":"35","seg2":"53","x":880,"y":240,"wires":[],"inputLabels":["msg.PM25"]},{"id":"fc41b156.17017","type":"ui_text","z":"a0e05e56b90ecabf","group":"ac7bd49c.51cf38","order":0,"width":"6","height":"2","name":"","label":"空氣品質","format":"{{msg.payload}}","layout":"row-spread","x":850,"y":400,"wires":[],"inputLabels":["msg.payload"]},{"id":"148f161.fc68fea","type":"function","z":"a0e05e56b90ecabf","name":"PM2.5 [0..80]","func":"msg.payload=msg.PM251;\nreturn msg;","outputs":1,"noerr":0,"x":700,"y":260,"wires":[["5e616d1c.5f5204","4f0344d6.7bf2dc"]]},{"id":"4f0344d6.7bf2dc","type":"debug","z":"a0e05e56b90ecabf","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":860,"y":280,"wires":[]},{"id":"2932333a.810e1c","type":"function","z":"a0e05e56b90ecabf","name":"AQI [0..400]","func":"msg.payload= msg.AQI1;\nreturn msg;","outputs":1,"noerr":0,"x":700,"y":340,"wires":[["e22444a1.5dda48","9d489604.c1ea28"]]},{"id":"e22444a1.5dda48","type":"ui_gauge","z":"a0e05e56b90ecabf","name":"","group":"ac7bd49c.51cf38","order":0,"width":"6","height":"3","gtype":"gage","title":"AQI [0..50] 良好","label":"units","format":"{{value}}","min":0,"max":"200","colors":["#00b500","#e6e600","#ca3838"],"seg1":"50","seg2":"100","className":"","x":870,"y":320,"wires":[],"inputLabels":["msg.PM25"]},{"id":"ffb7537c.5fcc","type":"function","z":"a0e05e56b90ecabf","name":"Status","func":"msg.payload=msg.Status1;\nreturn msg;","outputs":1,"noerr":0,"x":680,"y":420,"wires":[["fc41b156.17017","33bed4d0.fc4e0c"]]},{"id":"cbd33403.ed5f58","type":"function","z":"a0e05e56b90ecabf","name":"PublishTime","func":"msg.payload=msg.PublishTime1;\nreturn msg;","outputs":1,"noerr":0,"x":700,"y":500,"wires":[["5c529cd1.1170b4","ca7e38c9.45dc98"]]},{"id":"5c529cd1.1170b4","type":"ui_text","z":"a0e05e56b90ecabf","group":"ac7bd49c.51cf38","order":0,"width":"6","height":"3","name":"","label":"發表時間","format":"{{msg.payload}}","layout":"row-spread","x":850,"y":480,"wires":[],"inputLabels":["msg.payload"]},{"id":"9d489604.c1ea28","type":"debug","z":"a0e05e56b90ecabf","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":860,"y":360,"wires":[]},{"id":"33bed4d0.fc4e0c","type":"debug","z":"a0e05e56b90ecabf","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":860,"y":440,"wires":[]},{"id":"ca7e38c9.45dc98","type":"debug","z":"a0e05e56b90ecabf","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":860,"y":520,"wires":[]},{"id":"d51b6fa7448dc94c","type":"debug","z":"a0e05e56b90ecabf","name":"debug 6","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":260,"y":220,"wires":[]},{"id":"8850bfb05c7ca503","type":"function","z":"a0e05e56b90ecabf","name":"function 5","func":"\nflow.set(\"temp\",msg.payload);\nvar rawdata = flow.get(\"temp\");\n\nvar citynumber=rawdata.records.length;\nvar records_array=[];\nvar i;\nfor (i=0; i<citynumber;i++)\n{\n    records_array[i]=rawdata.records[i]\n}\n\nmsg.payload=records_array;\nflow.set(\"RECORDS\",records_array);\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":80,"wires":[["48068d3d.60f764","b398f49598b605af"]]},{"id":"b398f49598b605af","type":"debug","z":"a0e05e56b90ecabf","name":"debug 7","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":380,"y":20,"wires":[]},{"id":"40bf4d5e.0395f4","type":"mqtt-broker","broker":"broker.mqtt-dashboard.com","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":15,"cleansession":true,"birthQos":"0","willQos":"0"},{"id":"ac7bd49c.51cf38","type":"ui_group","name":"大里區空氣品質狀況","tab":"ba052423.3729f8","order":1,"disp":true,"width":"6","collapse":false},{"id":"ba052423.3729f8","type":"ui_tab","name":"AQI","icon":"dashboard","order":1}]

Node-Red 取得台中市天氣(等待約30秒以上)

    Node-Red 取得台中市天氣(等待約30秒以上)


     Stime=rawdata[i].weatherElement[0].time[0].startTime;

        Temp=rawdata[i].weatherElement[0].time[0].elementValue.value;

        Mois=rawdata[i].weatherElement[2].time[2].elementValue.value;

        Weat=rawdata[i].weatherElement[12].time[2].elementValue[0].value;


https://opendata.cwb.gov.tw/fileapi/v1/opendataapi/F-D0047-091?Authorization=CWB-40C25FFF-1224-4250-B9D9-3735AAE17DBF&downloadType=WEB&format=JSON






flow. Set("temp",msg.payload);

var rawdata = flow.get("temp");

 

var citynumber=rawdata.records.length;

var cityarray=[];

var i;

for (i=0; i<citynumber;i++)

{

    cityarray[i]=rawdata.records[i].sitename;

}

 

msg.payload=cityarray;

flow.set("locationname",cityarray);

return msg;

 

 

 

flow.set("temp",msg.payload);

var rawdata = flow.get("temp");

 

var citynumber=rawdata.records.length;

var site_array=[];

var aqi_array=[];

var pm25_array=[];

var i;

for (i=0; i<citynumber;i++)

{

    site_array[i]=rawdata.records[i].sitename;

    aqi_array[i]=rawdata.records[i].aqi;

    pm25_array[i]=rawdata.records[i].pm25subindex;

   

}

 

msg.payload={site_array,aqi_array,pm25_array};

flow.set("Loc",site_array);

flow.set("Aqi",aqi_array);

flow.set("PM25",pm25_array);

return msg;

                         

var a = flow.get("RECORDS");

 

var number=a.length;

var AQI,PM25,SITE;

var i;

 

for (i=0; i<number;i++) {

    if (a[i].sitename=="大里") {

        SITE=a[i].sitename;

        AQI=a[i].aqi;

        PM25=a[i].pm25subindex;

 

    msg.payload={SITE,AQI,PM25};

    return msg;

    }

}

 

 

var a = msg.payload;

var PM252;

 

a.forEach (function(array,i)

{

   if(array.sitename =="大里") {

    PM252 = '   站名 '+ array['sitename'] ;  

    PM252 = ',  日期 '+ array['monitordate'] ;

    PM252 = PM252 + ' ,  AQI=' + array['aqi'] ;

    PM252 = PM252 + ' ,  CO=' + array['cosubindex'] ;

    PM252 = PM252 + ' ,  PM2.5 index=' + array['pm25subindex'] ;

    }

 } );

msg.payload={PM252};

return msg;

 

 

//// array.forEach(function (value,index) {

//// });

 

 

 

flow.set("tempera",msg.payload);

var rawdata = flow.get("tempera");

 

var citynumber=rawdata.cwbopendata.dataset.locations.location.length;

var cityarray=[];

var i;

for (i=0; i<citynumber;i++)

{

    cityarray[i]=rawdata.cwbopendata.dataset.locations.location[i];

}

 

msg.payload=cityarray;

flow.set("loname",cityarray);

return msg;

 

 

//flow.set("loname",cityarray);

 

var rawdata = flow.get("loname");

 

var citynumber=rawdata.length;

var i;

var Stime;

var Temp;

var Mois;

var Weat;

var dataDate;

 

for (i=0; i<citynumber;i++)

{

    if (rawdata[i].locationName==='臺中市')

    {

        Stime=rawdata[i].weatherElement[0].time[0].startTime;

        Temp=rawdata[i].weatherElement[0].time[0].elementValue.value;

        Mois=rawdata[i].weatherElement[2].time[2].elementValue.value;

        Weat=rawdata[i].weatherElement[12].time[2].elementValue[0].value;

        break;

    }

}

 

msg.payload='平均溫度='+Temp+'°C , 平均相對濕度='+Mois+'% , 天氣'+ Weat+ ' , 發佈時間' + Stime;

return msg;

 

 

//flow.set("loname",cityarray);

 

var rawdata = flow.get("loname");

 

var citynumber=rawdata.length;

var i;

var Stime;

var Temp;

var Mois;

var Weat;

var dataDate;

 

for (i=0; i<citynumber;i++)

{

    if (rawdata[i].locationName==='臺中市')

    {

        Stime=rawdata[i].weatherElement[0].time[0].startTime;

        Temp=rawdata[i].weatherElement[0].time[0].elementValue.value;

        Mois=rawdata[i].weatherElement[2].time[2].elementValue.value;

        Weat=rawdata[i].weatherElement[12].time[2].elementValue[0].value;

        break;

    }

}

 

msg.payload= Mois;

return msg;

 

 

//flow.set("loname",cityarray);

 

var rawdata = flow.get("loname");

 

var citynumber=rawdata.length;

var i;

var Stime;

var Temp;

var Mois;

var Weat;

var dataDate;

 

for (i=0; i<citynumber;i++)

{

    if (rawdata[i].locationName==='臺中市')

    {

        Stime=rawdata[i].weatherElement[0].time[0].startTime;

        Temp=rawdata[i].weatherElement[0].time[0].elementValue.value;

        Mois=rawdata[i].weatherElement[2].time[2].elementValue.value;

        Weat=rawdata[i].weatherElement[12].time[2].elementValue[0].value;

        break;

    }

}

 

msg.payload= Temp;

return msg;

 

 


Stime=rawdata[i].weatherElement[0].time[0].startTime;


2022/9/30 下午5:15:01node: d73f973e.ef0298msg.payload : Object

object

cwbopendata: object

@xmlns: "urn:cwb:gov:tw:cwbcommon:0.1"

identifier: "fb364e55-73cf-4c5f-a8a8-f98a25972dbf"

sender: "weather@cwb.gov.tw"

sent: "2022-09-30T16:52:51+08:00"

status: "Actual"

scope: "Public"

msgType: "Issue"

dataid: "D0047-091"

source: "MFC"

dataset: object

datasetInfo: object

locations: object

locationsName: "台灣"

location: array[22]

[0 … 9]

0: object

locationName: "連江縣"

geocode: "09007000"

lat: "26.154204"

lon: "119.929303"

weatherElement: array[15]

[0 … 9]

0: object

elementName: "T"

description: "平均溫度"

time: array[15]

[0 … 9]

0: object

startTime: "2022-09-30T18:00:00+08:00"

endTime: "2022-10-01T06:00:00+08:00"

elementValue: object

1: object

2: object

3: object

4: object

5: object

6: object

7: object

8: object

9: object

[10 … 14]

 

 


flow. Set("temp",msg.payload);

var rawdata = flow.get("temp");

 

var citynumber=rawdata.records.length;

var cityarray=[];

var i;

for (i=0; i<citynumber;i++)

{

    cityarray[i]=rawdata.records[i].sitename;

}

 

msg.payload=cityarray;

flow.set("locationname",cityarray);

return msg;

 

 

 

flow.set("temp",msg.payload);

var rawdata = flow.get("temp");

 

var citynumber=rawdata.records.length;

var site_array=[];

var aqi_array=[];

var pm25_array=[];

var i;

for (i=0; i<citynumber;i++)

{

    site_array[i]=rawdata.records[i].sitename;

    aqi_array[i]=rawdata.records[i].aqi;

    pm25_array[i]=rawdata.records[i].pm25subindex;

   

}

 

msg.payload={site_array,aqi_array,pm25_array};

flow.set("Loc",site_array);

flow.set("Aqi",aqi_array);

flow.set("PM25",pm25_array);

return msg;

                         

var a = flow.get("RECORDS");

 

var number=a.length;

var AQI,PM25,SITE;

var i;

 

for (i=0; i<number;i++) {

    if (a[i].sitename=="大里") {

        SITE=a[i].sitename;

        AQI=a[i].aqi;

        PM25=a[i].pm25subindex;

 

    msg.payload={SITE,AQI,PM25};

    return msg;

    }

}

 

 

var a = msg.payload;

var PM252;

 

a.forEach (function(array,i)

{

   if(array.sitename =="大里") {

    PM252 = '   站名 '+ array['sitename'] ;  

    PM252 = ',  日期 '+ array['monitordate'] ;

    PM252 = PM252 + ' ,  AQI=' + array['aqi'] ;

    PM252 = PM252 + ' ,  CO=' + array['cosubindex'] ;

    PM252 = PM252 + ' ,  PM2.5 index=' + array['pm25subindex'] ;

    }

 } );

msg.payload={PM252};

return msg;

 

 

//// array.forEach(function (value,index) {

//// });

 

 

 

flow.set("tempera",msg.payload);

var rawdata = flow.get("tempera");

 

var citynumber=rawdata.cwbopendata.dataset.locations.location.length;

var cityarray=[];

var i;

for (i=0; i<citynumber;i++)

{

    cityarray[i]=rawdata.cwbopendata.dataset.locations.location[i];

}

 

msg.payload=cityarray;

flow.set("loname",cityarray);

return msg;

 

 

//flow.set("loname",cityarray);

 

var rawdata = flow.get("loname");

 

var citynumber=rawdata.length;

var i;

var Stime;

var Temp;

var Mois;

var Weat;

var dataDate;

 

for (i=0; i<citynumber;i++)

{

    if (rawdata[i].locationName==='臺中市')

    {

        Stime=rawdata[i].weatherElement[0].time[0].startTime;

        Temp=rawdata[i].weatherElement[0].time[0].elementValue.value;

        Mois=rawdata[i].weatherElement[2].time[2].elementValue.value;

        Weat=rawdata[i].weatherElement[12].time[2].elementValue[0].value;

        break;

    }

}

 

msg.payload='平均溫度='+Temp+'°C , 平均相對濕度='+Mois+'% , 天氣'+ Weat+ ' , 發佈時間' + Stime;

return msg;

 

 

//flow.set("loname",cityarray);

 

var rawdata = flow.get("loname");

 

var citynumber=rawdata.length;

var i;

var Stime;

var Temp;

var Mois;

var Weat;

var dataDate;

 

for (i=0; i<citynumber;i++)

{

    if (rawdata[i].locationName==='臺中市')

    {

        Stime=rawdata[i].weatherElement[0].time[0].startTime;

        Temp=rawdata[i].weatherElement[0].time[0].elementValue.value;

        Mois=rawdata[i].weatherElement[2].time[2].elementValue.value;

        Weat=rawdata[i].weatherElement[12].time[2].elementValue[0].value;

        break;

    }

}

 

msg.payload= Mois;

return msg;

 

 

//flow.set("loname",cityarray);

 

var rawdata = flow.get("loname");

 

var citynumber=rawdata.length;

var i;

var Stime;

var Temp;

var Mois;

var Weat;

var dataDate;

 

for (i=0; i<citynumber;i++)

{

    if (rawdata[i].locationName==='臺中市')

    {

        Stime=rawdata[i].weatherElement[0].time[0].startTime;

        Temp=rawdata[i].weatherElement[0].time[0].elementValue.value;

        Mois=rawdata[i].weatherElement[2].time[2].elementValue.value;

        Weat=rawdata[i].weatherElement[12].time[2].elementValue[0].value;

        break;

    }

}

 

msg.payload= Temp;

return msg;

 

 

2022/9/30 下午5:15:01node: d73f973e.ef0298msg.payload : Object

object

cwbopendata: object

@xmlns: "urn:cwb:gov:tw:cwbcommon:0.1"

identifier: "fb364e55-73cf-4c5f-a8a8-f98a25972dbf"

sender: "weather@cwb.gov.tw"

sent: "2022-09-30T16:52:51+08:00"

status: "Actual"

scope: "Public"

msgType: "Issue"

dataid: "D0047-091"

source: "MFC"

dataset: object

datasetInfo: object

locations: object

locationsName: "台灣"

location: array[22]

[0 … 9]

0: object

locationName: "連江縣"

geocode: "09007000"

lat: "26.154204"

lon: "119.929303"

weatherElement: array[15]

[0 … 9]

0: object

elementName: "T"

description: "平均溫度"

time: array[15]

[0 … 9]

0: object

startTime: "2022-09-30T18:00:00+08:00"

endTime: "2022-10-01T06:00:00+08:00"

elementValue: object

1: object

2: object

3: object

4: object

5: object

6: object

7: object

8: object

9: object

[10 … 14]

 

 



 

flow.set("tempera",msg.payload);

var rawdata = flow.get("tempera");

 

var citynumber=rawdata.cwbopendata.dataset.locations.location.length;

var cityarray=[];

var i;

for (i=0; i<citynumber;i++)

{

    cityarray[i]=rawdata.cwbopendata.dataset.locations.location[i];

}

 

msg.payload=cityarray;

flow.set("loname",cityarray);

return msg;





 

//flow.set("loname",cityarray);

 

var rawdata = flow.get("loname");

 

var citynumber=rawdata.length;

var i;

var Stime;

var Temp;

var Mois;

var Weat;

var dataDate;

 

for (i=0; i<citynumber;i++)

{

    if (rawdata[i].locationName==='臺中市')

    {

        Stime=rawdata[i].weatherElement[0].time[0].startTime;

        Temp=rawdata[i].weatherElement[0].time[0].elementValue.value;

        Mois=rawdata[i].weatherElement[2].time[2].elementValue.value;

        Weat=rawdata[i].weatherElement[12].time[2].elementValue[0].value;

        break;

    }

}

 

msg.payload='平均溫度='+Temp+'°C , 平均相對濕度='+Mois+'% , 天氣'+ Weat+ ' , 發佈時間' + Stime;

return msg;

 

//flow.set("loname",cityarray);

 

var rawdata = flow.get("loname");

 

var citynumber=rawdata.length;

var i;

var Stime;

var Temp;

var Mois;

var Weat;

var dataDate;

 

for (i=0; i<citynumber;i++)

{

    if (rawdata[i].locationName==='臺中市')

    {

        Stime=rawdata[i].weatherElement[0].time[0].startTime;

        Temp=rawdata[i].weatherElement[0].time[0].elementValue.value;

        Mois=rawdata[i].weatherElement[2].time[2].elementValue.value;

        Weat=rawdata[i].weatherElement[12].time[2].elementValue[0].value;

        break;

    }

}

 

msg.payload= Mois;

return msg;


//flow.set("loname",cityarray);

 

var rawdata = flow.get("loname");

 

var citynumber=rawdata.length;

var i;

var Stime;

var Temp;

var Mois;

var Weat;

var dataDate;

 

for (i=0; i<citynumber;i++)

{

    if (rawdata[i].locationName==='臺中市')

    {

        Stime=rawdata[i].weatherElement[0].time[0].startTime;

        Temp=rawdata[i].weatherElement[0].time[0].elementValue.value;

        Mois=rawdata[i].weatherElement[2].time[2].elementValue.value;

        Weat=rawdata[i].weatherElement[12].time[2].elementValue[0].value;

        break;

    }

}

 

msg.payload= Temp;

return msg;

113 學年度第 1 學期 RFID應用課程 Arduino程式

113 學年度第 1 學期 RFID應用課程 Arduino程式 https://www.mediafire.com/file/zr0h0p3iosq12jw/MFRC522+(2).7z/file 內含修改過後的 MFRC522 程式庫 (原程式有錯誤) //定義MFRC522...