It works great. I used a 1M resistor. However, it is really sensitive to my hand near it, etc... I also understand temperature could skew the reading. I did it just like the instructable, used two tin foil strips, running up the side of a plastic bottle (across from each other). Soldered wire to each strip. One to ground and the other to DI2. Then I ran the 1M resistor from DI2 to DI3. I used the capSense code I found here. One thing I am going to do is switch to copper tape instead of the foil. However, to make it more robust (filter out noise and smooth the readings, handle temperature) I have the following thoughts. Can somebody provide their opinions or feedback on these thoughts? Thanks!
Since temperature could change the result, I was wondering if a temperature sensor was implemented, could this keep it calibrated? I assume the liquid temperature would be most important. I was thinking a temperature sensor attached to the water bottle at the lowest point.
Would shielded cable would work better. Would you put the shield to the ground piece of foil and the center wire to the other foil (sense)? I did notice that the results we jumpy and that my hand would throw it off. I wonder if the shielded cable would help the result be more consistent and prevent the noise (from my hand).
I see in the image of the instructable of the water bottle that the wire is soldered to the foil and then wrapped around the bottle a few times. It also appears that the lead back is also twisted. I wonder if these are important steps? Would they help with the noise? Would they be required if you are using shielded wire?
I also saw another writeup on this method and it mentions using an insulator over the foil and then another layer all the way around that is a ground plane.
The short answer is "Yes" to all of your questions. The effectiveness however is dependent on the situation. I would experiment and find out. Temperature will require additional calibration work. Shielding the system may swamp the capacitance, so you'll have to be careful. Twisting your wires usually tends to more help from radiating noise rather than containing it, and maintain a more consistent capacitance across the length of the cable (But it will add capacitance). Shielding the cable will reduce induced capacitance and other picked up noise, but again increase capacitance. I don't know the tolerances for this particular application, but it sounds small. Doing each of these may reduce noise, but also lower the overall range of measurement or otherwise inconveniently skew the results.
Here is a discussion of an alternative capacitative liquid level sensor, which uses a DIY coaxial capacitor. If the outer tube is grounded, that would eliminate proximity effects (like a nearby hand) : DIY Capacitive fuel sensor question - Sensors - Arduino Forum
Thank you for the replies so far, very interesting comments!
I guess I should have explained what my application is better. I have a large tank, 50 gallons. I want the level of the liquid in the tank. There are alot of options to do that as I am sure you all know. However, I have two requirements that have limited my options significantly. First, the tank itself is metal. Second, the liquid inside (water) can be heated and therefore, vary in temperature. Let's say for the sake of argument that the water could go from room temperature to 160+ degrees. I cannot use alot of sensors due to the tank being metal and others because of the possible temperature of the water.
There is however, a sight glass on the tank where you could get a visual of the tank level. Using this approach, I could easily line the sight glass with copper tape and read the level in the sight glass (which is the same as the tank) using capacitance. The level will change rapidly only when filling or draining the tank, otherwise, I am just looking for evaporation. If I deal with the temperature offset using a temperature sensor, then I am all set.
So, I was just looking for some best practices on how to set this all up on the sight glass (as far as using shielded cable, etc...). I like the cylindrical capacitor. I am assuming that would actually be submerged in the liquid? Then I would use two copper pipes, one inside of the other, ground the outer one and I would be good. The only challenge with that approach is how to keep the inner and outer pipes from touching each other, along the span. Given my amount of fluid/tank size, I need to sense about 30" as my tank is just under 30" tall.
The cylindrical capacitor is necessarily immersed in the fluid, situated so that the fluid level inside the capacitor is the same as the fluid level outside. It works if the dielectric constant of the fluid is different than whatever else would be in the space between the cylinders (like air, which has dielectric constant of 1). For fuel, the dielectric constant is around 2 to 4 depending on oxygen content.
If the cylinder were constructed from two pieces of bare conductive pipe, this approach may not work well for water unless it is very pure. Ionic contaminants make water conductive. In case of contaminants you could put a sheath of nonconductive plastic over the inner electrode, as long as you leave space between the outer electrode and the sheath for water to fill in. The inner electrode would have to be completely sealed so that contaminated water could not get between the nonconductive sheath and connect the inner and outer electrodes with a conductive path.
You are right to be worried about the temperature. The capacitance of a water sensor would depend strongly on temperature, because the dielectric constant of water does so and changes from about 88 at 0 degrees C to 55 at 100 C. If you can somehow use the sight glass, e.g. apply foil electrodes on either side of it, that seems like the easiest approach to construction, but temperature compensation would still be an issue.
I use Omega pressure sensors to determine the level (amount) of water in tanks. Water pressure changes by 0.434 psi/foot of head, and changes of a fraction of an inch are easily detectable.
jremington, thank you so much for the great replies and suggestions. I have one more question/comment. I am glad you brought up the pressure sensor! It was the approach that was in a close second place and I have been researching this solution. However, I cannot get past two issues regarding the pressure sensor. First, my tank is not sealed completely so I could not measure pressure from the top of the tank. HOWEVER, the sightglass is sealed. I could grab pressure from the top of that. As liquid comes in from the bottom of the sightglass, the headspace above would pressurize. Then the question with that is, does it work the same if the sightglass is only 3/4" diameter? I am sure it does. But, second issue, I read somewhere that as the liquid is draining back out, there is a vacuum that is created and this throws off the pressure sensor. Maybe temperature also has to do with this. Some people are talking about venting to equalize the vacuum or even using a pump to pump air in??? I don't want to use this approach if I need to supply a pump. Here is where I read about this at first, these people are using it for beer brewing: https://www.oscsys.com/projects/brewtroller/system-design/volume-measurement
They got around the issue of the pots not being sealed by adding a tube (stainless I assume) into the liquid and then reading from that. I can do that too. However, I am concerned about the vacuum issue and don't want to add an aquarium pump as they did. They sensor they are using from Freescale has a pressure and a vacuum port. I am wondering if they are just missing something and don't really need the pump. If so, I would like to research this method.
I can also look at the sensor you suggested. I will do that. But, what are your thoughts or comments on the above issues? Especially given your experience with those pressure sensors?
I don't quite understand the problem with partial vacuum, or why you want to measure from the top of the tank. If the tank is not sealed, isn't the liquid surface at atmospheric pressure? If not, could you make an opening so that it is? Then you can measure the liquid pressure from the bottom of the tank (i.e. tap into the tank itself or an outlet pipe). The sensors I use (PX-309 from Omega) measure pressure relative to atmospheric pressure and are extremely accurate at measuring the head or volume (+/- 1 gallon precision in a 3000 gallon tank).
Alternatively there are pressure sensors that are sealed and submersible, so you just drop the line into the tank so that the sensor rests on the bottom. Those are absolute, that is they measure the pressure relative to a (possibly partial) vacuum. They are quite expensive.
Whilst the solution to interference from your hand is shielding, you do not want to use shielded cable as it has a high capacitance in itself which will tend to dilute that you are sensing. In fact any length between the sensor and the electronics is to be avoided, you really need to mount the Arduino (or a buffer device such as a 74HC14) on (or very near to) the pickup itself. If you must use a length of shielded cable, you should use something with a low capacitance such as Heliax or something constructed to resemble it. Twisted wire also increases the capacitance and has negligible shielding effect (twisting is only useful where the data being transferred is already balanced).
It certainly is the case that you need to use the earth electrode to shield the sensing electrode itself. That is why the concentric design is preferable. If you had the sensor submerged in the liquid, it could consist of a fully insulated rod concentric with a tubular earth electrode which does not need to be insulated (except to avoid electrolytic effects, but can be the same material as the tank). You hold the sensor central to the sleeve with rings of insulating material such as acrylic, perforated with sufficient holes to allow free water flow. In fact, the outer sleeve can be perforated - or even mesh.
Pressure sensors used in washing machines and dishwashers use a tube running from the bottom of the tank, up past and to above the tank to the dry sensor. As water fills, it starts to fill the tube, compressing the air so that the resultant pressure represents the difference between the water level in the container and that in the tube. This is probably unsuitable for your application because there will be a tendency for the air to dissolve in the water over time (days).