Control Signals Flow
The Node-RED flow for sending control signals to the Nano circuit is shown below.
Code
You can recreate the flow by importing the code below into your Node-RED editor.
[{"id":"9dfab80c77ae7237","type":"tab","label":"Control Signal Flow","disabled":false,"info":"","env":[]},{"id":"db681470950d87aa","type":"mqtt in","z":"9dfab80c77ae7237","name":"Subscribe - STEMVentorHiveMQ - control-signals","topic":"control-signals","qos":"2","datatype":"auto-detect","broker":"90844ce0ad4c8dc2","nl":false,"rap":false,"rh":0,"inputs":0,"x":300,"y":360,"wires":[["fe332e922abb0a3a"]]},{"id":"fe332e922abb0a3a","type":"json","z":"9dfab80c77ae7237","name":"","property":"payload","action":"obj","pretty":false,"x":590,"y":360,"wires":[["3d0cd9a77e6c03a7","b4033ac821a6be3a"]]},{"id":"3d0cd9a77e6c03a7","type":"switch","z":"9dfab80c77ae7237","name":"IdentifyBoard","property":"payload.board_name","propertyType":"msg","rules":[{"t":"eq","v":"Arduino Nano","vt":"str"},{"t":"eq","v":"Raspberry Pico","vt":"str"},{"t":"eq","v":"ESP32","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":4,"x":770,"y":360,"wires":[["b4bd0ac8099249ec"],["289145d7bc5199fc"],["9342167c41316e31"],["8881be9f7401b3b0"]]},{"id":"8881be9f7401b3b0","type":"function","z":"9dfab80c77ae7237","name":"ReturnInvalidBoardMsg","func":"\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1090,"y":480,"wires":[[]]},{"id":"9c6364c3c1dbbfcd","type":"json","z":"9dfab80c77ae7237","name":"ToJSONString","property":"payload","action":"str","pretty":false,"x":1620,"y":240,"wires":[["481f86170625ab01","6e84a3ff74d48ea7"]]},{"id":"b4bd0ac8099249ec","type":"function","z":"9dfab80c77ae7237","name":"ReducePayload","func":"// Once the board has been identified\n// only send the pin and value to it to reduce overhead.\n\nvar reduced_msg = {\n payload:{\n pin: msg.payload.pin,\n value: msg.payload.value,\n timestamp: msg.payload.timestamp\n }\n}\n\nreturn reduced_msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1060,"y":240,"wires":[["b99b1ae572c19a1b"]]},{"id":"fb362a2aaea82d41","type":"serial out","z":"9dfab80c77ae7237","name":"PicoSerialOut","serial":"98dbac6f7bfc9d91","x":1520,"y":320,"wires":[]},{"id":"289145d7bc5199fc","type":"function","z":"9dfab80c77ae7237","name":"ReducePayload","func":"// Once the board has been identified\n// only send the pin and value to it to reduce overhead.\n\nvar reduced_msg = {\n payload: {\n pin: msg.payload.pin,\n value: msg.payload.value,\n timestamp: msg.payload.timestamp\n }\n}\n\nreturn reduced_msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1060,"y":320,"wires":[["78d91f59d8f10558"]]},{"id":"78d91f59d8f10558","type":"json","z":"9dfab80c77ae7237","name":"ToJSONString","property":"payload","action":"str","pretty":false,"x":1280,"y":320,"wires":[["fb362a2aaea82d41"]]},{"id":"9342167c41316e31","type":"function","z":"9dfab80c77ae7237","name":"ReducePayload","func":"// Once the board has been identified\n// only send the pin and value to it to reduce overhead.\n\nvar reduced_msg = {\n payload: {\n pin: msg.payload.pin,\n value: msg.payload.value,\n timestamp: msg.payload.timestamp\n }\n}\n\nreturn reduced_msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1060,"y":400,"wires":[["955200fc7e66d866"]]},{"id":"955200fc7e66d866","type":"json","z":"9dfab80c77ae7237","name":"ToJSONString","property":"payload","action":"str","pretty":false,"x":1280,"y":400,"wires":[["32b48993f582f8bf"]]},{"id":"32b48993f582f8bf","type":"serial out","z":"9dfab80c77ae7237","name":"ESP32SerialOut","serial":"98dbac6f7bfc9d91","x":1520,"y":400,"wires":[]},{"id":"b4033ac821a6be3a","type":"debug","z":"9dfab80c77ae7237","name":"debug 5","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":780,"y":580,"wires":[]},{"id":"481f86170625ab01","type":"serial out","z":"9dfab80c77ae7237","name":"NanoSerialOut","serial":"e89ac83158ba7533","x":1840,"y":240,"wires":[]},{"id":"b99b1ae572c19a1b","type":"switch","z":"9dfab80c77ae7237","name":"","property":"payload.pin","propertyType":"msg","rules":[{"t":"eq","v":"D4","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1270,"y":240,"wires":[["587ab94174a9d58f"],["9c6364c3c1dbbfcd"]]},{"id":"587ab94174a9d58f","type":"range","z":"9dfab80c77ae7237","minin":"0","maxin":"10","minout":"0","maxout":"180","action":"scale","round":true,"property":"payload.value","name":"","x":1440,"y":180,"wires":[["9c6364c3c1dbbfcd"]]},{"id":"6e84a3ff74d48ea7","type":"debug","z":"9dfab80c77ae7237","name":"debug 6","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1840,"y":340,"wires":[]},{"id":"90844ce0ad4c8dc2","type":"mqtt-broker","name":"STEMVentor HiveMQ","broker":"0d7e686af22d4bada5068acbd9312761.s1.eu.hivemq.cloud","port":"8883","tls":"","clientid":"","autoConnect":true,"usetls":true,"protocolVersion":"5","keepalive":"60","cleansession":true,"autoUnsubscribe":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willRetain":"false","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""},{"id":"98dbac6f7bfc9d91","type":"serial-port","name":"","serialport":"COM11","serialbaud":"9600","databits":"8","parity":"none","stopbits":"1","waitfor":"","dtr":"none","rts":"none","cts":"none","dsr":"none","newline":"\\n","bin":"false","out":"char","addchar":"\\n","responsetimeout":"10000"},{"id":"e89ac83158ba7533","type":"serial-port","name":"","serialport":"COM3","serialbaud":"9600","databits":"8","parity":"none","stopbits":"1","waitfor":"","dtr":"none","rts":"none","cts":"none","dsr":"none","newline":"\\n","bin":"false","out":"char","addchar":"\\n","responsetimeout":"10000"}]