# Water detector with a BC547 and help understanding transistors

I have set up a basic water detection sensor using a BC547 transistor to switch on an LED if there is current between two electrodes (which are spaced about 1 cm apart):

I'm trying to understand more about how transistors work. I have some questions which I would appreciate help with:

1. The 4.7k resistor is a failsafe in case the electrodes touch each other and send too much current through the transistor and destroying it. I've made this mistake already. If the electrodes touch, with the 4.7k resistor in place, only 1.9 mA will pass to the base. How do I know how much current is too much for the base? I've looked at this spec but I don't see a specification for this. Is it the same as the max collector current (100 mA)?

2. If I replace the 4.7k resistor with 1M ohm then the LED burns very dim. How is this happening? Surely the switch is only on and off.

3. It seems that my tap water provides a resistance of roughly 500k ohms. This means that as little as 18 uA of current is going to the transistor's base, which does indeed switch it on. What current would be too small to work and how would I calculate this number?

4. The BC547 spec says the max emitter-base voltage is 6 V. Does this mean I need to drop the voltage along this line? Should I plug in a couple of diodes?

Any other points or suggestions would be appreciated!

• Have you tried 18K resistor at base? Commented Mar 28, 2021 at 15:51
• Figure 4 in data sheet implies max base current is 30 mA. Too many questions raised though and it would take too long to get you up to speed on how BJTs work for you to recognize a good answer. BJTs are not black and white. Commented Mar 28, 2021 at 15:55
• Transistors aren't just switches. They're amplifiers. Commented Mar 28, 2021 at 16:02
• Dave, I've designed and tested a two BJT circuit that makes the detection and includes hysteresis (which I think is important.) But it involves MegOhm resistors because of the high impedance of water. You can also buy very nice, very sensitive units designed to sit next to a toilet and generate an alarm when moisture occurs. They are also VERY cheap. Is this something you want to make?
– jonk
Commented Mar 28, 2021 at 18:45
• @jonk: please supply a reference to these if you have :) Commented Mar 29, 2021 at 14:00

1.The 4.7k resistor is a failsafe in case the electrodes touch each other and send too much current through the transistor and destroying it. I've made this mistake already. If the electrodes touch, with the 4.7k resistor in place, only 1.9 mA will pass to the base. How do I know how much current is too much for the base? I've looked at this spec but I don't see a specification for this. Is it the same as the max collector current (100 mA)?

There isn't a good answer to your question. The manufacturer has not addressed the issue of driving so much base current through the transistor that it kills the transistor. At a guess, 100 ma would seem a reasonable starting point, although reducing that wouldn't be a bad idea.

2. If I replace the 4.7k resistor with 1M ohm then the LED burns very dim. How is this happening? Surely the switch is only on and off.

Surely not. As long as the collector-emitter voltage is greater than about 1 volt (and the emitter current is within bounds) a transistor acts as a current amplifier, with the collector current being more-or-less proportional to the base current. Look at the data sheet and see "current gain". Also keep in mind that gain varies with current, and in particular drops as current increases past the specified values. It also decreases with decreasing current, too.

Once you get into the situation that Vce is less than about a volt, the gain of the transistor is fairly low. Note that the rating for Vce(sat), the saturation voltage, is specified at a gain of 20. Once you get into this range, small changes in base current have almost no effect on output voltage, and you can use the transistor as a switch.

3. It seems that my tap water provides a resistance of roughly 500k ohms. This means that as little as 18 uA of current is going to the transistor's base, which does indeed switch it on. What current would be too small to work and how would I calculate this number?

That requires a little thought in defining exactly what you mean. What, exactly, does "switch it on" mean? Let's assume that "on" means 2 mA through the LED, AND that it's a white LED. Then it will have voltage drop of about 3 volts. 2 mA through the 1k resistor will produce a 2 volt drop. So Vce on the transistor will be 9 - 2 - 3 volts, or 4 volts.

2 mA of collector current and 4 V of collector current are almost exactly where the gain of the transistor is specified, and you'll notice that the minimum value is listed as 110. So the base current to do this will be 2 mA / 110, or about 18 uA.

Of course, as I mentioned, you need to think carefully about exactly what "switch on" means. If the LED gets 1 mA, and is a little dimmer, is that "on"?

4. The BC547 spec says the max emitter-base voltage is 6 V. Does this mean I need to drop the voltage along this line? Should I plug in a couple of diodes?

Nope, you need to think about exactly what the spec is saying. Note that it is the emitter-base voltage, not the base-emitter voltage. It's referring to the reverse voltage you can apply to the emitter-base pair, rather than the forward voltage, which will be limited to about 0.7 volts by the diode action of the junction. Unless you plan to reverse the power leads on your circuit, you don't need to worry about it.

• 100 mA into the base feels like a lot for such a small transistor. I tend to use a few times the base current that would drive $I_{C,max}$ (here, Ib = 5 mA for Ic = 500 mA, roughly, with the minimum spec β) as a rule of thumb for something not to exceed, so I'd try not to go beyond about 20 mA. Commented Mar 28, 2021 at 17:21
• Thanks for the thorough response. Very helpful. I've misunderstood how the BJT acts as an amplifier. Commented Mar 29, 2021 at 18:03

Your setup seems good to me.

1. The 4k7 is base protection as you mention, put 1.9mA maximum to the base is safe.
2. 1M in base pass too little current to transistor fully open(you have to count with another 500k water resistance). Using high Beta BC547C it could work.
3. If you want open transistor to pass 6mA, then you need base current at least 6mA/Beta , so for Beta = 200 you need about 30uA.
4. The 6V is a maximum BE reverse voltage and you don`t have to care about it in this case.