Notifications
Clear all

My P-trap water sensor

42 Posts
6 Users
20 Likes
2,617 Views
 Biny
(@binaryrhyme)
Member
Joined: 2 years ago
Posts: 269
Topic starter  

My first post (after my intro)!

My Mom-in-Law has a guest room tub that we suspect regularly goes dry via evaporation, allowing sewer gases to come in to the house. That's the theory, anyway - and the mitigation strategy thus far has been to run the taps periodically. I'm building a water probe that will have a simple UI - red if there is no water in the trap, and green if there is, that will be powered by USB or a power brick - no microprocessor required.

My electronics is rusty (software guy by trade) so this is my inaugural project after many years of neglect. I've got "Water Probe - v01" breadboarded and it mostly works, but it needs some tweaking.

Water Probe Schematic - v01

On the table are two issues:

Issue 1) I'm currently driving this using the classic 3.3/5V breadboard power supply PCB - and I'm getting wildly varying output voltages from the +5V rails (from 4V to 8V) depending on what I drive the board with. I suspect my initial cheapo kit buy wasn't from a vendor strong on quality tolerances, or I have a bad apple. What vendors have a reputation for good products of this ilk?

I've ordered a couple of Pololu S7V7F5 Buck/Boost converters (A lesser sibling of the one featured in Bill's video), and will see if they condition the power to a more consistent level.

Issue 2) When the probe (just two dupont wires at this point) is in water, the resistance across the leads is 21K (salty water) or 50K (tap water). I use an NPN (2N3904) to amplify the resulting current, and that works reasonably well, but I'm not getting as much current as I'd like, it seems. The green LED (T1) emitter drives LED1, but it's about half brightness, and the bc current on T2, a PNP (2N3906) isn't enough to shut down the collector-base current on the red LED2. I need to do mucho measuring and mathing to tweak the values on the resistors, I think - suggestions welcome.

Hope the day finds you well. 🙂

I edit my posts to fix typos, correct grammar, or improve clarity. On-screen keyboards are evil.


   
Quote
(@davee)
Member
Joined: 3 years ago
Posts: 1697
 

Hi @binaryrhyme,

   I have only limited experience of vendors, but so far the 'cheap stuff', has worked, albeit sometimes 'near the edge', so expect issues like poor smoothing/decoupling because capacitors are smaller than a robust design. However these guys must rely on selling a fair quantity to make it worthwhile at the minimal profit margins, so they usually make sure most of their stuff works ... but I only would only use it in situations where failure is a frustration at most .. never where it could cause injury or worse.

Of course, because such boards must be made very quickly and cheaply, testing will be minimal and occasional bad apples will emerge.

Alternately, there are 'professional' suppliers, Farnell, Avnet, Digikey, Mouser, etc., who will normally only deal with quality controlled products, but their price maybe less attractive.

With regard to your voltage regulator, sadly it sounds like it may have failed.

It might be bad luck, but depending on what checks you made before connecting it up, I would suggest you check out your source of power, and also the specification of the regulator chip(s) on the board. Ensure, they are compatible with good margins... as I said, expect parts to be pushed to the limit.

This covers voltage, current and heat dissipation ... the last particularly with linear regulators. Some of the boards use small devices with little or no heat sinking, so overheating can easily occur if the current drawn, or the input voltage, is higher than it can cope with. Most are supposed to have a protective shutdown, but that should be regarded as a 'once in a lifetime' - not a normal mode of operation.

As for the buck/boost ... I have never used a buck/boost, but I have read some warnings in the reviews that among the cheap ones, there are some around with a very nasty habit. I would advise carefully checking the operation as the input voltage reduced, before connecting to a load that might be damaged ... as the input voltage is reduced, it should switch off at a certain point, but some are reported to flick to a high output voltage ... i.e. the input voltage is too low for the voltage control mechanism, but the boost function continues uncontrolled. I suspect only a small minority (if any) of units on sale are affected in this way, but if I get a buck/boost, I will be carefully checking it before use.

Just personal views .. good luck with your project.


   
ReplyQuote
 Biny
(@binaryrhyme)
Member
Joined: 2 years ago
Posts: 269
Topic starter  

@davee Excellent info - many thanks. I hear you on the 'mostly works' - yes, results varied on this unit depending on what was driving it.

Thanks for the heads up on the buck/boost issues. I think I'll need to invest in a component test breadboard, so I can put incoming bits through my own receiving QA. I just took delivery of the two I ordered, but will rig up the test infrastructure before putting them in my project.

I edit my posts to fix typos, correct grammar, or improve clarity. On-screen keyboards are evil.


   
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1697
 

Hi @binaryrhyme,

  Pleased you found my last post helpful.

