This flow executes a script included on a Turck IM18-CCM50. The script is called ambient_read.sh
and outputs the value of the onboard temperature and humidity sensor of the Turck IM18-CCM50 module. This flow executes the script every 30 seconds (this can be changed after importing) and converts the output of the script to a JSON object.
-
-
Save SankariNL/64631bb920110a0fb6db3e0c8c765735 to your computer and use it in GitHub Desktop.
Turck IM18-CCM50 Ambient_read
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id": "fd1a48acaded6406", | |
"type": "tab", | |
"label": "Ambient_read", | |
"disabled": false, | |
"info": "" | |
}, | |
{ | |
"id": "b6f1da912eaa655f", | |
"type": "function", | |
"z": "fd1a48acaded6406", | |
"name": "", | |
"func": "var payload = msg.payload;\npayload = payload.trimEnd();\nvar array = payload.split(/\\r?\\n/, 2);\narray[0] = array[0].replace(\"ambient: HUM, \", \"\");\narray[0] = array[0].replace(\" RH\", \"\");\narray[1] = array[1].replace(\"ambient: TEMP, \", \"\");\narray[1] = array[1].replace(\" dC\", \"\");\ndelete msg.payload;\nmsg.payload = {};\n// Use parseFloat to convert string to float\nmsg.payload.humidity = parseFloat(array[0]);\nmsg.payload.temperature = parseFloat(array[1]);\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"initialize": "", | |
"finalize": "", | |
"libs": [], | |
"x": 780, | |
"y": 200, | |
"wires": [ | |
[ | |
"36fa675aa9e17538" | |
] | |
] | |
}, | |
{ | |
"id": "36fa675aa9e17538", | |
"type": "debug", | |
"z": "fd1a48acaded6406", | |
"name": "", | |
"active": true, | |
"tosidebar": true, | |
"console": false, | |
"tostatus": false, | |
"complete": "payload", | |
"targetType": "msg", | |
"statusVal": "", | |
"statusType": "auto", | |
"x": 970, | |
"y": 200, | |
"wires": [] | |
}, | |
{ | |
"id": "9553be600dcda066", | |
"type": "exec", | |
"z": "fd1a48acaded6406", | |
"command": "/home/scripts/ambient_read.sh", | |
"addpay": "", | |
"append": "all", | |
"useSpawn": "false", | |
"timer": "", | |
"winHide": false, | |
"oldrc": false, | |
"name": "", | |
"x": 530, | |
"y": 200, | |
"wires": [ | |
[ | |
"b6f1da912eaa655f" | |
], | |
[], | |
[] | |
] | |
}, | |
{ | |
"id": "91f0d40878536a65", | |
"type": "inject", | |
"z": "fd1a48acaded6406", | |
"name": "", | |
"props": [ | |
{ | |
"p": "timestamp", | |
"v": "", | |
"vt": "date" | |
} | |
], | |
"repeat": "30", | |
"crontab": "", | |
"once": false, | |
"onceDelay": 0.1, | |
"topic": "", | |
"x": 240, | |
"y": 200, | |
"wires": [ | |
[ | |
"9553be600dcda066" | |
] | |
] | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment