A fun little project for the house - Page 1
Forum section: electronics / projects

author: Ground_Loop
author_rank: Frequent Contributor
timestamp: February 06, 2021, 06:52:49 pm
content: I thought I would share something partially inspired by this community.After numerous issues with my water line I decided to get ahead of it a bit. I developed a device I’m calling Water Guard. The water line to my house is 1000 feet long and enters at street pressure, 150psi. Just inside the crawlspace is an isolation valve, pressure reducer, pressure gauge, and another isolation valve. Over the years I have suffered broken water lines, fouled reducer valve seats, internal slow leaks and billing issues. So, with a bit of occasional help from you folks I have created a monitor system which consists of a PIC18F27Q10-controlled instrument assembly and a PIC24FV32KA302-controlled user interface.The Instrument package is a analog street pressure sensor, flow meter with pulse-per-gallon output, analog house pressure sensor, and crawlspace temperature sensor. The instrument controller performs the following:1. Read in analog street and house pressure.2. Read One-Wire temperature.3. Accumulate water flow pulses in gallons up to 32 bit, good for several decades.4. Store in flash memory gallons every 100 gallons as a power outage guard.5. Transmit pressure, temperature and flow to the user interface.6. Allow for power on reset of stored gallons if desired.The water line instruments almost ready to cut in.Instrument controller still on the proto board. I noticed that the Bluetooth module didn't like the soft start of my bench supply so i had to put in a delayed start SCR to turn on power. The two pots are simulating the pressure sensors and water flow is simulated with a pulse generator. Temperature is the actual temperature sensor. The little buck power supply is backed up with a 9V battery through steering diodes. Both packages have a minimally intrusive breathing LED life indicator.The default view of the UI. Pressure, total recorded flow, date and timeUsage compare view. Begin and end dates are entered with the pushbuttons and data is pulled from the EEPROM. Usage is the difference between the two dates. Temperature also displayed.Hourly use review. Up an Down pushbuttons cycle through each of the last 24 hours to display hourly water usage.Data is transmitted to the UI over a married pair of Bluetooth modules using a UART channel on both ends. Marrying the Bluetooth modules was challenging in the sense that it was done through a terminal program with issues of its own and a TTL-RS232 converter I put together just for the occasion. The other challenge for me on the instrument end was the One-Wire protocol for the temperature probe. This is the most ridiculous and annoying thing I think I’ve ever dealt with. I ended up successfully creating a driver for the PIC. The One Wire takes so long that I had to pulse stretch the flow pulse to ensure it was never missed.On to the user interface. The UI receives data from the instrument package:1. displays relevant information on a 20x4 LCD2. Allows monitoring of the last 24 hours of water flow (leak detection)3. Allows comparing water flow for two selected dates. (billing accuracy check)4. Stores water usage at the end of each day in a 64K serial EEPROM5. Sets alarms for:a. House pressure too high (reducer failure)b. Street pressure too low (possible broken line)c. Crawlspace temperature too low (possible freeze hazard)d. Positive flow recorded for each of the last 24 hours (internal house leak)Time and date are maintained by a battery backed clock module. The UI utilizes 2 channels of I2C, one for the clock module and one for the EEPROM. I realize both could be one a single channel, but troubleshooting is simplified with dedicated channels. The LCD display is driven by a 16bit shift register on SPI. Bluetooth is on a UART channel. User inputs are NO pushbuttons with interrupt driven debouncing.Pictures are as of today. I am collecting enclosure components and will update when fully installed.I have dabbled in electronics my whole life, but my career centered on developing large scale industrial control systems and project management. Until a couple years ago I have never programmed anything in C and only a couple occasions programming microcontrollers in assembly. Thanks to all that helped. This has been fun and educational.The pics did not insert in-line, but they are in order below.

author: fourtytwo42
author_rank: Super Contributor
timestamp: February 06, 2021, 07:29:58 pm
content: Great ideaIn the UK our water meters have a little magnet on the pointer so long ago I put a reed switch down the hole with it and a display in the house that gives Litres/day, week & month. Useful for checking your bills BUT also saved me a ton of money when our underground pipe sprang a leak as I picked it up in a few hours rather than when the next bill arrived months laterThank god my normal water pressure is nowhere near 150psi, but I do wonder if a pulse is what split the plastic pipe that turned out to be a good 4ft down.I hope your Bluetooth modules still work over the desired distance, my reed switch is connected by wire and I am always catching it in the hedge cutter, wireless would be nice but that means batteries

author: Renate
author_rank: Super Contributor
timestamp: February 06, 2021, 08:46:47 pm
content: I don' need no stinking flow meter.I just check the level of my 20 gallon tank.I'll let you do the math: 1/2 a 20 gallon tank in 10 days...

author: Skashkash
author_rank: Regular Contributor
timestamp: February 06, 2021, 08:56:06 pm
content: That's pretty neat. I have a buddy that wants to do something similar on his water supply.Do you have a link or any info on the analog pressure sensors you selected and how you plan to read / calibrate them?Thanks.

author: Ground_Loop
author_rank: Frequent Contributor
timestamp: February 06, 2021, 09:08:50 pm
content: I bought the sensors and water meter off Amazon. Sensors cannot be calibrated. But if it really bothered me I could compare against a known standard and develop a calibration curve. As it is they are close enough. Range for both is 0.5-4.5VDC 0psi-full scale. The high pressure sensor is 0-150psi and the other is 0-100psi. Fittings are ⅛ MIP.

author: Ian.M
author_rank: Super Contributor
timestamp: February 06, 2021, 09:34:16 pm
content: 1Wire protocol is a *LOT* easier to handle if you have a free UART.Seehttps://www.maximintegrated.com/en/design/technical-documents/tutorials/2/214.htmlIt can be entirely non-blocking and handled by a background ISR.You may wish to consider changing to a PIC with two UARTs so you can eliminate the flow pulse pulsestretcher.Also, why not use one of the PIC's hardware counters to accumulate the flow pulse, or at the very least an external interrupt?

author: Ground_Loop
author_rank: Frequent Contributor
timestamp: February 06, 2021, 10:37:16 pm
content: Thanks for the suggestions Ian. Now that I have both ends operating reliably I'm reluctant to make any changes. Nonetheless, things to consider for the next projects.

author: Messtechniker
author_rank: Frequent Contributor
timestamp: February 07, 2021, 07:42:37 am
content: My non-invasive solution with a reflex light barrier:

author: Ground_Loop
author_rank: Frequent Contributor
timestamp: February 07, 2021, 01:27:29 pm
content: Quote from: Renate on February 06, 2021, 08:46:47 pmYou use 1 gallon per day? Our house averages about 200 per day.

author: Renate
author_rank: Super Contributor
timestamp: February 07, 2021, 02:08:46 pm
content: Quote from: Ground_Loop on February 07, 2021, 01:27:29 pmYup.Quote from: Ground_Loop on February 07, 2021, 01:27:29 pmI'd have to fill up 10 times a day for that!

author: Ground_Loop
author_rank: Frequent Contributor
timestamp: March 07, 2021, 06:00:05 pm
content: Got it in an enclosure and leak checked the instruments.Left to right, User Interface, sensor interface, sensor junction box.I got the UI faceplate from Front Panel Express. Next step is inserting the sensor assembly in the water line.

author: Renate
author_rank: Super Contributor
timestamp: March 07, 2021, 10:03:39 pm
content: That all looks very nice!The main front panel came out well.I like the two other boxes with a bit of gasket? and the screw inserts.I'm too used to boxes with self-tapping screws.