I also had a look at your other question (which maybe would have been better as a separate post from you?)

I suggest you consider using a simulator for testing out your ideas ... they are not a 'perfect' answer, as the models and reality are always a bit different, but they often provide guidance and insight into how changes are likely to affect it.

There are several free SPICE simulators around that can handle circuits like yours ... my 'goto' default is LTspice, presently LTspice XVII version 17.x, which originated from Linear Technology, and is currently on the Analog Devices website, as they have bought LT to expand the chip catalogue, and have stated they intend to continue to support and provide LTspice free.

I had hoped to add an example of a modified version of your circuit, but for some reason (may be me being stupid), I don't seem to be able to attach pics and files at present.

Anyway, my suggestions to consider are:

  • My simulation used an 'unspecified' NPN transistor, which was a bit low on gain for your circuits needs. If your 'real' circuit is suffering similarly, make T1 into a Darlington pair ... either add a 2nd 2N3904, or find a Darlington pair device. This makes a 'super gain transistor', so that the current passing through the water is sufficient to drive the green LED more brightly ... (Darlington pair is a classic 'trick' .. see Wikipedia or similar if you are not familiar with it.)
  • LEDs come in shapes and sizes, but the common small ones usually need close to 20 mA current for a good brightness .. Reduce the 220 Ohm resistors ... maybe nearer 60-80 Ohms  .. not too low to burn out the device of course.
  • To turn the RED LED off, (when the GREEN LED is on), the base-emitter voltage for T2 must be reduced to well below 0.5V. T1 is not achieving that, as the current flowing throgh the water is insufficient to drive T1 into a 'hard' saturation. Hence, a small forward biased silicon diode (cathode end connects to T2 emitter, anode to +5V rail) in series with T2 emitter, introduces an extra voltage drop of about 0.5V, so that T2 is no longer biased to conduct current.
  • Changing T1 to a Darlington pair will actually make the last problem worse! However, this can be balanced by using two diodes in series, instead of one!
  • 10k resistor connected to base of T2 may benefit from a reduction of value .. my simulation with the 'unspecified' PNP preferred about 2.5k to have sufficient base current to adequately drive the LED. T1 is driving its LED and will barely notice the extra current demand from T2.

Hope this is helpful ... remember these are only suggestions to consider and maybe try .. certainly not guaranteed fixes.

------

Additional thoughts about your application:

  • Passing a DC current through water will cause electrolytic reactions .. your present electrodes will be plated and corroded, plus you may find salts being deposited. Materials such as platinum are often chosen to minimise this problem. Only experience will tell you how quickly this effect will 'break' your system with the electrodes you choose - the current is quite small, which is in your favour.
  • Also, to minimise this effect, 'professional' systems use AC rather than DC to sense the water resistance ... the AC implies that the electrolysis reaction is continually being reversed, thus reducing the 'net progress' rate of the electrolytic reactions. Probably over the top for your requirements, but I thought you might be interested.
  • As for the water problem itself, I don't know about the temperature, humidity etc, or the length of time between flushes of water, but my experience is that it takes a long time for the water to evaporate in my locality ... typically months. I am certainly not a plumber, but I do know that if the trap is connected to the drain/sewer pipe with an inadquate ventilation system (on the drain side), it is possible for water flows elsewhere in the drain/sewer to 'suck' the water out of the trap and down into the sewer. As well as looking at the drain vent pipe arrangement, I think you can get traps with an extra valve or something to reduce this problem. Just a thought if it is happening within a short time.

Hope this is interesting. Please let me know how you get on

Good luck with your project. Best wishes. Dave


   
ReplyQuote
 Biny
(@binaryrhyme)
Member
Joined: 2 years ago
Posts: 269
Topic starter  

@davee Thanks muchly for taking as much time with this! Your remarks are informative indeed. I'm at v03 now and have cracked the inverter issue - my issue was that the base of both a PNP and an NPN connected together did not provide the intended result. 😉 I've gone all positive logic now, and the open and shorted conditions work fine. I have some work to do on the middle thresholds, which brings me to...

