Turck IM18-CCM50 Ambient_read

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.

Ambient_read flow

[{"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"]]}]

Flow Info

Created 2 years, 10 months ago
Rating: 5 2

Owner

Actions

Rate:

Node Types

Core
  • debug (x1)
  • exec (x1)
  • function (x1)
  • inject (x1)
Other
  • tab (x1)

Tags

  • Turck
  • IM18-CCM50
  • CCM50
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option