| The Free Site | vBuddy - make friends, share photos, blogs, have fun | Cheap Web Hosting - starting at $5 |
Radio link for measuring water levels in a tank
This webpage describes how to build a pressure sensor and RF data link. The tank level receiver can be used to control a pump and display the level. This circuit uses single chip Picaxe microcontrollers.

View of tanks on top of a hill, out of sight of the pump shed. How do we know they are full?

Transmitter module. The pressure guage is a medical sphygmomanometer and is invaluable for calibrating and testing. But water in a pipe will work fine too. Pressures in a tank are 2-3 metres of water. 1 metre of water is 0.1 atmospheres, 1.4psi and 76mm of mercury. The board to the right of the guage contains a picaxe chip and a 324 op amp. This is connected via the white cable to the tiny RF transmitter module. This wire would normally be longer as the electronics are down near the ground and the RF module up on a pole. Antenna is 17cm of wire for 433Mhz. Yagi's can be used to extend the range.

Closeup of the transmitter electronics.

Closeup solder side. The tiny module at the top left hand corner is the pressure transducer Honeywell 24PC05SMT available from Farnell for about $24 Australian dollars. They are also available in Europe from SensorTechnics. The connector is a barbed 4mm irrigation part glued onto the sensor port with epoxy resin. It is important not to get resin up the port hole, so put the glue on the outside of the port, then slide the barbed fitting over it.


Schematic. Note that the numbers next to the picaxe chips 08 and 08M are the actual leg numbers. Picaxe chips usually use a convention of naming legs as pins - eg pin0 is output 0 which is physical leg 7. RF modules are generic 433Mhz modules. These ones came from Jaycar and draw about 10mA. Thus it is possible to turn the transmitter on directly from the picaxe chip. This transmitter runs on 3V, so a red led is used to drop 1.7V from 5V. Other modules may run on 5V. If the module uses more than 10mA or runs on a different voltage - eg 12V, then turn it on with a relay driven by the picaxe. The module only needs to turn on intermittently.
The receiver schemtic is a generic idea, and shows how the output can be converted into an analogue voltage for display on a meter, or a led can turn on when the tank is full. It is easy to use the picaxe outputs to turn on pumps automatically using a transistor to drive a relay to drive a contactor. I send the data into a PC and the PC turns the pumps on and off as this enables me to only pump using off-peak electricity, but the reciever could control the pump directly.

The receiver board.

How to connect 4mm pipes to big pipe fittings. The clear plastic tube goes up the side of the tank and also gives a visual indication of level. These pipes go together with 4mm barbed connectors and it is easy to use a T piece to go off to the sensor. The barbs were cut off one side with a knife and pushed into an appropriate sized hole drilled in the blank plug. In this case it fit perfectly and did not leak. Any leaks can be sealed with silcone, epoxy resin or by melting the two plastic parts together with a soldering iron.

Power comes from a solar panel and this charges an old car battery. Current is 50mA in full sun and the circuit uses about 10mA. A ratio of 5:1 is about right given that there is no solar energy available on cloudy days or at night. All sorts of fancy overcharge circuits can be built using picaxes, but given that old car batteries are free and last at least 5 years in this application, they probably are the best option. Alternatively 7-8 NiMH AA cells can be used. Overcharging NiMH batteries just makes heat, and NiMH batteries don't have a memory effect like Nicads.
Picaxe code for transmitter
' RF Tank Pressure Transmitter
' Circuit = 24PC05SMT Farnell (24PC = honeywell series, 05=5 PSI, SMT = Surface mount)
$24.03
' Pin 1 to 5V
' pin 4 to earth
' if use the lower port then pin 4 = positive side of differential amp and pin 2 =
negative
' pin 2 to op amp buffer (324) 1
' pin 4 to op amp buffer (324) 2
' 324 differential amp x33 ie 100k op amp buffer 1 to negative
' 3M3 negative to output
' 100k from op amp buffer 2 to positive
' positive to 3M3 then to 1.6V reference
' 1.3 V reference is a 27k/10k divider through op amp buffer (4)
' output of differential amp into 08M pin 2
' input voltage measurement is a 20k/10k divider on the input voltage into 08M pin 1
' 08M pin0 = output to RF module
' 08M pin4 = power to RF module (via red led drops 1.7V so RF module gets 3V3) - maybe
omit this component
main: high 4' turn on RF module
pause 1000
readadc 1,b1' input volts where 128= 7.5V and 255 = 15V
readadc 2,b2' pressure (1.31V = 0, 2.42V = 152mmHg = 2 metres of head = 0.2 atmospheres
serout 0,T1200,(85,85,85,85,85,"Tank",85,85,85,b1,85,b2)
pause 1000
low 4' turn off RF module
pause 3000
goto main
Note the 85's in the serout - these are a 01010101 and because there a quite a few of them the number of 0's and 1's is similar in the whole packet. There are more definite ways of doing this with Manchester coding, but for this application with only a few bytes the 85 solution works fine. This code also measures the battery voltage and it is useful to see what that is. I put the battery voltage on a 24 hour display on a PC, and as the battery dies it is possible to see the volts falling rapidly at night. The transmitter circuit could do more clever things with the battery voltage information - eg disconnect the solar panel when the batteries are charged.
Code for Receiver.
' RF tank receiver
' 433 module to 08
main:serin 1,T1200,("Tank"),b0,b0,b0,b1,b0,b2
' b1 = battery voltage
' b2 = tank level
' callibration = 65 = zero and 125 = 2 metres
let b3=b2-65' subtract offset
let b3=b3*2' multiply
' send an analogue output
for b4=1 to 4
pwm 2,b3,255 ' see pwm command. Using a 10k/33uF into 324 buffer Max
324 output = 3.9V
next
' light a led if overfull (or could turn on a pump if low and turn off when gets full
if b3>128 then
high 0
else
low 0
endif
' calibration - 2.4V output = 2 mtres, 1.2V = 1 metre.
high 4
pause 1000' flash led to acknowledge data received
low 4
' serout to PC
' debug
goto main
This code shows some simple maths to create an analogue output and turn an output high when conditions are met.
This circuit can interface with pumps of any size.

