Pi-loton Cadence side beta 2.0
Conflict
- During the implementation test, I found out that the OLED node will produce a message overflow and in turn will have reading conflict on the actual Cadence reading values node display.
Improvements.
- This flow aims to calibrate the rpm side for the Pi-loton project. The flow is using an OLED contrib by https://flows.nodered.org/node/node-red-contrib-oled . Credit and Thanks to Hedrikroth
With this small tweak, by applying a delay node with message rate restrictions, the flow have been resolve. The down side is that, the OLED display will have a latency as per time set on the delay node. Give or take, I am happy that the flow right now has no conflict on the i2c OLED Display and the Cadence value readings node display. I am hoping that for those enthusiast who are trying to use i2c OLED Display will try and would implement a delay node to avoid message overflow.
- Cadence is now implementing a smoothing reset.
Future Evaluation.
This flow is still under testing and its development process. If there are mistakes and errors I made please feel free to post your comments.
Copy JSON
Note: some third-party nodes may appear with blank styling, and not as they appear in the Node-RED Editor.
Copy [{"id":"5a5ea2f2.e652dc","type":"rpi-gpio in","z":"eee72f37.6dc038","name":"Pedal Sensor","pin":"35","intype":"up","debounce":"1","read":false,"x":106.76189804077148,"y":230.6666898727417,"wires":[["4d5a13de.9b38ec"]]},{"id":"4d5a13de.9b38ec","type":"switch","z":"eee72f37.6dc038","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":179.80953979492188,"y":314.3809390068054,"wires":[["a686b3b8.402338"]]},{"id":"a686b3b8.402338","type":"interval-length","z":"eee72f37.6dc038","format":"mills","bytopic":false,"minimum":"","maximum":"","window":"","timeout":true,"msgTimeout":"2","minimumunit":"msecs","maximumunit":"secs","windowunit":"msecs","msgTimeoutUnit":"secs","reset":true,"startup":true,"msgField":"payload","timestampField":"timestamp","repeatTimeout":true,"name":"","x":388.00001525878906,"y":138.57143592834473,"wires":[["8dee18cb.3647e"],["45531688.7b2658"]]},{"id":"8dee18cb.3647e","type":"function","z":"eee72f37.6dc038","name":"Crank RPM","func":"var x = msg.payload;\nvar rev = (60000/x);// milliseconds in a minute\nvar msg1 = {payload:rev};\nreturn msg1;","outputs":1,"noerr":0,"x":1007.9287414550781,"y":60.000038146972656,"wires":[["e68dbde5.97eb8","b7508949.c572a8"]]},{"id":"abbe2edb.a4f88","type":"ui_gauge","z":"eee72f37.6dc038","name":"","group":"df423369.1e76","order":2,"width":"4","height":"3","gtype":"gage","title":"RPM","label":"{{msg.topic}}","format":"{{value | number: 0}}","min":0,"max":"500","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1736.0000381469727,"y":49.71428966522217,"wires":[]},{"id":"e68dbde5.97eb8","type":"ui_chart","z":"eee72f37.6dc038","d":true,"name":"","group":"df423369.1e76","order":14,"width":"8","height":"3","label":"Cadence RPM Chart ","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"200","removeOlder":"20","removeOlderPoints":"","removeOlderUnit":"60","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":583.0952682495117,"y":273.5238723754883,"wires":[[]]},{"id":"b7508949.c572a8","type":"smooth","z":"eee72f37.6dc038","name":"","property":"payload","action":"mean","count":"15","round":"","mult":"single","reduce":false,"x":860.3690185546875,"y":140.83426189422607,"wires":[["62c2c0d1.cb277"]]},{"id":"f8b3f25c.c232d","type":"String","z":"eee72f37.6dc038","name":"RPM Value","display":"657ab741.69fea8","x":1627.7773895263672,"y":318.6068706512451,"wires":[]},{"id":"9936b03.019a95","type":"function","z":"eee72f37.6dc038","name":"Oled Rpm txt size and posistion","func":"var x = msg.payload;\nvar y = {\"size\":2,\"x\":1,\"y\":1,\"text\": x};\nvar msg1 ={payload:y};\n//var label = {\"size\":1,\"x\":18,\"y\":17,\"text\": \"RPM\"};\n//var msg2 = {payload : label}; \n\nreturn msg1;","outputs":1,"noerr":0,"x":1274.6029586791992,"y":177.09781169891357,"wires":[["f8b3f25c.c232d"]]},{"id":"62c2c0d1.cb277","type":"switch","z":"eee72f37.6dc038","name":"RPM Swith Control","property":"payload","propertyType":"msg","rules":[{"t":"null"},{"t":"lt","v":"1","vt":"num"},{"t":"btwn","v":"2","vt":"num","v2":"10","v2t":"num"},{"t":"gt","v":"11","vt":"num"},{"t":"gt","v":"500","vt":"str"}],"checkall":"true","repair":false,"outputs":5,"x":814.2696914672852,"y":264.1693458557129,"wires":[[],["f11f9720.435978"],["dc80c2f6.209f8"],["5b42d9b0.c48888","80eb8f56.8b408"],[]]},{"id":"f11f9720.435978","type":"change","z":"eee72f37.6dc038","name":"Oled to display Zero RPM","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"size\":2,\"x\":1,\"y\":1,\"text\":\"00.0*\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":1239.2695083618164,"y":219.90381050109863,"wires":[["f8b3f25c.c232d","42fb41ce.e9e7f"]]},{"id":"e23a4865.ef2598","type":"function","z":"eee72f37.6dc038","name":"round","func":"var num = msg.payload;\nvar n = num.toFixed(1);\nvar msg1 = {payload: n};\nreturn msg1;","outputs":1,"noerr":0,"x":1417.531234741211,"y":112.11721801757812,"wires":[["9936b03.019a95"]]},{"id":"a01997fc.ce6ae8","type":"change","z":"eee72f37.6dc038","name":"Oled to display Loading","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"size\":2,\"x\":1,\"y\":1,\"text\":\"LDNG*\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":1250.4323501586914,"y":270.25002098083496,"wires":[["f8b3f25c.c232d","cb198067.9cfb2"]]},{"id":"dc80c2f6.209f8","type":"change","z":"eee72f37.6dc038","name":"Oled to display low","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"size\":2,\"x\":1,\"y\":1,\"text\":\" LOW*\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":1325.2656860351562,"y":320.00000381469727,"wires":[["f8b3f25c.c232d","42f2fd02.0a7204"]]},{"id":"cb198067.9cfb2","type":"change","z":"eee72f37.6dc038","name":"loading","rules":[{"t":"set","p":"topic","pt":"msg","to":"Loading","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1772.5039901733398,"y":168.20703792572021,"wires":[["abbe2edb.a4f88"]]},{"id":"42f2fd02.0a7204","type":"change","z":"eee72f37.6dc038","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"LOW RPM","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1793.2657089233398,"y":232.7500147819519,"wires":[["abbe2edb.a4f88"]]},{"id":"5b42d9b0.c48888","type":"change","z":"eee72f37.6dc038","name":"RPM Label","rules":[{"t":"set","p":"topic","pt":"msg","to":"RPM","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1329.4323539733887,"y":50.83334970474243,"wires":[["abbe2edb.a4f88"]]},{"id":"42fb41ce.e9e7f","type":"change","z":"eee72f37.6dc038","name":"RPM Label","rules":[{"t":"set","p":"topic","pt":"msg","to":"RPM","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1616.1822814941406,"y":136.500009059906,"wires":[["abbe2edb.a4f88"]]},{"id":"45531688.7b2658","type":"change","z":"eee72f37.6dc038","name":"RPM TimeOUT set to Zero","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":471.85191345214844,"y":330.3704013824463,"wires":[["62c2c0d1.cb277","65902569.40395c"]]},{"id":"910bd1f3.b515d","type":"comment","z":"eee72f37.6dc038","name":"","info":"15\n1000","x":354.1666793823242,"y":61.666669845581055,"wires":[]},{"id":"80eb8f56.8b408","type":"delay","z":"eee72f37.6dc038","name":"To avoid OLED conflict","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":1201.2499694824219,"y":110.83338737487793,"wires":[["e23a4865.ef2598"]]},{"id":"65902569.40395c","type":"function","z":"eee72f37.6dc038","name":"reset rpm smoothing","func":"msg.reset=true;\nreturn msg;","outputs":1,"noerr":0,"x":665.3333740234375,"y":54.000022888183594,"wires":[["b7508949.c572a8"]]},{"id":"df423369.1e76","type":"ui_group","z":"","name":"DAudio","tab":"b12ebccc.218e98","order":1,"disp":false,"width":"8","collapse":false},{"id":"657ab741.69fea8","type":"oled-config","z":"","name":"32","width":"128","height":"32","address":"3c"},{"id":"b12ebccc.218e98","type":"ui_tab","z":"","name":"Mountain Bike Computer","icon":"dashboard","order":2,"disabled":false,"hidden":false}]