Skip to content

Es(Pi)resso Part IV: Fill Level Detection

I have to say I think this little modification is pretty cool. We can measure, using the Pi, the water level at any given moment, and update to the display accordingly.

Sure, you could just bend down and look at it. But where’s the fun in that? Best of all the components needed to service this modification are very cheap indeed.

Water level detectors conventionally sit in the water. Given we have to drink out of it, that would probably require ongoing maintenance and cleaning of the device. So we’re going to be using a non-contact option: an ultrasonic range detector. Namely the HC-SRC04.

They work by sending out an ultrasonic signals which will bounce off the water back to the device. The further the distance, the longer it takes to bounce back. Using some basic calculations we can then convert that measure of time into a distance. We can then calibrate the Pi to know the appropriate distance at ‘full’, ’empty’ (and probably a few other intervals for accuracy). That measurement will then be able to be ‘reflected’ on the display. Again, most of the software work is done for us, aside from the calibration.

The HC-SRC04 outputs at 5v, so we will need to do a level conversion to 3.3v for the safety of the Pi’s GPIO pins. But that shouldn’t be a problem. The first section of this blog deal with the hardware, and the second the software.

The Hardware

Version 1.0

I started off thinking of how best to affix the HC-SRC04 to the underside of the Classic, above the water tank. I originally got a small Hammond project box from eBay (50mm x 35mm x 15mm), drilled out a couple of holes, and figured I would just double-sided sticky tape it on. It was a very tight fit, and I had to remove the screw posts from the project box. Though it did squeeze in. But, the wiring would also have been exposed and visible from the underneath. Not ideal, thought I…

…In fairness, it wasn’t a bad job, though I would have had to glue down the project box cover. Cables could have been routed through the ‘gaps’ in the side of the Classic.

Anyway I thought I could do much better. I wasted the £2 delivered the project box cost, so you don’t have to…

Version 2.0

Bring on v2.0. I wanted something a bit more robust. So I got a larger Hammond project box (80mm x 40mm x 20mm) and drilled out some holes in the chassis of the Classic to fix it down at each corner of the project boxes (manufactured) screw holes. I added a third hole to route the wiring through directly to the inside of the machine. I had to remove the pump to do this. One of the holes situated under the pump, which I used for positioning, was pre-drilled and was perfectly sized for the project box screws. I didn’t make use of the project box lid in the end.

I used a 3mm drill bit for the screw holes in the chassis of the Classic, and a 16mm drill bit to drill out the holes in the project box to fit the ‘speakers’ of the HC-SRC04 through. The steel on the inside seems to be of a much lower grade than that of the outside: I had a much easier time getting through this time, than I did for the pressure sensor.

The amount of space in the 80mm x 40mm x 20mm box is probably a bit overkill, though its of no real consequence. 50mm (width) was too small to allow for screw holes. If you can find a box that is 65mm-70mm that will probably be perfectly sized, though your level conversion might have to be brought inside the Classic chassis.


Below you will see where I ended up drilling my screw holes, as indicated in red. It was quite awkward owing to the shape of the Classic, and took a fair bit of measuring. A compact drill will help massively. The left most screw hole was predrilled. The middle hole (this is an old picture: it is now much larger) was for cable routing. The hole on the right had to be measured and drilled.

Inside the Classic chassis, with screw holes indicated in red.

This way, the unit sits flush1Not entirely flush because of the approximately half a mm that the ‘pump mount’ adds to the lefthand most screw to the underside of the Classic. Because of the larger project box size, I’m also able to put the level conversion wiring inside the project box, rather than taking it further into the machine.

It just about fits with the water tank, with a small amount of breathing room! I wouldn’t want to take the water level above the prescribed ‘Maximum’ as it might flood the project box (!) 

All in all, however, I’m pretty pleased. There is a fair amount of height left in the project box so that the HC-SRC04 doesn’t touch the (metal) chassis, but I will in any event put a piece of electric tape on it for insulation once the soldering is complete. If it turns out to be more of an issue, once all the wiring is in place, I can always push the device further into the project box so that the ‘speakers’ protrude outwards.

It occurs to me that I might have to do that anyway when I connect it up to the Pi, as the proximity to the project box may well cause interference with my readings. I shall have to wait and run some tests.

Also, as things stand, I haven’t glued or otherwise fixed the device into the project box. With a 16mm hole, appropriately spaced, the friction alone is holding it in place. It requires a fair amount of force to move. Again. I may have to rethink that once the wiring is in and testing is done.

Looking good. Now to do the wiring.

The Wiring

To be continued…

The Software

To be continued…

Published inEs(Pi)resso

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *