# Help with circuit - why does this work?

Hello,
I'm implementing this schematic:

It's from here

I'm trying to figure out why this works such that when the bottom level probe and a sensor probe are both in the water, the associated pin will go low. For example, if there is a decent amount of water in the tank, PIN 8 will read LOW. My understanding is when there is water, a small current should flow to the base, and a an amplified current will flow from the collector to the emitter. Why does this prevent current from flowing from the +5V pin through the 470 Ohm resistor and into pin 8? Is this because pin 8 has some resistance after it (on the arduino board), and the current will prefer to short to ground through the transistor?

thanks

You got it right: the current "prefers" to flow to ground through the transistor. Almost NO current flows into the pin because it has a very high resistance.
Viewed another way: the current through the transistor produces a large voltage drop over the 470 Ohm resistor, so at the "bottom" side of the resistor there is not much voltage left.
Yet another view: the resistor and the transistor form a voltage divider where the lower part (the transistor) is of variable resistance. When conducting the transistor has a low resistance hence leading to a low voltage at the middle point of the divider

The Arduino can detect a voltage without a current going into the pin. It is almost as if the Arduino smells the voltage at the pin without touching it. That high is the input resistance of an Arduino.

I don't care of the circuit works, I don't like it :o
A current is going through the water, that will cause a little electrolysis on the probes (the metal pins in the water). After a long time those probes will get corroded and will not work well anymore.

Current is "lazy" . It will rather go through the easy way. You could add a resistor before the transistor to allow more current to flow both ways

Yeah - the electrolytic corrosion will be a problem here. The negative side is fine - the electrical potential is actually going to prevent it from corroding - but on the positive side, you can't use a non-noble metal. Carbon holds up well, and of course, platinum or gold are excellent.

But yeah, I hate that design too, I wouldn't do it. I wonder if you could make a capacitive touch/proximity sensor detect the water level through the side of the container. I bet you could.

Or a cheap ultrasonic distance sensor.

Not sure how deep the tank is but I would use one of these:-

One other thing to keep in mind with the level sensors that rely on conduction (as the original diagram shows) - people think of water as a conductor. In reality, it is a very poor conductor - it is the impurities in it that make it conduct. If you fill that with distilled water, it probably will not read it.

OK, makes sense. I wasn't sure if the pins had high internal resistance or not.

Yes, there is a problem with corrosion. The idea is to have this in my small water tank for my espresso machine. There is no room for a float or ultrasound sensor without me starting to hack into plastic parts of the enclosure. I was thinking I could turn on the sensor for 5 seconds every now and then to check the water level. The manual way of checking water level is to move the espresso machine and lift out the water tank.

Anyways, this is mostly for fun and learning. I'll keep looking at captive sensors, and maybe consider designing a top port to accept an ultrasound sensor, although I'm guessing humidity won't be kind.

cheers

Capacitive sensors are the best when you want to put something in the water.
This is a very nice painted (for isolation) capacitive sensor : - YouTube

At the moment I am using alternating sensing voltage with copper/nickel strips. That is not capacitive, but measuring the conductivity. I use three Arduino pins. Two for the alternating voltage, one to measure.

There is another way of sensing water level you might want to check out - basically, you use a clear plastic rod with the end cut with two 45 degree bevels polished (looks like a wedge) and you have an led/opto sensor at the top. The LED sends light down the rod - when in air, the two surfaces reflect the light back up again while in water (or other liquid), the two faces don't reflect so there is no signal back again. I have not played with them, but I have seen the design before. That method does not have any conductors or anything in the liquid.

Koepel:
Capacitive sensors are the best when you want to put something in the water.
This is a very nice painted (for isolation) capacitive sensor : - YouTube

At the moment I am using alternating sensing voltage with copper/nickel strips. That is not capacitive, but measuring the conductivity. I use three Arduino pins. Two for the alternating voltage, one to measure.

That dfrobot product looks interesting. Any idea on how it is sensing water level?

There is another way of sensing water level you might want to check out - basically, you use a clear plastic rod with the end cut with two 45 degree bevels polished (looks like a wedge) and you have an led/opto sensor at the top. The LED sends light down the rod - when in air, the two surfaces reflect the light back up again while in water (or other liquid), the two faces don't reflect so there is no signal back again. I have not played with them, but I have seen the design before. That method does not have any conductors or anything in the liquid.

The circuit I'm building is hitting a roadblock. I had most everything on the prototype board and it was working and then I added the LED warning lights and now it always reads empty. Super frustrating.

Adding the LED's should not affect the rest of the circuit unless there is a wiring error. One issue I do see as a potential problem - it is configured so if only the bottom one is in the water then it is "LOW" - the problem is that if the water drops below the bottom one, none of them will turn on - the software in the sketch should be configured such that if none of them are turning on it gives a warning. As far as the LED's go, try disconnecting one at a time and see if it is just one of them causing the problem or if they all are. There is also a potential problem depending on exactly how the probe coming from the supply through the 22k resistor is set up. Those are bipolar transistors and the way they are configured, the base can only be pulled up to about 0,7 volts and the transistor turns ON due to the current through the base emitter junction. If the water in the tank is very conductive or the "supply" probe is not placed right, the other transistors my not get enough current through them to turn on. Something to consider. I think I would have used FET's (although if I show my age, I would have used vacuum tubes with the sensors connected to the grids of dual triodes ... )

Capacitive. You can measure it simply by taking two wires and placing them in the tank.

I must have screwed up something with my nano...
The ATmega chip got really hot for a while. Now my arduino IDE doesn't see the board at all. Maybe I shorted something on it. This is quite the frustrating experience.

Yes, you may have let the magic smoke out A chip like that getting "really hot" is not a good sign.

bcphysics:
I must have screwed up something with my nano...
The ATmega chip got really hot for a while. Now my arduino IDE doesn't see the board at all. Maybe I shorted something on it. This is quite the frustrating experience.

You need to change the thread title to "why DID this work"....

The frustration is all part of the fun.

Hi,
When you added the LED did you use a series current limit resistor?

Tom...

TomGeorge:
Hi,
When you added the LED did you use a series current limit resistor?

Tom...

Yes I used a 150 Ohm resistor on each LED.
I also soldered a lead to the Vin on the arduino for a 9V battery strap. I'm guessing that I may have added too much solder and that it shorted with the gnd pin on the arduino. I checked connectivity between the two pins before powering up (they weren't electrically connected) but maybe it was intermittent. I don't know why this would cook the arduino though.

I'll pull out the arduino and put in a new nano.
What tests can I do with the multimeter to see that things are connected the way they are supposed to be connected? With the soldered board, measuring current isn't going to happen so I'll I can do is check resistance and voltage. I think what I really want to measure is the current feeding into the base of the transistors though. Maybe I should de-solder these as well and measure current there?