Node-RED Pycom Temperature Sensor code Tiny-11
Jump to navigation
Jump to search
Node-RED code
[
{
"id": "4b1f07da97e8502f",
"type": "tab",
"label": "Tiny House 11",
"disabled": false,
"info": "",
"env": []
},
{
"id": "b0b2328cead93466",
"type": "mqtt in",
"z": "4b1f07da97e8502f",
"name": "whi-tinyhouse-11",
"topic": "#",
"qos": "0",
"datatype": "json",
"broker": "303962795dfc4ac1",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 120,
"y": 60,
"wires": [
[
"85d561705a2c933c"
]
]
},
{
"id": "355a35cc0aaa4da7",
"type": "debug",
"z": "4b1f07da97e8502f",
"name": "debug 3",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 680,
"y": 200,
"wires": []
},
{
"id": "a2597fa003f60c85",
"type": "function",
"z": "4b1f07da97e8502f",
"name": "process tiny house 11 data",
"func": "var battery; // battery voltage data\nvar int_humidity; // humidity data from within the sensor housing\nvar ext_temp; // external temperature data\nvar int_temp; // temperature data from within the sensor housing\n\nbattery = msg.payload.uplink_message.decoded_payload.bat;\nint_humidity = msg.payload.uplink_message.decoded_payload.humid;\next_temp = msg.payload.uplink_message.decoded_payload.onewire_temp;\nint_temp = msg.payload.uplink_message.decoded_payload.temp;\n\nmsg.payload = \"bat=\" + String(battery) + \"&\"\n + \"intHumid=\" + String(int_humidity) + \"&\"\n + \"extTemp=\" + String(ext_temp) + \"&\"\n + \"intTemp=\" + String(int_temp) + \"&\"\n + \"date=\" + String(msg.myymd) + \" \" + String(msg.mytimes);\n\nmsg.url = \"https://dweet.io/dweet/for/MPPS-Tiny-House-11-bundoora?\" + msg.payload;\n\n// check dweet with - https://dweet.io/get/latest/dweet/for/<My_Dweet_address>\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 540,
"y": 120,
"wires": [
[
"703d7f73d330c794"
]
]
},
{
"id": "85d561705a2c933c",
"type": "simpletime",
"z": "4b1f07da97e8502f",
"name": "",
"mydate": true,
"myymd": true,
"myyear": true,
"mymonth": true,
"mymonthn": true,
"mydom": true,
"mydoy": true,
"myday": true,
"myhourpm": true,
"myhour": true,
"mytime": true,
"mytimes": true,
"myminute": true,
"myminutes": true,
"mysecond": true,
"mymillis": true,
"myepoch": true,
"myrawdate": true,
"mypm": true,
"x": 310,
"y": 60,
"wires": [
[
"a2597fa003f60c85",
"08c2e92b93331f65"
]
]
},
{
"id": "08c2e92b93331f65",
"type": "debug",
"z": "4b1f07da97e8502f",
"name": "debug 4",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 500,
"y": 60,
"wires": []
},
{
"id": "703d7f73d330c794",
"type": "http request",
"z": "4b1f07da97e8502f",
"name": "dweet tiny house 11 data",
"method": "POST",
"ret": "obj",
"paytoqs": "body",
"url": "",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 430,
"y": 200,
"wires": [
[
"355a35cc0aaa4da7"
]
]
},
{
"id": "303962795dfc4ac1",
"type": "mqtt-broker",
"name": "whi-tinyhouse-11",
"broker": "au1.cloud.thethings.network",
"port": "1883",
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willPayload": "",
"willMsg": {},
"userProps": "",
"sessionExpiry": ""
}
]