RPi Node-Red – Remote Control Car with video stream

This is a basic first draft: car kit in beta

The wiring diagram is here:

 

Wiring Diagram of Car

The default flow is below – do not import this flow if you already have a flow in your raspberry pi node-red

[{"id":"c3004570.c5fdb8","type":"tab","label":"Movement","disabled":false,"info":""},{"id":"b3ddf90e.a09218","type":"tab","label":"Video","disabled":false,"info":""},{"id":"45012f78.86c5d","type":"tab","label":"Settings","disabled":false,"info":""},{"id":"1bd47399.a5c5dc","type":"tab","label":"Extras","disabled":true,"info":""},{"id":"c892232.a6b64e","type":"ui_group","z":"","name":"Controls","tab":"f12bfb77.9e80e8","order":2,"disp":false,"width":"8","collapse":false},{"id":"408f9230.25cedc","type":"ui_group","z":"","name":"Camera","tab":"f12bfb77.9e80e8","order":1,"disp":false,"width":"11","collapse":false},{"id":"f12bfb77.9e80e8","type":"ui_tab","z":"","name":"Home","icon":"dashboard","order":1},{"id":"c22338ce.f469a8","type":"ui_base","theme":{"name":"theme-dark","lightTheme":{"default":"#0094CE","baseColor":"#0094CE","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"darkTheme":{"default":"#097479","baseColor":"#0e777c","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"customTheme":{"name":"Untitled Theme 1","default":"#4B7930","baseColor":"#4B7930","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"},"themeState":{"base-color":{"default":"#097479","value":"#0e777c","edited":true},"page-titlebar-backgroundColor":{"value":"#0e777c","edited":false},"page-backgroundColor":{"value":"#111111","edited":false},"page-sidebar-backgroundColor":{"value":"#000000","edited":false},"group-textColor":{"value":"#16b9c1","edited":false},"group-borderColor":{"value":"#555555","edited":false},"group-backgroundColor":{"value":"#333333","edited":false},"widget-textColor":{"value":"#eeeeee","edited":false},"widget-backgroundColor":{"value":"#0e777c","edited":false},"widget-borderColor":{"value":"#333333","edited":false},"base-font":{"value":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"}},"angularTheme":{"primary":"indigo","accents":"blue","warn":"red","background":"grey"}},"site":{"name":"Node-RED Dashboard","hideToolbar":"false","allowSwipe":"false","lockMenu":"false","allowTempTheme":"true","dateFormat":"DD/MM/YYYY","sizes":{"sx":48,"sy":48,"gx":6,"gy":6,"cx":6,"cy":6,"px":0,"py":0}}},{"id":"5d86451c.b71dec","type":"ui_tab","z":"","name":"Settings","icon":"dashboard","order":2},{"id":"ae7bc233.3c456","type":"ui_group","z":"","name":"Settings / Shutdown","tab":"5d86451c.b71dec","order":1,"disp":true,"width":"6","collapse":false},{"id":"5665ef6d.468c7","type":"PCA9685","z":"","deviceNumber":"1","address":"64","frequency":"50"},{"id":"b4d77b75.1806f8","type":"oled-config","z":"","name":"","width":"128","height":"64","address":"60"},{"id":"15e30af6.f028d5","type":"oled-config","z":"","name":"","width":"128","height":"64","address":"3c"},{"id":"69b618c6.62b938","type":"exec","z":"c3004570.c5fdb8","command":"sudo python /home/pi/Downloads/Raspi_Car/fwd.py","addpay":false,"append":"","useSpawn":"true","timer":"4","oldrc":false,"name":"","x":570,"y":60,"wires":[[],[],[]]},{"id":"5642fa90.d3aa54","type":"exec","z":"c3004570.c5fdb8","command":"sudo python /home/pi/Downloads/Raspi_Car/bwd.py","addpay":false,"append":"","useSpawn":"true","timer":"4","oldrc":false,"name":"","x":580,"y":140,"wires":[[],[],[]]},{"id":"1cc3c9fb.0cd206","type":"exec","z":"c3004570.c5fdb8","command":"sudo python /home/pi/Downloads/Raspi_Car/turn_r.py","addpay":false,"append":"","useSpawn":"true","timer":"4","oldrc":false,"name":"","x":580,"y":300,"wires":[[],[],[]]},{"id":"826cb173.39cc1","type":"exec","z":"c3004570.c5fdb8","command":"sudo python /home/pi/Downloads/Raspi_Car/turn_l.py","addpay":false,"append":"","useSpawn":"true","timer":"4","oldrc":false,"name":"","x":580,"y":220,"wires":[[],[],[]]},{"id":"3d71630b.6baaec","type":"ui_button","z":"c3004570.c5fdb8","name":"","group":"c892232.a6b64e","order":1,"width":0,"height":0,"passthru":true,"label":"FWD","color":"","bgcolor":"","icon":"","payload":"1","payloadType":"str","topic":"","x":270,"y":60,"wires":[["69b618c6.62b938","2bd73342.45bcac"]]},{"id":"7403b905.981538","type":"ui_button","z":"c3004570.c5fdb8","name":"","group":"c892232.a6b64e","order":4,"width":0,"height":0,"passthru":true,"label":"BACK","color":"","bgcolor":"","icon":"","payload":"1","payloadType":"str","topic":"","x":270,"y":140,"wires":[["5642fa90.d3aa54","2bd73342.45bcac"]]},{"id":"670ea129.3442c","type":"ui_button","z":"c3004570.c5fdb8","name":"","group":"c892232.a6b64e","order":3,"width":"4","height":"1","passthru":true,"label":"RIGHT","color":"","bgcolor":"","icon":"","payload":"1","payloadType":"str","topic":"","x":280,"y":300,"wires":[["2bd73342.45bcac","826cb173.39cc1"]]},{"id":"df8ab935.62a7b8","type":"ui_button","z":"c3004570.c5fdb8","name":"","group":"c892232.a6b64e","order":2,"width":"4","height":"1","passthru":true,"label":"LEFT","color":"","bgcolor":"","icon":"","payload":"1","payloadType":"str","topic":"","x":270,"y":220,"wires":[["1cc3c9fb.0cd206","2bd73342.45bcac"]]},{"id":"d82c04e8.1aea98","type":"inject","z":"c3004570.c5fdb8","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":60,"wires":[["3d71630b.6baaec"]]},{"id":"d586c6c3.3b7308","type":"inject","z":"c3004570.c5fdb8","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":140,"wires":[["7403b905.981538"]]},{"id":"1194b926.7fb467","type":"inject","z":"c3004570.c5fdb8","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":300,"wires":[["670ea129.3442c"]]},{"id":"a4917833.2d9588","type":"inject","z":"c3004570.c5fdb8","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":220,"wires":[["df8ab935.62a7b8"]]},{"id":"c326f349.dc3c2","type":"exec","z":"45012f78.86c5d","command":"sudo shutdown now","addpay":false,"append":"","useSpawn":"true","timer":"4","oldrc":false,"name":"","x":500,"y":80,"wires":[[],[],[]]},{"id":"5508c561.de945c","type":"ui_button","z":"45012f78.86c5d","name":"","group":"ae7bc233.3c456","order":6,"width":0,"height":0,"passthru":true,"label":"Shutdown Pi","color":"","bgcolor":"","icon":"","payload":"1","payloadType":"str","topic":"","x":290,"y":80,"wires":[["c326f349.dc3c2"]]},{"id":"82bc1029.a21df","type":"inject","z":"45012f78.86c5d","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":80,"wires":[["5508c561.de945c"]]},{"id":"9b0bcd2e.6b34","type":"ui_button","z":"1bd47399.a5c5dc","name":"","group":"c892232.a6b64e","order":5,"width":0,"height":0,"passthru":true,"label":"Servo","color":"","bgcolor":"","icon":"","payload":"90","payloadType":"num","topic":"","x":270,"y":80,"wires":[["deb27663.5e02e8"]]},{"id":"f5eadb34.69d8c8","type":"inject","z":"1bd47399.a5c5dc","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":80,"wires":[["9b0bcd2e.6b34"]]},{"id":"9efa51e0.97e71","type":"ui_button","z":"1bd47399.a5c5dc","name":"","group":"c892232.a6b64e","order":6,"width":0,"height":0,"passthru":true,"label":"Servo","color":"","bgcolor":"","icon":"","payload":"180","payloadType":"num","topic":"","x":270,"y":120,"wires":[["deb27663.5e02e8"]]},{"id":"b207ac1.566af5","type":"inject","z":"1bd47399.a5c5dc","name":"","topic":"","payload":"180","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":120,"wires":[["9efa51e0.97e71"]]},{"id":"deb27663.5e02e8","type":"exec","z":"1bd47399.a5c5dc","command":"sudo python /home/pi/Downloads/Raspi_Car/servoArg.py","addpay":true,"append":"","useSpawn":"true","timer":"4","oldrc":false,"name":"","x":610,"y":100,"wires":[["959c728f.b1179"],["959c728f.b1179"],["959c728f.b1179"]]},{"id":"959c728f.b1179","type":"debug","z":"1bd47399.a5c5dc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":730,"y":160,"wires":[]},{"id":"8571640e.026f48","type":"ui_slider","z":"1bd47399.a5c5dc","name":"","label":"slider","group":"c892232.a6b64e","order":7,"width":0,"height":0,"passthru":true,"outs":"all","topic":"","min":0,"max":"180","step":1,"x":270,"y":160,"wires":[["deb27663.5e02e8"]]},{"id":"2bd73342.45bcac","type":"timeout","z":"c3004570.c5fdb8","name":"My Timeout","outtopic":"","outsafe":"","outwarning":"","outunsafe":"Unsafe","warning":"5","timer":"20","repeat":false,"again":true,"x":250,"y":460,"wires":[["b454a19d.728fc","85eaa486.d76538"]]},{"id":"b454a19d.728fc","type":"debug","z":"c3004570.c5fdb8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":430,"y":520,"wires":[]},{"id":"85eaa486.d76538","type":"exec","z":"c3004570.c5fdb8","command":"sudo python /home/pi/Downloads/Raspi_Car/twitch.py","addpay":false,"append":"","useSpawn":"true","timer":"4","oldrc":false,"name":"","x":560,"y":460,"wires":[[],[],[]]},{"id":"7984811f.1205d","type":"inject","z":"45012f78.86c5d","name":"","topic":"","payload":"Hello!","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":470,"y":320,"wires":[["e4dcbd0.d86264"]]},{"id":"e4dcbd0.d86264","type":"String","z":"45012f78.86c5d","name":"OLED","display":"15e30af6.f028d5","x":670,"y":280,"wires":[]},{"id":"8554d33e.6eead","type":"function","z":"45012f78.86c5d","name":"Format Message","func":"if (msg.payload.length >4) \n{\n    msg.payload={\n    x:1,  \n    y:50,\n    text:\"IP \"+msg.payload+\":1880\"\n    }\n}\nelse\n{\n    msg.payload={\n    x:1,  \n    y:50,\n    text:\"No IP Address           \"\n    }\n}\nreturn msg;","outputs":1,"noerr":0,"x":520,"y":280,"wires":[["e4dcbd0.d86264"]]},{"id":"f731709.c52189","type":"change","z":"45012f78.86c5d","name":"IP","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload[0].address","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":280,"wires":[["8554d33e.6eead"]]},{"id":"c453f0d.b93711","type":"inject","z":"45012f78.86c5d","name":"","topic":"","payload":"10","payloadType":"num","repeat":"60","crontab":"","once":true,"onceDelay":0.1,"x":90,"y":280,"wires":[["801f5d06.d2c9d"]]},{"id":"801f5d06.d2c9d","type":"hostip","z":"45012f78.86c5d","name":"Host IP","x":220,"y":280,"wires":[["f731709.c52189"]]},{"id":"f66984f4.70d858","type":"comment","z":"45012f78.86c5d","name":"Display IP address on the mini OLED display","info":"","x":300,"y":240,"wires":[]},{"id":"414f604.c4230a","type":"exec","z":"45012f78.86c5d","command":"sudo reboot","addpay":false,"append":"","useSpawn":"true","timer":"4","oldrc":false,"name":"","x":470,"y":140,"wires":[[],[],[]]},{"id":"8c2297bc.a24728","type":"ui_button","z":"45012f78.86c5d","name":"","group":"ae7bc233.3c456","order":6,"width":0,"height":0,"passthru":true,"label":"Reboot Pi","color":"","bgcolor":"","icon":"","payload":"1","payloadType":"str","topic":"","x":280,"y":140,"wires":[["414f604.c4230a"]]},{"id":"bcdafe6a.1cdcd","type":"inject","z":"45012f78.86c5d","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":140,"wires":[["8c2297bc.a24728"]]},{"id":"1949951f.c994bb","type":"change","z":"b3ddf90e.a09218","name":"IP","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload[0].address","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":120,"wires":[["a910f2f1.2dd32"]]},{"id":"e4ccfcbd.2f65e","type":"inject","z":"b3ddf90e.a09218","name":"","topic":"","payload":"10","payloadType":"num","repeat":"60","crontab":"","once":true,"onceDelay":0.1,"x":110,"y":120,"wires":[["be99e886.7b65c8"]]},{"id":"be99e886.7b65c8","type":"hostip","z":"b3ddf90e.a09218","name":"Host IP","x":240,"y":120,"wires":[["1949951f.c994bb"]]},{"id":"a910f2f1.2dd32","type":"function","z":"b3ddf90e.a09218","name":"","func":"\n\n\nmsg.payload = \"http://\"+msg.payload+\"/html/min.php\"\nreturn msg;","outputs":1,"noerr":0,"x":490,"y":120,"wires":[["f2f68f7d.06dcc"]]},{"id":"f2f68f7d.06dcc","type":"ui_template","z":"b3ddf90e.a09218","group":"408f9230.25cedc","name":"","order":0,"width":0,"height":0,"format":"<iframe scrolling=no marginwidth=0 marginheight=0 frameborder=0 id=\"myFrame\" width=\"540\" height=\"440\" src = \"\"></iframe>\n<script>\n(function(scope) {\n    // watch msg object from Node-RED\n    scope.$watch('msg', function(msg) {\n        // new message received\n        var x = document.getElementById('myFrame');\n        x.setAttribute('src', msg.payload); \n        });\n})(scope);\n</script>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":620,"y":120,"wires":[[]]},{"id":"5442134b.08d54c","type":"exec","z":"1bd47399.a5c5dc","command":"sudo python /home/pi/Downloads/Raspi_Car/stop.py","addpay":false,"append":"","useSpawn":"true","timer":"4","oldrc":false,"name":"","x":560,"y":260,"wires":[[],[],[]]},{"id":"37661f0f.03b32","type":"ui_button","z":"1bd47399.a5c5dc","name":"","group":"c892232.a6b64e","order":8,"width":0,"height":0,"passthru":true,"label":"STOP","color":"","bgcolor":"","icon":"","payload":"1","payloadType":"str","topic":"","x":270,"y":260,"wires":[["5442134b.08d54c"]]},{"id":"83bf0fc1.b2a52","type":"inject","z":"1bd47399.a5c5dc","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":260,"wires":[["37661f0f.03b32"]]}]

 

 

 

 

image_pdfGenerate PDFimage_printPrint
Posted in Uncategorized.

Leave a Reply