Two vertical Calpeda pumps with three phase motors. Pump capacity is 1
litre per second at 10 atmospheres (100psi).

Inside the control box. Anything that uses more than a few amps at 240V ought to be built and signed off by an electrician. I asked the electrican to build a box and to give me control wires that turned on with 12VDC. He put 12V relays inside the box. I turn on these relays with a computer and hence there is isolation between the computer and the high power electrical components. This box has two 3phase contactors. On the front are two 3 position switches - Off, On and Auto. The white stuff on the bottom of the box is ant killer - ants love to find their way into warm boxes like these. This box also has circuit breakers, overload cutouts and earth leakage circuit breakers. Ok, that sort of thing costs but it could well save a pump or a life.
Finally, why go wireless? Well one reason in our part of the world (Australia) is that the wildlife love chewing on wires. Kangaroos koalas and various birds are the main culprits. Koalas are not always just cute and cuddly. Here are a couple of koalas fighting outside the pumpshed.






Having said that, it is possible to send data down wires as well, eg the fence wires in the foreground of the pictures above. Solder onto the steel wires using zinc chloride flux. Or use plastic coated steel wire. Or put some wire inside 13mm garden pipe (use compressed air to blow 60 metres of string down a pipe then use the string to pull the wire through).
Sending data down wires
Sometimes RF data won't get there. Or sometimes need several systems all working in parallel. The following schematics describe data comms using one or two wires. This is for long distance and assumes the wires are picking up all sorts of interference such as from nearby power lines. Exposed wires can also pick up considerable volts during storms and if the wire is exposed, even a fence line, it may be worth grounding them with 10k resistors as well. My experience with long distance comms is that invariably something goes wrong somewhere along the wire, so the data rate needs to be very slow to help debug things. This system can be debugged using a torch globe. The 10 ohm resistor limiting current onto the comms wire may not be absolutely necessary, but it does help save the transmitter if there is a dead short. The earths need to be fairly good - this may even entail watering the ground round the earth stake in summer.

Circuit 1 - comms using one wire.

Circuit 2 using two wires.
Picaxe code for the above two circuits. Sends 4 bytes, then two checksum bytes. This code was written before the new picaxe codes with if/endif came out, and probably can be optimised.
'Slow serial transmitter. Sends about 1 byte every 2 seconds.
Useful for slow reliable transmission usnig relays
' This code sends 4 bytes, then a checksum of two bytes
' Also - Bonus compared with Serin - this code has a timeout!
SlowSerialOut:let b8=b1
gosub sendloop
let b8=b2
gosub sendloop
let b8=b3
gosub sendloop
let b8=b4
gosub sendloop
let w6=b1+b2+b3+b4
let b8=b12
gosub sendloop' checksum
let b8=b13
gosub sendloop' checksum
return
sendloop:' pass b8 uses b9 b10
' pin 2 is blue led pin 6 is relay - may not need led on pin2
high 2
high 6
pause 200' start pulse
low 2
low 6
let b9=128' decrement amount to add
for b10=1 to 8
if b8 >= b9 then outhigh
if b8 < b9 then outlow
bytereturn:b9=b9/2
pause 200' 200 milliseconds
next b10
low 2
low 6
pause 1000' pause to resynch
return
outhigh:high 2
high 6
let b8=b8-b9
goto bytereturn
outlow:low 2
low 6
goto bytereturn
' Slow serial receiver goes with code above
main:if pin3=1 then goto startdecode
goto main
startdecode:gosub decodebyte
let b5=b2
gosub decodebyte
let b6=b2
gosub decodebyte
let b7=b2
gosub decodebyte
let b8=b2
gosub decodebyte'checksum
let b10=b2
gosub decodebyte'checksum
sendbyte: let b11=b2' jumps to here if times out on last byte
' now have data in b5-b8 and checksum in b10
and b11
' do whatever with these, eg serout to
somewhere else
' or check that checksum adds up
' in this example this picaxe just sends it to a PC as-is and PC does checksum
serout
2,N1200,("Data",b5,b6,b7,b8,b110,b11)
goto main
decodebyte: pause 300' wait for start pulse then sense in middle of next
pulse
high 1
let b2=0
let b3=128
for b4=1 to 8
if pin3=0 then goto skiphigh
let b2=b2+b3
skiphigh: let b3=b3/2
pause 200
next b4
low 1
' input will be low by now as pausing
' now have value in b2
pause 200' to make sure is low
let b0=250
decodecount:pause 10
if pin3=1 then goto decodereturn' jump out of delay loop
let b0=b0-1
if b0>10 then goto decodecount
goto sendbyte' either times out or gets to here after last byte
decodereturn:return
Update January 2008
The above has been turned into a proper PCB with an LCD display to show the actual pressure:


Any further questions please send me an email moxhamj (at) internode.on.net
Dr James Moxham, Adelaide, Australia