Introduction: A Water Sensor for My Coffee

Picture of A Water Sensor for My Coffee

Sounds strange? Well, here's the background: A while ago I published an upgrade for my coffee machine. That still works a charm, but there was one nuisance left: when the water tank runs empty I have to refill, remove air from the hoses and pump and finalize my (now colder) coffee by hand. Adding an automatic refill from the tap was (and is) no option since I don't want my home flooded by a malfunctioning system. But having an alarm when the water is about to finish would really be nice.

So, how could this be accomplished? I found a number of ibles here which use a floater and a magnet to sense the water level. But I did not like that for several reasons. First, the water tank is made from Plexiglas and will cost a fortune if it needs to be replaced (in case mounting the float will not work as desired). Second, the float would likely be difficult to clean and having any micro-biotical farm in my water tank is nothing that makes my coffee tastier. And third, there must be a smarter way.

Step 1: Using Light - the Right Way

Picture of Using Light - the Right Way

While water is simply transparent for light and thus not suitable for a light barrier I still remembered my physics lesson from school that there is something called total reflection angle. You can see that if you look onto an even water surface. Looking from a perpendicular view you can easily see through the water towards the ground.

Step 2: Narrower ...

Picture of Narrower ...

When you use a lower angle the surface starts turning into a mirror. You can see a faint reflection of the spoon already.

Step 3: And Narrower

Picture of And Narrower

And at an angle of about 20 degrees you see more of the spoons reflection above than what you see of it in the water.

If you ever dived in a swimming pool with diving goggles, you know that this effect is much stronger from under water. There, if the pool is empty and there are almost no waves, you can see that the surface really looks like a mirror. Unfortunately my camera is not water proof. And my cup was not large enough to dive in. (The picture is a bit blurry since my camera is really old and it could not get a good focus this way.)

Step 4: The Perfect Angle

Picture of The Perfect Angle

Okay, a perfect angle is not needed, just a suitable one. I read about refraction index and found that it depends on a couple of factors. E.g. looking from (dense) water to (light) air results in a large factor which lets the mirror effect appear earlier as if looking the opposite way (air to water). Using those factors the angle could be calculated. But, as seen previously, you can simply use an empirical value. It turned out that 20 degrees had been a good choice.

The only thing to do is to make a sketch with a beam going upwards at 20 degrees, being reflected at the water surface and then again being reflected by a mirror at the rear. This way the placement of sender and receiver of the light beam can be calculated. Sender and receiver can be swapped at will since the beam will be reflected at the water level independent on the side from where it reached the surface (the incidence angle of radiation is the same on both sides).

Step 5: The Right Sensors

Picture of The Right Sensors

Rather than using visible light I took an IR LED (like for the sensor in my coffee machine that sensed the removal of the coffee filter). I did not have a photo transistor at hand, but found a cheap alternative in a TSOP4838 which are used in remote controls. I just had to create a 38 kHz pulse for the IR LED. You need to use an IR LED which emits light at the right frequency (about 950 nm wave length).

When the receiver detects such a light signal it switches a transistor with open collector output at its pin 2 which can be read by the micro-controller.

The rectangular pulse can further be used to tune the strength of the light beam. If it's too weak, the sensor will detect nothing at all. If it's too strong, it will signal all time as it receives diffusion light. Finally I set the pulse to every 26 microseconds and made the pulse width 3 microseconds.

Step 6: Housing the Sensor

Picture of Housing the Sensor

According to my measurements and the sketch I constructed a housing for sender and receiver. For that purpose I use OpenSCAD which lets you construct objects programmatically. The housing is split in a left and right half that were print on my 3D printer (which might be another story to tell, but it's not cheaper than other printers - just it's completely built by myself). The cylinders where the light goes through are clamped together with rings from an aluminum tube (remainders of my helicopter tail tube - just another story).

Step 7: And Glued in Place

Picture of And Glued in Place

The sensor needed to be mounted a bit offset from the wall since the water tank has a notch to that side. A little holder for the distance was easily printed and glued in place together with the sensor.

Step 8: Put Together

Picture of Put Together

Here you can see how the sensor is placed inside the housing of the coffee machine. The "mirror" is simply a tiny piece of aluminum foil fixed with transparent foil.

Step 9: Finally

Picture of Finally

I had to replace the ATtiny45 with an Arduino Nano since the extra sensor needed another input. And there was none left. I already constructed a circuit for an ATtiny13 working as co-processor with the ATtiny45, but I encountered a couple of issues with that. So I used an Arduino whose USB power supply was smoked during tests I performed for the new circuit. How lucky I was that the power supply anyway was coming from the coffee machine :-)

Ah - I forgot: the water level is measured when the coffee machine is powered one once. If a low level is detected, the pump is turned on twice for a short time. So that humming tells me: add water!

Since I constructed the sensor lighting from the lower water surface (remember the better mirror effect I explained?) the detected low level is relatively high. It would be nice to have a lower level since that would stretch the times between refills. So eventually I will try to see if I can use the sensor looking from top down instead of bottom up. That needs a couple more experiments. Luckily I got enough coffee for that.

Comments

About This Instructable

444views

7favorites

License:

Bio: I'm a retired IT consultant. Besides answering questions on StackOverflow I play around wth Atmels in various home projects. Recently I played a lot ... More »
More by ThomasK19:A Water Sensor for My CoffeeFlash CC3D With CleanFlightDigital Piano Notes Display
Add instructable to: