CIRCUIT NOTEBOOK
Interesting circuit ideas which we have checked but not built and tested. Contributions will be paid for at
standard rates. All submissions should include full name, address & phone number.
A minimal WiFi water tank level gauge
This circuit is inspired by the WiFi
Water Tank Level Meter (February
2018; siliconchip.au/Article/10963)
and the PIC-based Water Tank Level
Meter (November 2007; siliconchip.
au/Series/46).
It uses the cheapest ultrasonic distance sensor module, the HC-SR04,
which consumes little power and
doesn’t need a preamplifier like other
kinds of distance sensors.
It also uses an inexpensive PIC microcontroller (a tiny 6-pin PIC10F322).
For the WiFi connectivity, a small
ESP-03 module does the job. It can be
used as a wired solution, giving measurements every two seconds, displayed by a terminal application. The
wireless solution provides a measurement once per minute, displayed on a
UDP monitor.
The PIC produces a 10μs high-level
pulse from its RA2 digital output to the
trigger input of the HC-SR04, which
starts the ranging procedure. The latter responds with a pulse from its echo
pin after a delay that’s proportional to
the roundtrip distance. With a typical
speed of sound of 344m/s at 20°C and
94
Silicon Chip
sea level, we get a gauge resolution of
17.2cm.
An optional temperature sensor
(MCP9700A) may be connected to
analog input AN0 (pin 1), to correct
the speed of sound as it varies with
temperature. The formula used is C
= 331.3m/s + 0.606Tm/s, where T is
in degrees Celsius, giving a negligible error of less than 0.2% for a 1°C
difference.
The PIC produces serial data from
its RA1 digital output by ‘bit banging’
(8N1, 57,600 baud) every two seconds
that includes the ambient temperature, battery voltage and distance to
the top of the water. If a wired solution is preferred, one can simply use
a TTL/USB cable between this prototype and a PC (with a terminal application like PuTTY).
If a wireless solution is preferred,
one can use the ESP-03 instead. It is
powered periodically for brief periods (to preserve the battery), then
put into deep sleep mode. I chose the
ESP-03 over the popular ESP-01 as
it is smaller and allows a direct link
between its RST and WAKE pins,
Australia's electronics magazine
which is necessary when using the
deepSleep function.
It uses a dynamic IP and issues UDP
broadcasts on port 6010. The periodic
statistics can be displayed with a PC
application (like Netcat) or an Android
application (like UDP Monitor).
With a 4000mAh LiPo cell, the prototype ran for 29 days, with the battery discharging from 4.2V to 3.5V.
Below 3.5V, the HC-SR04 module
gives false readings, but the ESP03
still works, as its 3.3V voltage regulator 3.3V is a low-dropout (LDO) type
(MCP1702-33).
For the distance sensor, I recommend using the waterproof JSN-SR04T
model. It is directly compatible with
the HC-SR04, with more options, and
will operate down to 3.3V, although it
is more expensive.
Both the PIC software (HEX file and
assembly language source code) and
Arduino sketch for the ESP-03 module can be downloaded from the Silicon Chip website at siliconchip.au/
Shop/6/268
Mohammed Salim Benabadji,
Oran, Algeria. ($90)
siliconchip.com.au