IOT Based Remote Control Interface for Vehicle Tele-Operation

This flow is the second half of the Overall IoT-based Control Infrastructure to enable the Remote Tele-Operation of a Vehicle. The json flow hosted on a RaspberryPi (RPi) receives using an MQTT input node, the control data sent from the Operator Control Platform over an MQTT server hosted on AWS IoT thing. The flow then converts the data through the RPi GPIO into digital command signals for an Arduino Due Microcontroller to receive and process in order to generate the control signals necessary to control the operation of the vehicle such as its movement and robot arms (Manipulators) through its internal subsystems. The flow utilizes standard node-red nodes available on installation.

[{"id":"5b57b905.98d218","type":"tab","label":"Flow 2"},{"id":"bff45647.2b9788","type":"subflow","name":"Loop","info":"","in":[{"x":64,"y":114,"wires":[{"id":"ce0cbf0e.ff7fb"}]}],"out":[{"x":557,"y":176,"wires":[{"id":"e63f9.f5c76c07","port":0}]}]},{"id":"cc80483d.9c98c8","type":"mqtt-broker","z":"","broker":"a16ck7fy1v223m.iot.eu-west-1.amazonaws.com/things/TSRV/shadow","port":"8883","tls":"a88a8731.90b978","clientid":"Pi","usetls":true,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""},{"id":"a88a8731.90b978","type":"tls-config","z":"","name":"AWS","cert":"/home/pi/pi_socket/TSRV.cert.pem","key":"/home/pi/pi_socket/TSRV.private.key","ca":"/home/pi/pi_socket/root.CA.pem","verifyservercert":true},{"id":"eee6a834.377588","type":"ui_tab","z":"","name":"Home","icon":"dashboard"},{"id":"8e43c46c.dd91a8","type":"ui_base","name":"Node-RED Dashboard","theme":"theme-dark"},{"id":"59bbfac4.6a0d64","type":"mqtt in","z":"5b57b905.98d218","name":"Direction","topic":"/Direction","qos":"1","broker":"cc80483d.9c98c8","x":294,"y":93,"wires":[["cf5a20a4.9c88a"]]},{"id":"13a40489.2e305b","type":"mqtt in","z":"5b57b905.98d218","name":"Up/Down","topic":"/UD","qos":"1","broker":"cc80483d.9c98c8","x":746.47607421875,"y":109.7139892578125,"wires":[["70701b78.fb3794"]]},{"id":"6e96c6c6.65a018","type":"mqtt in","z":"5b57b905.98d218","name":"Clutch","topic":"/Clutch","qos":"1","broker":"cc80483d.9c98c8","x":284.3810119628906,"y":259.9930114746094,"wires":[["f4ab2922.5e9288"]]},{"id":"69afda15.899ea4","type":"mqtt in","z":"5b57b905.98d218","name":"Start","topic":"/Start","qos":"1","broker":"cc80483d.9c98c8","x":282.3330078125,"y":310,"wires":[["de51719.d5b1d9"]]},{"id":"49cd939d.610a3c","type":"mqtt in","z":"5b57b905.98d218","name":"Gear","topic":"/Gear","qos":"1","broker":"cc80483d.9c98c8","x":288,"y":186,"wires":[["48caa93b.78f838"]]},{"id":"e781ee1.19d481","type":"mqtt in","z":"5b57b905.98d218","name":"Right/Left","topic":"/RL","qos":"1","broker":"cc80483d.9c98c8","x":763,"y":215,"wires":[["8bb1a70a.7519b8"]]},{"id":"5f4f64b9.4cec0c","type":"rpi-gpio out","z":"5b57b905.98d218","name":"","pin":"7","set":"","level":"0","out":"out","x":628,"y":100,"wires":[]},{"id":"a77a614e.7a09b","type":"rpi-gpio out","z":"5b57b905.98d218","name":"","pin":"37","set":false,"level":"1","out":"out","x":646,"y":177,"wires":[]},{"id":"ca417108.abd35","type":"rpi-gpio out","z":"5b57b905.98d218","name":"","pin":"11","set":"","level":"0","out":"out","x":627,"y":240,"wires":[]},{"id":"6f90376a.bbf5c8","type":"rpi-gpio out","z":"5b57b905.98d218","name":"","pin":"13","set":"","level":"0","out":"out","x":592.802001953125,"y":347.47003173828125,"wires":[]},{"id":"153ef36d.74bbdd","type":"rpi-gpio out","z":"5b57b905.98d218","name":"","pin":"15","set":"","level":"0","out":"out","x":985,"y":87,"wires":[]},{"id":"f0fd3e99.9e183","type":"rpi-gpio out","z":"5b57b905.98d218","name":"","pin":"18","set":"","level":"0","out":"out","x":995,"y":181,"wires":[]},{"id":"3a2846bf.9baaca","type":"rpi-gpio out","z":"5b57b905.98d218","name":"","pin":"22","set":"","level":"0","out":"out","x":991,"y":241,"wires":[]},{"id":"d8edf120.a6bec","type":"function","z":"5b57b905.98d218","name":"Direction GPIO Cntrl","func":"if (msg.payload == '1') \n        {msg.payload = 0;}\nelse if(msg.payload == '8')\n        {msg.payload = 1;}\nreturn msg;","outputs":1,"noerr":0,"x":467,"y":134,"wires":[["5f4f64b9.4cec0c"]]},{"id":"ce09b54.33a0e48","type":"function","z":"5b57b905.98d218","name":"Gear GPIO Cntrl","func":"if (msg.payload == '2') \n        {msg.payload = 0;}\nelse if(msg.payload == '4')\n        {msg.payload = 1;}\nreturn msg;","outputs":1,"noerr":0,"x":456,"y":223,"wires":[["a77a614e.7a09b"]]},{"id":"70701b78.fb3794","type":"function","z":"5b57b905.98d218","name":"Up","func":"var on = 1;\nvar off = 0;\n\nif (msg.payload == \"4\")\n    {var msg1 = {payload: on};\n     var msg2 = {payload: off};}\nelse if(msg.payload == \"20\")\n        {var msg1 = {payload: off};\n         var msg2 = {payload: on};}\nelse{var msg1 = {payload: off};\n     var msg2 = {payload: off};}\nreturn [msg1,msg2];","outputs":"2","noerr":0,"x":859,"y":107,"wires":[["153ef36d.74bbdd"],["2f0e0cd4.67c564"]]},{"id":"f4ab2922.5e9288","type":"function","z":"5b57b905.98d218","name":"Clutch","func":"var on = 1;\nvar off = 0;\n\nif (msg.payload == \"32\")\n    {var msg1 = {payload: on};\n     var msg2 = {payload: off};}\nelse if(msg.payload == \"48\")\n        {var msg1 = {payload: off};\n         var msg2 = {payload: on};}\nelse{var msg1 = {payload: off};\n     var msg2 = {payload: off};}\nreturn [msg1,msg2];","outputs":"2","noerr":0,"x":425,"y":262,"wires":[["ca417108.abd35"],["5852c208.50a23c"]]},{"id":"de51719.d5b1d9","type":"function","z":"5b57b905.98d218","name":"Start GPIO Cntrl","func":"var on = 1;\nvar off = 0;\n\nif (msg.payload == '128') \n{\n    var msg = {payload: on};\n}\nelse if(msg.payload == '64')\n{\n    var msg = {payload: off};\n}\nreturn msg;","outputs":1,"noerr":0,"x":416,"y":309,"wires":[["6f90376a.bbf5c8"]]},{"id":"8bb1a70a.7519b8","type":"function","z":"5b57b905.98d218","name":"Right","func":"var on = 1;\nvar off = 0;\n\nif (msg.payload == \"12\")\n    {var msg1 = {payload: on};\n     var msg2 = {payload: off};}\nelse if(msg.payload == \"28\")\n        {var msg1 = {payload: off};\n         var msg2 = {payload: on};}\nelse{var msg1 = {payload: off};\n     var msg2 = {payload: off};}\nreturn [msg1,msg2];","outputs":"2","noerr":0,"x":872,"y":216,"wires":[["f0fd3e99.9e183"],["3a2846bf.9baaca"]]},{"id":"2f0e0cd4.67c564","type":"rpi-gpio out","z":"5b57b905.98d218","name":"","pin":"16","set":"","level":"0","out":"out","x":985,"y":134,"wires":[]},{"id":"ed578671.01eaa8","type":"mqtt in","z":"5b57b905.98d218","name":"Lift ","topic":"/Lift","qos":"1","broker":"cc80483d.9c98c8","x":758,"y":300,"wires":[["4b0fa6ea.b61e18"]]},{"id":"4b0fa6ea.b61e18","type":"function","z":"5b57b905.98d218","name":"Lift","func":"var on = 1;\nvar off = 0;\n\nif (msg.payload == \"24\")\n    {var msg1 = {payload: on};\n     var msg2 = {payload: off};}\nelse if(msg.payload == \"17\")\n        {var msg1 = {payload: off};\n         var msg2 = {payload: on};}\nelse{var msg1 = {payload: off};\n     var msg2 = {payload: off};}\nreturn [msg1,msg2];","outputs":"2","noerr":0,"x":857,"y":301,"wires":[["16f57bba.14c584"],["7c3e4a6a.e5f934"]]},{"id":"16f57bba.14c584","type":"rpi-gpio out","z":"5b57b905.98d218","name":"","pin":"31","set":true,"level":"0","out":"out","x":990,"y":292,"wires":[]},{"id":"7c3e4a6a.e5f934","type":"rpi-gpio out","z":"5b57b905.98d218","name":"","pin":"32","set":true,"level":"0","out":"out","x":988,"y":342,"wires":[]},{"id":"89dff1b2.6ab6d","type":"mqtt in","z":"5b57b905.98d218","name":"Pinch/Release","topic":"/PR","qos":"1","broker":"cc80483d.9c98c8","x":298,"y":474,"wires":[["ec6019ba.9100b8"]]},{"id":"ec6019ba.9100b8","type":"function","z":"5b57b905.98d218","name":"PR","func":"var on = 1;\nvar off = 0;\n\nif (msg.payload == \"20\")\n    {var msg1 = {payload: on};\n     var msg2 = {payload: off};}\nelse if(msg.payload == \"18\")\n        {var msg1 = {payload: off};\n         var msg2 = {payload: on};}\nelse{var msg1 = {payload: off};\n     var msg2 = {payload: off};}\nreturn [msg1,msg2];","outputs":"2","noerr":0,"x":429.8089904785156,"y":473.90399169921875,"wires":[["eeaac8a2.7846a8"],["5263bf1e.ffc0d"]]},{"id":"eeaac8a2.7846a8","type":"rpi-gpio out","z":"5b57b905.98d218","name":"","pin":"33","set":true,"level":"0","out":"out","x":565,"y":463,"wires":[]},{"id":"5263bf1e.ffc0d","type":"rpi-gpio out","z":"5b57b905.98d218","name":"","pin":"35","set":true,"level":"0","out":"out","x":563,"y":510,"wires":[]},{"id":"5852c208.50a23c","type":"rpi-gpio out","z":"5b57b905.98d218","name":"","pin":"12","set":true,"level":"0","out":"out","x":622,"y":289,"wires":[]},{"id":"bba7afb2.c1e7a","type":"mqtt in","z":"5b57b905.98d218","name":"Shift","topic":"/Shift","qos":"1","broker":"cc80483d.9c98c8","x":745,"y":391.00006103515625,"wires":[["4582bf47.3408b"]]},{"id":"4582bf47.3408b","type":"function","z":"5b57b905.98d218","name":"Shift Cntrl","func":"var on = 1;\nvar off = 0;\n\nif (msg.payload == '16') \n{\n    var msg = {payload: on};\n}\nelse \n{\n    var msg = {payload: off};\n}\nreturn msg;","outputs":"1","noerr":0,"x":857.6669921875,"y":390.14306640625,"wires":[["487d5180.421c7"]]},{"id":"487d5180.421c7","type":"rpi-gpio out","z":"5b57b905.98d218","name":"","pin":"36","set":true,"level":"0","out":"out","x":977,"y":390.00006103515625,"wires":[]},{"id":"e63f9.f5c76c07","type":"function","z":"bff45647.2b9788","name":"Loop","func":"// The received message is stored in 'msg'\n// It will have at least a 'payload' property:\n// console.log(msg.payload);\n// The 'context' object is available to store state\n// between invocations of the function\n// context = {};\nconsole.log('Entering loop');\nconsole.log(msg.loop);\n\nif (msg.loop == 'off' ) {\n\treturn [msg,null];\n} else {\n\tconsole.log('Looping');\n\treturn [msg,msg];\n}","outputs":"2","noerr":0,"x":339,"y":244,"wires":[[],["ce0cbf0e.ff7fb"]]},{"id":"b0cefe07.21a9b","type":"delay","z":"bff45647.2b9788","name":"Delay it","pauseType":"queue","timeout":"2","timeoutUnits":"seconds","rate":"2","nbRateUnits":"","rateUnits":"second","randomFirst":"","randomLast":"","randomUnits":"seconds","drop":true,"x":419,"y":114,"wires":[["e63f9.f5c76c07"]]},{"id":"ce0cbf0e.ff7fb","type":"function","z":"bff45647.2b9788","name":"Control Loop","func":"// The received message is stored in 'msg'\n// It will have at least a 'payload' property:\n//   console.log(msg.payload);\n// The 'context' object is available to store state\n// between invocations of the function\n//   context = {};\n\nmsg.loop = 'on';\n\nreturn msg;","outputs":1,"noerr":0,"x":288,"y":115,"wires":[["b0cefe07.21a9b"]]},{"id":"cf5a20a4.9c88a","type":"subflow:bff45647.2b9788","z":"5b57b905.98d218","x":452,"y":94,"wires":[["d8edf120.a6bec"]]},{"id":"bb1b88b6.c283d8","type":"mqtt in","z":"5b57b905.98d218","name":"Kill","topic":"/Kill","qos":"1","broker":"cc80483d.9c98c8","x":709,"y":466,"wires":[["407296a0.a40618"]]},{"id":"407296a0.a40618","type":"function","z":"5b57b905.98d218","name":"Kill GPIO Cntrl","func":"var on = 1;\nvar off = 0;\n\nif (msg.payload == '128') \n{\n    var msg = {payload: off};\n}\nelse if(msg.payload == '64')\n{\n    var msg = {payload: on};\n}\nreturn msg;","outputs":1,"noerr":0,"x":840.093505859375,"y":465.80853271484375,"wires":[["ab989db5.d7d6c"]]},{"id":"ab989db5.d7d6c","type":"rpi-gpio out","z":"5b57b905.98d218","name":"","pin":"38","set":"","level":"0","out":"out","x":979.154296875,"y":464.37615966796875,"wires":[]},{"id":"48caa93b.78f838","type":"subflow:bff45647.2b9788","z":"5b57b905.98d218","x":425,"y":179,"wires":[["ce09b54.33a0e48"]]},{"id":"e1436084.482bb","type":"rpi-gpio in","z":"5b57b905.98d218","name":"","pin":"29","intype":"in","debounce":"25","read":false,"x":270,"y":371,"wires":[["ea79326.1dce9d"]]},{"id":"ea79326.1dce9d","type":"function","z":"5b57b905.98d218","name":"Tipping","func":"var on = 1;\nvar off = 0;\n\nif (msg.payload == on) \n{\n    var msg = {payload: 'Tipping'};\n}\nelse \n{\n    var msg = {payload: 'Strong and Stable'};\n}\nreturn msg;","outputs":"1","noerr":0,"x":330,"y":411,"wires":[["80b40931.e6f258"]]},{"id":"80b40931.e6f258","type":"mqtt out","z":"5b57b905.98d218","name":"Tipping","topic":"/Tipping","qos":"0","retain":"","broker":"cc80483d.9c98c8","x":468,"y":377,"wires":[]},{"id":"a51ff9fd.9df748","type":"is online","z":"5b57b905.98d218","name":"Signal Status","url":"","action":"0","x":795.5,"y":508,"wires":[["69ea6984.15eea8"]]},{"id":"940ff087.68721","type":"inject","z":"5b57b905.98d218","name":"","topic":"","payload":"1","payloadType":"num","repeat":"0.5","crontab":"","once":false,"x":705,"y":546,"wires":[["a51ff9fd.9df748"]]},{"id":"69ea6984.15eea8","type":"function","z":"5b57b905.98d218","name":"Kill_Eng","func":"if (msg.payload.toString()==\"true\")\n    {var msg = {payload: 0};}\nelse {var msg = {payload: 1};}\nreturn msg;","outputs":1,"noerr":0,"x":883,"y":547,"wires":[["aa276a54.bc15c8","ab989db5.d7d6c"]]},{"id":"aa276a54.bc15c8","type":"mqtt out","z":"5b57b905.98d218","name":"Signal","topic":"/Signal","qos":"0","retain":"","broker":"cc80483d.9c98c8","x":1000,"y":510,"wires":[]}]
hafizalk

Flow Info

created 2 months, 2 weeks ago

Node Types

Core
  • delay (x1)
  • function (x14)
  • inject (x1)
  • mqtt in (x10)
  • mqtt out (x2)
  • mqtt-broker (x1)
  • rpi-gpio in (x1)
  • rpi-gpio out (x15)
Other
  • is online (x1)
  • subflow (x1)
  • subflow:bff45647.2b9788 (x2)
  • tab (x1)
  • tls-config (x1)
  • ui_base (x1)
  • ui_tab (x1)

Tags

  • AWS
  • IoT
  • MQTT
  • TeleOperation
  • RaspberryPi
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option