Bicycle Speedometer and Cadence Test Flow

This test project is an implementation of the Raspberry Weather pi. The flow structure was pattern based on the anemometer python code to measure the wind speed. This experiment aims to implement the python code in node red .

The primary sensor in this project is a Honeywell Magnetic contact since the magnetic contact has a reed switch and is available off the shelf at our local hardware and online .

Many thanks to the Raspberry pi Foundation for sharing the weather pi project to the public. I would also like to thank the maker of interval length node , bartbutenaers.

This flow still need further improvements. Evaluation and feedbacks are highly appreciated.

[{"id":"5a5ea2f2.e652dc","type":"rpi-gpio in","z":"eee72f37.6dc038","name":"Pedal Sensor","pin":"35","intype":"up","debounce":"25","read":false,"x":187,"y":224,"wires":[["4d5a13de.9b38ec","e7ea3d50.4b1b6","ee89f341.369cf"]]},{"id":"a54fb71.5e264c8","type":"debug","z":"eee72f37.6dc038","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":759,"y":485,"wires":[]},{"id":"98c086d6.6dbd08","type":"rpi-gpio in","z":"eee72f37.6dc038","name":"Wheel Sensor","pin":"40","intype":"up","debounce":"1","read":false,"x":212.61114501953125,"y":460.80560302734375,"wires":[["abd42eb2.0c93e8"]]},{"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":356,"y":282,"wires":[["a686b3b8.402338"]]},{"id":"a686b3b8.402338","type":"interval-length","z":"eee72f37.6dc038","format":"mills","bytopic":false,"minimum":"","maximum":"","window":"","timeout":false,"msgTimeout":"","minimumunit":"msecs","maximumunit":"msecs","windowunit":"msecs","msgTimeoutUnit":"msecs","reset":false,"startup":false,"msgField":"payload","timestampField":"timestamp","repeatTimeout":false,"name":"","x":398,"y":190,"wires":[["8dee18cb.3647e"],[]]},{"id":"8dee18cb.3647e","type":"function","z":"eee72f37.6dc038","name":"","func":"var x = msg.payload;\nvar rev = (60000/x);\nvar msg1 = {payload:rev};\nreturn msg1;","outputs":1,"noerr":0,"x":544,"y":336,"wires":[["abbe2edb.a4f88"]]},{"id":"abbe2edb.a4f88","type":"ui_gauge","z":"eee72f37.6dc038","name":"","group":"df423369.1e76","order":3,"width":"8","height":"4","gtype":"gage","title":"Cadence","label":"RPM","format":"{{value | number: 1}}","min":0,"max":"200","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":627,"y":403,"wires":[]},{"id":"e7ea3d50.4b1b6","type":"trigger","z":"eee72f37.6dc038","op1":"","op2":"0","op1type":"nul","op2type":"num","duration":"2","extend":false,"units":"s","reset":"0","bytopic":"all","name":"","x":253,"y":351,"wires":[["abbe2edb.a4f88"]]},{"id":"ee89f341.369cf","type":"trigger","z":"eee72f37.6dc038","op1":"","op2":"1","op1type":"nul","op2type":"num","duration":"2","extend":false,"units":"s","reset":"1","bytopic":"all","name":"","x":265,"y":387,"wires":[["abbe2edb.a4f88"]]},{"id":"88a44ce4.9e933","type":"ui_gauge","z":"eee72f37.6dc038","name":"","group":"df423369.1e76","order":1,"width":"4","height":"4","gtype":"gage","title":"Speed","label":"KMPH","format":"{{value | number:1 }}","min":0,"max":"50","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":870.2500076293945,"y":745.5000238418579,"wires":[]},{"id":"abd42eb2.0c93e8","type":"interval-length","z":"eee72f37.6dc038","format":"mills","bytopic":false,"minimum":"","maximum":"","window":"","timeout":false,"msgTimeout":"5","minimumunit":"msecs","maximumunit":"secs","windowunit":"msecs","msgTimeoutUnit":"msecs","reset":false,"startup":false,"msgField":"payload","timestampField":"timestamp","repeatTimeout":false,"name":"","x":409.3333206176758,"y":676.416690826416,"wires":[["49f7f80e.6f7f38"],[]]},{"id":"11198ecb.28d031","type":"switch","z":"eee72f37.6dc038","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":253.99920272827148,"y":577.5653305053711,"wires":[["abd42eb2.0c93e8"]]},{"id":"49f7f80e.6f7f38","type":"function","z":"eee72f37.6dc038","name":"rpm","func":"var x = msg.payload;\nvar rev = (60000/x);\nvar msg1 = {payload:rev};\nreturn msg1;","outputs":1,"noerr":0,"x":467.6102867126465,"y":565.065318107605,"wires":[["910fb33a.eb335"]]},{"id":"910fb33a.eb335","type":"function","z":"eee72f37.6dc038","name":"speed calculator","func":"var rpm = msg.payload;\nvar radius = 20.32;\nvar cm_in_km = 100000.0;\nvar sec_in_an_hour = 3600;\nvar circumference_cm = (2* Math.PI) * radius;\n\nvar dist_km =  (circumference_cm * rpm )/ cm_in_km;\nvar km_per_sec =dist_km /3600; \nvar km_per_hour = (km_per_sec * sec_in_an_hour * 1.8);\nvar msg1 = {payload: km_per_hour};\n\nreturn msg1;","outputs":1,"noerr":0,"x":705.2500114440918,"y":650.2500295639038,"wires":[["88a44ce4.9e933","d0ec0bcd.af66a8"]]},{"id":"220fabde.e6ccb4","type":"ui_gauge","z":"eee72f37.6dc038","name":"","group":"df423369.1e76","order":2,"width":"4","height":"4","gtype":"gage","title":"Power","label":"Watts","format":"{{value | number:1 }}","min":0,"max":"30","colors":["#b5323b","#e6e600","#389d21"],"seg1":"","seg2":"","x":718.0186462402344,"y":838.4848909378052,"wires":[]},{"id":"d0ec0bcd.af66a8","type":"function","z":"eee72f37.6dc038","name":"Estimated Power Calculator","func":"var x = msg.payload;\nvar power = x*1.092;\nvar msg1 = {payload:power}\nreturn msg1;","outputs":1,"noerr":0,"x":494.1725158691406,"y":819.2075529098511,"wires":[["220fabde.e6ccb4"]]},{"id":"df423369.1e76","type":"ui_group","z":"","name":"Bicycle Crank and Wheel Sensors","tab":"b12ebccc.218e98","disp":true,"width":"12","collapse":false},{"id":"b12ebccc.218e98","type":"ui_tab","z":"","name":"Speedometer and RPM Test Project","icon":"dashboard","disabled":false,"hidden":false}]

Flow Info

Created 5 years, 5 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • debug (x1)
  • function (x4)
  • switch (x2)
  • trigger (x2)
Other

Tags

  • raspberry
  • pi
  • cadence
  • and
  • speedometer
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option