Ah, there are so many impressive people and projects here. What I have done is neither but it is why I love these devices: I used them to do a simple ugly hack to fix the hot water in my house. I have extended my computer skills into the real world. Amazing.
Background
I have a combination gas boiler in my home. Owing to some manufacturing or design defect, every couple of years the hot water breaks down. This is because the internal switch for DWH (Direct Hot Water) fails. I’ve tried everything in the past but the only reliable fix is to replace a fairly substantial assembly costing over £100.
It not the money, the scraped fingers, the swearing, the tears (mine) whilst replacing it. It’s the business critically of the service. When the thing breaks, the hot water suddenly goes cold when my wife is in the shower.
So I put together the ugliest of ugly hacks with a Netduino, a water flow sensor (http://proto-pic.co....er-flow-sensor/), a simple relay and a bunch of plumbing items.
Oh, and this code.
Can you tell that I don’t do this for a living?
using System;using System.Net;using System.Net.Sockets;using System.Threading;using Microsoft.SPOT;using Microsoft.SPOT.Hardware;using SecretLabs.NETMF.Hardware;using SecretLabs.NETMF.Hardware.NetduinoPlus;namespace NPlus_Water{ public class Program { static long pulsebuffer = 0; public static long totalPulse = 0; const int samplingPeriod = 500; // 1 second public static void Main() { InterruptPort FlowMeterPulse = new InterruptPort(Pins.GPIO_PIN_D7, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeHigh); FlowMeterPulse.OnInterrupt += new NativeEventHandler(FlowMeterPulse_OnInterrupt); bool flowLastPeriod = false; bool flowThisPeriod = false; OutputPort hotWater = new OutputPort(Pins.GPIO_PIN_D13, false); while (true) { WaitUntilNextPeriod(samplingPeriod); if (pulsebuffer > 10) { flowThisPeriod = true; } else { flowThisPeriod = false; } if (flowThisPeriod && flowLastPeriod) { hotWater.Write(true); } else if (!flowThisPeriod && !flowLastPeriod) { hotWater.Write(false); } flowLastPeriod = flowThisPeriod; Debug.Print("Pulses: " + pulsebuffer.ToString()); totalPulse += pulsebuffer; pulsebuffer = 0; } } public static void FlowMeterPulse_OnInterrupt(uint data1, uint data2, DateTime time) { pulsebuffer++; } static void WaitUntilNextPeriod(int period) { long now = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; var offset = (int)(now % period); int delay = period - offset; Debug.Print("sleep for " + delay + " msrn"); Thread.Sleep(delay); } }}
Here’s the thing. It has worked without a hitch and was a lot less expensive than the commercial part. And I did it myself with the support of this community: the various posts, the books, the inspiration (Cuno’s code).
Of course, I don’t let the wife see how appalling and flimsy the whole arrangement is.
Two pictures - One is where "the brains" plugs into the boiler instead of the old DHW switch. The other is "the brains": Neduino, flow meter, switch, etc.
Attached Files
Edited by Jack Chidley, 22 March 2013 - 02:09 PM.