Lab 4: Working with multiple IoT devices PLUS Mobile Push Notification
ในการทดลองนี้ จะเป็นการต่อเติมจากการทดลองที่แล้ว คือการเพิ่ม Push Notification ไปยัง NETPIE Mobile Application หาโหลดมาใช้งานได้ทั้ง
iPod Touch/iPhone/iPad (iOS) : https://itunes.apple.com/tt/app/netpie/id1356483168?mt=8
Android (Require Version 4.1 At Least) :
https://play.google.com/store/apps/details?id=io.netpie.NETPIE&hl=en
[{"id":"1e1f868a.217409","type":"microgear","z":"e17f78c2.122d58","name":"LM35 Temp Sensor","appid":"","key":"","secret":"","alias":"","topics":"/#","active":true,"retain":"false","retainType":"bool","x":210,"y":460,"wires":[["c4144e81.ff8d5"]]},{"id":"c4144e81.ff8d5","type":"switch","z":"e17f78c2.122d58","name":"Check Temperature","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"30","vt":"num"},{"t":"lt","v":"22","vt":"str"}],"checkall":"true","outputs":2,"x":430,"y":460,"wires":[["b545b5a1.0ddd68"],["716703da.beb37c"]]},{"id":"7d4ef313.9694cc","type":"microgear","z":"e17f78c2.122d58","name":"Air Con Switch","appid":"","key":"","secret":"","alias":"","topics":"/#","active":true,"retain":"false","retainType":"bool","x":840,"y":500,"wires":[[]]},{"id":"b545b5a1.0ddd68","type":"change","z":"e17f78c2.122d58","name":"Turn ON","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":420,"wires":[["7d4ef313.9694cc","899948f1.370ac8"]]},{"id":"716703da.beb37c","type":"change","z":"e17f78c2.122d58","name":"Turn OFF","rules":[{"t":"set","p":"payload","pt":"msg","to":"2","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":500,"wires":[["7d4ef313.9694cc","899948f1.370ac8"]]},{"id":"d1ef9f35.a9a0d","type":"push","z":"e17f78c2.122d58","name":"Mobile Notify","auth":"","target":"","targetType":"1","title":"Smart Air Condition","titleType":"str","body":"payload","bodyType":"msg","appGroup":"","mobileAppKey":"","mobileAppTopic":"","sound":"default","x":830,"y":360,"wires":[]},{"id":"899948f1.370ac8","type":"change","z":"e17f78c2.122d58","name":"Message Handler","rules":[{"t":"change","p":"payload","pt":"msg","from":"1","fromt":"num","to":"Air Conditioner : ON","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"0","fromt":"num","to":"Air Conditioner : OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":850,"y":420,"wires":[["d1ef9f35.a9a0d"]]}]
Exported Flow
รูปภาพที่ 59 แสดง Exported Flow Lab 4
รูปภาพที่ 60 ภาพขยายของโหนดด้านหลัง
เพื่อที่จะส่งข้อความเข้า Application จึงจำเป็นต้องแปลงข้อความอีกครั้ง โดยใช้โหนด Switch (ตอนนี้ตั้งชื่อว่า Message Handler) เพื่อแปลงจากสัญญาณ 1 = เปิด, 0 = ปิด ให้เป็นข้อความที่เข้าใจได้ง่าย จากนั้นส่งไปที่โหนด Push ซึ่งอยู่ในกลุ่มของ NETPIE ในหน้าแถบด้านซ้าย
รูปภาพที่ 61 แสดงตำแหน่งของโหนด Push
โดยการตั้งค่าของทั้งสองโหนด เป็นไปดังต่อไปนี้
รูปภาพที่ 62 แสดงการตั้งค่าของโหนด Mobile Notify และ Message Handler