The following description is about a level meter for my storm water cistern,
a standing-cylinder-type storm water cistern with constant surface over
volume. The water surface area is 3 square meters and the height is 2 m resulting in
a capacity of 6000 liters.
In the actual firmware I also implemented different geometries but I
could not test them.
If you experience difficulties here please contact me.
For the component selection, not only perfect fit was the choice but also what was available in the treasury.
The following circuit was developed for level-metering of a storm water cistern. It is composed of two units, an ultrasonic distance meter mounted in the cistern (above the water) and a display connected to the sensor by wire.
On the Download-Page you can find all project files as well as some other things that might interest you (sorry, no ads!).
Some parts in the schematics are SMD-types (e.g. BC856), for the prototype I used the through-hole version (BC556) of course which will work just the same.
Before you start having fun with the circuit, please read the safety advice near the end of this page!
To build the software, you'll need the Atmel AVR-Studio (preferable version 6.1).
Also have a look at the photos of my very first prototype which may answer some questions
For the very first prototype I used an ATmega162 as the simplest device with two USARTs but the actual version uses an ATmega128 which has much more peripherals allowing more gimmicks at about the same costs. Probably the higher volume production here makes the price.
The sensor uses a relatively small controller ATtiny 2313. Therefore its firmware is kept in assembler code (we don't want to forget that completely, do we?). All calculations are made in the display which is programmed in 'C'. The sensor supply voltage is switched by the display unit. Energy consumption therefore is of secondary interest as it is only active when absolutely necessary.
This also means, the sensor cannot permanently store values in RAM. Everything it has to remember has to be stored in its eeprom. Fortunately until now it doesn't have to remember *anything*.
The display unit is built with an ATmega128 at 3.6864 MHz. I chose it because of its two USARTs, one to communicate with the sensor, the other to the PC or a possible home bus (RS485). As of version 2.0 a Bluetooth-module has been added. The baud rate is 9600 baud. This is more than enough to read the water level once per minute and would also be good for further tasks such as reading energy- or flow meters or switching lamps etc. but this is another story...
A boot loader has been implemented to be able to update the sensor firmware.
A note about power consumption:
We use a highly efficient switch mode regulator so the power consumption could be significantly reduced (compared to linear regulators à la 78xx). Reducing the controller supply voltage to 3.3 V could save a little more but the display used needs 5 V for proper operation. All in all the device would not exceed the magical 2 W-barrier of my Conrad-Energy-Meter.
Using another cheap energy meter (unfortunately truly reliable meters are not at my disposal), I measured the following values that seem to be plausible:
|Standby: Sensor off, no backlight||1.5 W|
|Measurement active, no backlight||2.0 W|
|100% backlight, Sensor off||2.9 W|
This makes about 13 kWh or €3,30 (at 25 Cent/kWh) per year, permanent backlight roughly doubles this value.
A pushbutton key is used to activate the backlight (a long keypress is used to toggle between permanent and acute backlight). Additionally it allows displaying values that are normally hidden.
A slight surprise might be the RS485-interfaces. If both transmitters are activated and drive 5 V into the terminated lines (120 Ω at each end), this makes 83 mA per line or about 0.8 W, nearly the power of the backlight.
If you have only short lines without or with only short branch lines you can omit termination. If in doubt, just try out... Please also see here.
For the efficiency of the switch mode regulator I measured 77% (with external DC supply of 15V and a load of 500 mA at 5 V). This is not an exceptional good value but for an aged out regulator without synchronous rectifier it is absolutely acceptable. Presuming 2 Watts of output power you would loose 0.6 W what is possible without additional cooling measures.
Initial tries in the lab showed that even small and smooth objects (like your arm, curtains or a yard stick) cause reflections that overwhelm objects more far away. The echo of your small finger 40 cm away is as real as the echo of the surface 3 m away and can hardly be distinguished.
So I was really impressed as I could observe the liters (!) go away while I used water from the cistern.
Time will show how objects in the cistern (hoses or climbing steps) will influence the measurements. Initial experiments make me luckily looking forward to...
Meanwhile it showed up that even the nearly empty cistern could be measured correctly.
Spiders. Spiders can be a problem. After one year of work, the display began showing
I discovered that the sensor had disappeared in a spider web of a meter of diameter. Even the cord I used to fix the sensor was torn on one place (with weird brown ends). A monster spider was sitting on the brim of the cistern. I'm no expert in facial expressions of spiders but I suppose it was some kind of sheepish smile, well, it could not tell me more...
Humidity is the next problem. Although the sensor still worked (so no humidity seems to have penetrated the case) it was completely wet (in September) and all iron screws were completely rusty. Rising humidity of the (relatively) warm cistern water is responsible for this. So use nylon or stainless steel for all parts exposed to the cistern atmosphere!
The receiver and transmitter parts didn't look like new but the still worked without problems and do so until now.
The display supply is 230 VAC. Completely disconnect the mains before you work on the device. Keep enough clearance in your Layout between primary and secondary circuits (at least 8 mm). If you decide for my PCBs I have already done that for you. For measurements on the circuit do not use mains supply but apply (15..30) VDC directly after the rectifier (via TP2/TP4).
The transformer is not short circuit proof. To comply with all regulations, the manufacturer of the transformer confirmed this, it must be fused both on the primary and secondary side. The value of the secondary fuse is printed on the transformer and has to be 250 mA time lag. Its purpose is to protect the transformer against overload conditions. For the primary fuse i chose 100 mA time lag. It protects the circuit against failure inside the transformer. Be sure to use a fuse with extinguishing filler for the primary side (ceramic tubes, filled with sand) since they can break much higher currents. A normal glass type fuse can only break 35 A (higher currents may cause arcing which will not extinguish and thus short the fuse) while the fuse with filler can break 1500 A. You must expect currents of a few hundred Amperes in case of a direct short circuit of the mains, although this seems pretty unlikely.
Simplified this means you can use and distribute the schematics and the software at will, for free or for money as long as you keep my copyright notice and make your changes visible in the documentation. You have to offer the schematics and sources as you use them for free.
The pictures of the formulas were created with latex2png
Where to buy
The parts I used are nothing very special and you can get them from various distributors, maybe not all from a single one. Shipping costs and extra charges for small quantities may exceed the value of the parts in some cases. I ordered many of the parts at Reichelt, the rest simply came from our stock.
My employer Bär Industrie-Elektronik GmbH kindly agreed to provide the raw PCBs or the populated and tested boards together with the cases. The display case will be finished so you do not have to cut the display cutout youself but the sensor case is raw. You'll still have to drill the holes for the Sensors and the cable feedthrough of the sensor-case. Here you can find the kit.
Please note, this is a hobby project. Warranty only covers the correct operation of the devices, not the usability for a special purpose.
I'm looking forward to feedback, constructive criticism and proposals for improvements. Please accept that I can only give support as long as my spare time allows.