Having a supply of water coming from a river or stream etc requires monitoring both the quality and the possibility of ruptured pipes, using the NXP Kinetis® MCU with FlexIO this can be done smartly.
Water pressure loss from ruptures can be hard to find and may not be found for months unless they are monitored by hand especially when your away or have a long running
I will build a system that monitors the water level, quality and pressure inside a pump system. Identifying ruptures along a piped water system, blockages and an auto cut off so the pumps do not end up damaged from blockages.
Progress pics!I was going to use the registers to store and hold state about whether the valve is to be on or off but learnt that the sensor generates pulses not a variable voltage. It has a manual control for maintenance. If I get time, I will pop a stepper motor to raise a flag when something is wrong because who doesn't like flags?
States:- Water is flowing valve open
- Water is slowing down or stopped, close valve
- valve is closed, will make a check to try again to see if we have flow if not raise flag
- Water is flowing at a rate less than max(approx) recorded (leaks)
- Manual mode (button control)
The states will need training but it should be relatively simple.
Extras:- CO2 sensor MQ135 - done!
- intelligent flow detection
- NPN resistors to turn the h-bridge and valve power on/off (somehow I misplaced them :( )
- one of the nice things about the RTC clock is you could now place this on a day night, month etc timer which is awesome!
- hooking up a pump
- The current water flow sensor is limited to 1.5pa of pressure.
- Not owning spare hosing.
It will start in automatic mode. You can switch to manual control just by pressing any of the hard buttons on the board. Press the left button twice to switch back to automatic mode. The console/serial port prints out how many litres /mls a second is going through and a total since the board has been turned on. It will automatically turn the ball valve off if the flow is less than 1 litre a minute.
Progress diary:Instructions:Follow these instructions to get the K82F up and running:
Make sure you've loaded openSDA on the board. Grab the source from GitHub and import into Kinetis Design Studio to compile and load onto the board.
The easiest way to hook up the devices is to follow the schematic. But here is a list of pins and associated parts:
- VCC for controlling the H-bridge PTB16 and PTB17
- VCC control for turning both the H-bridge on and the driver PTD0 and PTC11
- sensor readings are off PTC9 and sensor VCC is PTC9
- CO2 sensor reads off off A01 and any power and ground pin will do
You can optionally hard wire power to the pins on the H-bridge instead of using the NPN resistors.
The CO2 sensor will need calibrating but I'm not sure how to do that properly without a CO2 chamber.
Once you have assembled the curcuit board after following the schematic and have in your possession a ball valve and water flow sensor, place them far enough apart that if water starts flowing again the sensor will not be blocked by the valve, this is important otherwise it won't re-open when there is flow.
Ball Valve ====== hosing ====== water flow sensor ======> water
The code will determine when to automatically shut off should there be reduced flow or no flow at all due to a blockage. This prevents water waste when there is a rupture or other unknown issue.
Make sure to power the sensor off 3.3v not 12v otherwise you might damage the K82F (I almost did)
Within the code you can adjust the level in which you want a shut off with the variable WATER_SHUTOFF_LEVEL in main.c
Comments