To deal with the variability of water conductivity (and now I'll factor in possible electrolytic degradation), I've decided to go with comparators on the probe intake, so I can tweak the thresholds with trim pots... and I'll make sure the probe can be replaced in the mechanical design... good catch. Sacrificial anode, maybe? My electrolytic chemistry chops are aged indeed.

I ran Spice in the 80s on a couple projects, but had forgotten all about it! Good reminder. Betcha it's easier to use now than the ol' UNIX shell command line version, lol. I'll look it up.

These traps are running dry in less than a month, we suspect - the resident is 90 years old, and 2 hours away, so we want to provide an indicator that she should run the taps. I might get carried away on a phase 2 using an Arduino to log when it goes dry. Heck, I might even have it text me, lol.

I'll post v03 soon. I too noticed the attachment problem, so I just shared the file from OneDrive as "anyone with the link can read," and linked it in.

I'm feeling the rust, lol - thanks for helping me scrape at it.


 

I edit my posts to fix typos, correct grammar, or improve clarity. On-screen keyboards are evil.


   
ReplyQuote
 Biny
(@binaryrhyme)
Member
Joined: 2 years ago
Posts: 269
Topic starter  

@davee Here's Water Probe v03

 

I edit my posts to fix typos, correct grammar, or improve clarity. On-screen keyboards are evil.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2535
 
Posted by: @binaryrhyme

My Mom-in-Law has a guest room tub that we suspect regularly goes dry via evaporation, allowing sewer gases to come in to the house. That's the theory, anyway - and the mitigation strategy thus far has been to run the taps periodically. I'm building a water probe that will have a simple UI - red if there is no water in the trap, and green if there is, that will be powered by USB or a power brick - no microprocessor required.

Wouldn't it be easier just to put the plug in the sink ? That'd stop the evaporation and plug the hole to prevent escape of any sewage gasses.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
 Biny
(@binaryrhyme)
Member
Joined: 2 years ago
Posts: 269
Topic starter  

@will There's some dinkum thinkin' 😉 It's a tub / shower, and the evaporation can't be halted, as it evaporates on both sides of the trap, even with an airtight seal... but that would slow things, potentially.

I'll check on that with the for-real engineer (my better half), who has been researching the plumbing end, and knows more about plumbing and venting issues now than I thought existed, lol.

I edit my posts to fix typos, correct grammar, or improve clarity. On-screen keyboards are evil.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2535
 

@binaryrhyme 

Yeah, for a tub you'd probably have to tape over the tub's overflow opening too.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
 Biny
(@binaryrhyme)
Member
Joined: 2 years ago
Posts: 269
Topic starter  

@will The quick 2 min update from the smart one is that traps can be vacated if the venting is poorly designed due to air pressure issues as well. You run the washing machine and the trap gets sucked dry. And other stuff. News to me 😉 ... so the sensor is a stop gap while we figure out if things are done badly in the plumbing as well.

I edit my posts to fix typos, correct grammar, or improve clarity. On-screen keyboards are evil.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2535
 

@binaryrhyme 

Good luck with that 🙂

Anything seems possible when you don't know what you're talking about.


   
Biny reacted
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1697
 

Hi @binaryrhyme,

   Good luck with your circuit revisions .. hope you get something useful.

  If the 1980s was the last time you saw SPICE then it might have changed. I played a little with SPICE using Mentor Graphics 'front end' for schematic entry to netlist, and output plotting in the later 1980s for general circuit design, but poor component models tended to make the thing very unstable, usually failing to converge.

I think you might find LTspice, and maybe others, a completely different game.

And the plumbing research seems to be similar to my impression of how problems could arise ... hope you are successful.

Best wishes, Dave


   
ReplyQuote
 Biny
(@binaryrhyme)
Member
Joined: 2 years ago
Posts: 269
Topic starter  

@davee 

I added a third transistor to amplify the sensor signal, dropped the base resistors from 10K to 5K, and it now triggers correctly on resistance loads 80K ohms or lower, and is still ok with a shorted lead, giving me 20K of of headroom. Works fine with a glass of tap water. 

Will definitely kick Spice up, after I've wrestled Fusion 360 to the ground. 😉 I'll publish an updated design with analysis, and do a comparator version as well - which should be able to detect a lead short fault.

 

I edit my posts to fix typos, correct grammar, or improve clarity. On-screen keyboards are evil.


   
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1697
 

Hi @binaryrhyme

  I realise your circuits have moved on, but as Bill has kindly fixed the attachment facility, I thought I would take advantage to include the simulation diagram of the circuit changes I described previously. And as an introduction to LTspice, the 'schematic netlist' of the same circuit - the format is 'reminiscent', but not the same as the old Spice deck, but unlike the early Spice days of hand net listing,  you only have to draw the schematic to create it. Once you have LTspice installed, which is the usual free download and click affair, you should be able to open the small file and simulate the circuit.

Hope it proves informative.

Best wishes,

Dave

 

water probe01

   
Biny reacted
ReplyQuote
 Biny
(@binaryrhyme)
Member
Joined: 2 years ago
Posts: 269
Topic starter  

@davee Excellent. I shall have at it this weekend while I await the arrival of the protoboard and case components - and new solder, lol.

I edit my posts to fix typos, correct grammar, or improve clarity. On-screen keyboards are evil.


   
ReplyQuote
Page 1 / 3