Skip to content
PekawayPekaway
Integrate flow sensors in VAN PI - measure filter flow

Integrate flow sensors in VAN PI - measure filter flow

A big thank you goes to Marvin, who wrote today's post. Check out his Instagram.

https://instagram.com/bastelmarvin?igshid=YmMyMTA2M2Y=

TürTorial #10 Integrating flow sensors in VAN PI

What is it about?

I installed the VAN PI system in the boat and unlike most people, I don't have fixed water tanks, but rather so-called water bags. That's why I can't use standard level sensors and had to think of something new. The solution was quickly found: flow sensors, also called flow meters. You need two of them. One measures how many liters of water go into the tank and the other counts how many liters of water flow out again. The difference is then the content.

The installation

As described above, two flow sensors are required. I have sensors of type

YF-S201 . We install the first one in the hose through which you fill the water. In my case it is at the front of the bow and looks like the picture below. The flow sensor has a 1/2" external thread on both sides, onto which I screwed hose nipples. I clamped this construction between my filling line.

Now the whole thing is wired and placed towards the VAN PI system. You can use an Ethernet cable or a telephone line, which are available cheaply at hardware stores.

The following assignment applies to the YF-S201 sensor:

Connection to the VÁN PI Relayboard

Connecting to the VAN PI system is now getting a bit more complicated, so grab a soldering iron and some solder.

In the two pictures above you can see the relay board from above on the left, from below

Before you continue, turn off the power to everything. Remember to disconnect the shunt first, then the power from the Pi!

Let's start on the left: there you can see some solder pads, in the same arrangement as the Pi. The solder pad at the bottom left is the 3.3V from the RaspberryPi, you solder your plus from the flow sensors there. One row higher, the 3rd pin is GND. You solder your minus there. Now go to the 8th pin in the top row (Pi pin 16), there you solder the signal from your input sensor. Unfortunately, the pin from the output is not explicitly led out, so you have to turn the board over and solder the cable for the output sensor directly to the connector strip where the RaspberryPi is plugged in. (Warning: it's easy to miscount there) If the barcode is at the top, then it is the 12th pin from the left in the bottom row (Pi pin 18). Once everything is soldered and insulated, you can reassemble and connect the VanPi system. First check that all cables are properly seated and that there is no fine wire sticking out to the adjacent pin. Below is an overview of all pins.

NodeRed Backend

Now let's connect our new sensors digitally. To do this, we go to the VAN PI backend. To do this, call up the following in the browser of your choice:

“IP_Eures_VanPI:1880/#flow/e10bdbef.f84828”.

Then we are in the backend of the VanPI system. You can now see many building blocks that are connected to each other.

To import the source code (shown below), click Import in the top right menu.

A small pop-up window will now open. Insert the source code there. Now you have the source code and can place it in an empty space, ideally under the water tanks.

You still have to adjust your approximate tank content in the source code. To do this, you have to change the 300 to your approximate tank content in the orange box in line 5. Since the amount is now calculated in liters and no longer in percent, we now have to change the display from % to liters. To do this, replace the orange "get global" and turquoise "Wave" blocks in the block row under "Delete unused water tanks here" with the two new ones. We are now finished in the backend. To do this, click on "Deploy" in the top right.

interface

You will hardly see any difference, except that water level 1 now shows an "L" instead of a "%" sign. Now you can fill in water and the display should show you the content. After you have done that, you can specify a more precise water content in the backend. But remember that we do not count down to the smallest milliliter here. If you ever want to adjust the content of the tank as you wish, you have the option to do so in the config under "Sensors". Here are two new buttons to fill or empty your water level 1.

Source code for import:

[{"id":"fc85e9b3ee2abd18","type":"rpi-gpio in","z":"e10bdbef.f84828","name":"","pin":"16","intype": "tri","debounce":"10","read":false,"x":610,"y":1200,"wires":[["c8d6fb0225660b90"]]},{"id":"c8d6fb0225660b90 ","type":"function","z":"e10bdbef.f84828","name":"fill","func":"//individual counting\n// Get the current counter value from storage\nvar myCount = flow.get(\"WaterLiter\") ||. 0;\n\nvar maxfull = 300;\nglobal.set(\"maxfullglob\", maxfull);\n\n\nif (msg.payload == \"0\")\n{ \n // Add 1 to the counter\n myCount=myCount+(1/450);//here 450 individual steps\n flow.set(\"WaterLiter \", myCount);\n global.set(\"Level1\", myCount);\n}\n\n\nif (msg.payload == \"resetjful\")\n{ \n myCount == maxfull;\n flow.set(\"WaterLiter\", maxfull);\n global.set(\"Level1\", maxfull);\n msg.payload=myCount;\n return msg;\n}\n \n//Max status min status\nif (myCount > maxfull) {myCount = maxfull} else if (myCount < 0) {myCount = 0}\n\n\n\nmsg.payload=myCount\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":730,"y":1220," wires":[[]]},{"id":"3a0c1a824da2f768","type":"ui_button","z":"e10bdbef.f84828","name":"","group":"1032e8ff. e5a657","order":17,"width":0,"height":0,"passthru":false,"label":"Set water 1 Empty","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"resetjleer","payloadType": "str","topic":"topic","topicType":"msg","x":950,"y":1240,"wires":[["5ad496c4f6821cf1"]]},{"id": "578336c777d09cd0","type":"comment","z":"e10bdbef.f84828","name":"Water Flow Sensors","info":"","x":860,"y":1120, "wires":[]},{"id":"53ed7d76e7504e49","type":"rpi-gpio in","z":"e10bdbef.f84828","name":"","pin":"18","intype":"tri","debounce":"10","read":false, "x":990,"y":1200,"wires":[["5ad496c4f6821cf1"]]},{"id":"5ad496c4f6821cf1","type":"function","z":"e10bdbef.f84828 ","name":"empty","func":"//individual counting\n// Get the current counter value from storage\nvar myCount = flow.get(\"WaterLiter\") || 0;\nvar maxvoll = global.get(\"maxvoll\");\n\nif (msg.payload == \"0\")\n{ \n // Add 1 to the counter\n myCount=myCount -(1/450);//here 450 individual steps\n flow.set(\"WaterLiter\", myCount);\n global.set(\"Level1\", myCount);\n}\n\n \nif (msg.payload == \"resetjempty\")\n{ \n myCount == 0;\n flow.set(\"WaterLiter\", 0);\n global.set(\"Level1\" , 0);\n msg.payload=myCount;\n return msg;\n}\n\n\n\n//Max status min status\nif (myCount > maxfull) {myCount = maxfull} else if (myCount < 0) {myCount = 0}\n\n\n\nmsg.payload=myCount\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"" ,"libs":[],"x":1110,"y":1220,"wires":[[]]},{"id":"818d0bf8be6ebe5c","type":"comment","z" :"e10bdbef.f84828","name":"Input","info":"","x":660,"y":1160,"wires":[]},{"id":"af56c6b8740c3262" ","type": "comment","z":"e10bdbef.f84828","name":"Output","info":"","x":1020,"y":1160,"wires":[]},{ "id":"defe58d92fb0f188","type":"ui_button","z":"e10bdbef.f84828","name":"","group":"1032e8ff.e5a657","order":16," width":0,"height":0,"passthru":false,"label":"Set Water 1 Full","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"resetjvoll","payloadType ":"str","topic":"topic","topicType":"msg","x":570,"y":1240,"wires":[["c8d6fb0225660b90"]]},{"id ":"c04bf80f.a3bca8","type":"ui_gauge","z":"e10bdbef.f84828","name":"","group":"577bbbad.624d64","order":1," width":"3","height":"3","gtype":"wave","title":" {{sensorname}} ","label":"%","format":" {{value}} ","min":0,"max":"99","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"" ,"className":"","x":1070,"y":940,"wires":[]},{"id":"7caef129.00c9c","type":"function","z" :"e10bdbef.f84828","name":"get global","func":"var check = global.get(\"Level1\");\nvar label = global.get(\"NLevel1\"); \n\nvar maxvoll = global.get(\"maxvollglob\");\n\nmsg.sensorname = label;\n\nif (check > maxvoll) {\n check = 100\n}\nelse if (check < 0) {\n check = 0\n}\n\nmsg.payload = check; \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":880,"y":940 ,"wires":[["c04bf80f.a3bca8"]]},{"id":"1032e8ff.e5a657","type":"ui_group","name":"WasserLevel Name","tab":"343363652ed7cfb3","order":3,"disp":true,"width":6,"collapse":true},{"id":"577bbbad.624d64","type" :"ui_group","name":"Water","tab":"c77f413b.09f91","order":3,"disp":true,"width":"6","collapse":false}, {"id":"343363652ed7cfb3","type":"ui_tab","name":"Sensors","icon":"dashboard","order":12,"disabled":false,"hidden":true },{"id":"c77f413b.09f91","type":"ui_tab","name":"Info","icon":"mi-info","order":1,"disabled":false ,"hidden":false}]

Source code to copy:

https://share.12-s.de/s/gYxmtZogHBtiqy3

Leave a comment

Your email address will not be published..

more tutorials

Open Source needs support

become Patron now

More projects, more tutorials and more supported devices. Our community is growing and would appreciate your support. So become a patron now to always receive the latest content and support the VAN PI project at the same time.

Become a Patron
Cart 0

Your cart is currently empty.

Start Shopping