Wireless PICAXE-based water tank level sensor

[ad name=”posts-ad-1″]

Water level graph
Water level graph – February 11 2010

Over the last few months I have prototyped and built a water tank level sensor for my 9000L rain water tank.

The design is based entirely on Silicon Chip’s PIC-Based Water-Tank Level Meter, but instead of programming PICs, I prototyped using an arduino, and built the final version using PICAXE microcontrollers.

The sensor consists of two components, each housed separately and joined by shielded cable.

Pressure sensor

Pressure sensor
An MPX-2010DP silicon pressure sensor (temperature compensated and calibrated) is mounted inside a small project case, and screwed directly to the water outlet of the tank. Water from the tank enters in via a 12.5mm threaded nipple, which is reduced to 3mm plastic tube connected to the pressure sensor.

Pressure sensor fitted to tank outlet

Air remains in the 3mm plastic tube, and is pressurised by the water coming in from the tank. The more water in the tank, the more force that is placed on the air in the tube, increasing the pressure which is read by the second component of the sensor, the sensor circuitry.

Sensor circuitry
The sensor circuitry consists of a 1.5V to 5V voltage step up circuit, an instrumentation amplifier to read the pressure sensor, a PICAXE microcontroller to convert the analog signal from the pressure sensor to a digital reading, and a 433MHz RF transmitter to transmit the water level and battery voltage to a remote base station and computer.

Sensor circuitry

Apart from the use of an 18X PICAXE microcontroller, the circuit is essentially the same as the “Telemetry” version of the Silicon Chip project (schematic). I also left out the BCD switches as I only have one tank which negates the need for them, as well as the three-colour LED.

The 1.5V rechargeable battery is kept charged by a small solar panel.

Sensor circuit and solar panel

The transmitted water level and battery voltage is received and displayed on an indoor base station, as well as being received by another RF receiver and 08M PICAXE built on a breadboard and connected to a PC, which stores the level in a database for displaying the water level on the web.

Base station
Again, the design has been based on the Silicon Chip project and the third part of their article, however the circuit was something I put together with an 18X PICAXE. I also used a “white on black” backlit LCD display, and interfaced it to the PICAXE using this PICAXE LCD interfacing guide.

Base station

My base station does not have four buttons like Silicon Chip’s, however they were not required as I only plan on reading data from one tank, and have no need to control pumps.

PC interface
The simplest part of the whole project! An 08M PICAXE reads the incoming water level and cell voltage from an RF receiver, and transmits the values out over the PICAXE serial download cable for the PC to record. There is also an LED that flashes when data is received.

If you are wondering why I used PICAXE microcontrollers, I can explain in two brief sentences. The straight forward answer is because of their ease to program, compared to a PIC. The long winded answer is ‘evolution’ – I started this project using an arduino to read the pressure sensor, then I wanted to go wireless, then I realised an arduino was overkill for one ADC conversion, plus I don’t have a PIC programmer, etc, etc.

PICAXE sketches

References and related links

 

[ad name=”posts-prymont-v2″]

57 thoughts on “Wireless PICAXE-based water tank level sensor”

  1. Hi Murali – the MPX2010 pressure sensor is airtight, so there is always an air lock in the tube between the sensor and the connection to the tank.

  2. Hi
    Thanks for your quick reply. Would also like to ask you – by how much the 3mm tube from the sensor needs to extend into the Tee connector (in other words how much gap between the end of 3mm tube and water). Also, from the photo above, noticed that the box housing the sensor is at an angle – was this intentional?

    Planning to build this tank meter using PICAXE and Xbee.

    Appreciate your time :-).

  3. Hi Murali

    From memory, the piece of 3mm tube was about 10-12cm long. The tee from the tank is 1″, which is reduced to 1/2″, then down to 6mm then 3mm for the tube I think. The tee is only angled like that because the other outlet goes underground to the pump – i don’t think it would matter which way it was oriented.

    I will take a photo inside the sensor case and post for you.

    Cheers
    Kayne

  4. Hi Murali – I have added two more photos to the post, showing inside the sensor. There is a short piece of tube (2cm) going to an elbow, and then a lengthier piece (7-8cm) going to the sensor. The yellow around the elbow is a cable tie to hold the tube tight. You can also see the very small hole i drilled in the case, to the right of the cable grommet. This allows the air pressure inside the case to be equal with the air pressure outside, and the sensor can use this pressure to determine the pressure of water in the tank (which is being influenced by the air pressure outside).

    Cheers
    Kayne

  5. Hi Ebow

    I would be willing to build one for you – you would need to cover the costs of all the parts required. If you are interested I could but together a parts list.

    I would also modify the design I used, and use an arduino on the tank sensor side, rather than a PICAXE microcontroller, and power the sensor circuitry from mains power using a DC plug pack – hopefully you have mains power available near the tank (for a water pump probably)? I have found the single AA battery and solar panel to be a bit unreliable – I am forever swapping in a freshly charged AA.

  6. Hi

    I have been looking at this for quite another purpose, monitor cabin temp and battery voltage for my car, should be easy enough, but i also want to control a relay. Using transceivers it should be simple to have coms in both directions but how should the program for base station and the unit in the car look ? ie how is the relay on command detected and transmitted? getting the temp and volt from the car should be much the same as done in this nice project, i could even figure how to add status if the stuff the relay activates are running. what trouble my mind is how to get the relay control working, what i had in mind was adding a switch to the base station that puts a input logic high when activated, but then my brain left me stranded

  7. Hi,
    I am very interested in building this project as per your modification. I can’t believe you have developed it to interface with the PC – exactly what I have been looking for. Love the Silicon Chip design but didn’t want the coloured LED’s.
    I am an amateur at electronics but love building kits.
    My questions are-
    Would it be very expensive?
    Can I buy programmed chips?
    Are the circuit boards available?

    Looking forward to your reply.

    Yours sincerely, Brian.

  8. Hi,

    That this all looks great, except I’m a bit confused about the choice os pressure sensor.. As far as I know the MPX2010 will only measure up to 10kPa which only about 1M of water. Is your tank only very short? Otherwise how are you reading any level above 1 meter?

  9. Not sure on the exact specs of the sensor, but my tank is 2m tall, 2.5m (or there abouts) in diameter (9000L) and the sensor reads full to empty just fine.

  10. Thanks kayno.. I have since downloaded the Silicon Chip article, and this quote explains how it is done:

    “This sensor is specified for a 0-10kPa pressure range, with a maximum differential pressure of 75kPa. Using it above the 10kPa level degrades the linearity due to internal self-heating of the sensor. However, this limit is specified when running the sensor from a 10V supply. Since we are using a 5V supply, the self-heating will be considerably lower and so we can easily exert more pressure than 10kPa without loss of linearity.

    When connected to measure water level, each metre of water adds 9.8kPa of pressure to the sensor. Most water tanks are equal to or less than about 2.2m in height because they are designed to fill from the rainwater guttering of a house. This means that, for a 2.2m tank, the maximum pressure applied to the sensor will be about 22kPa maximum. This is well below the 75kPa maximum allowable for the sensor.

    The strain gauge element is temperature compensated within the sensor by connecting it in a balanced bridge arrangement and by laser trimming the elements during manufacture. In practice, the sensor is compensated over a 0-85°C range but can be operated from -40°C to +125°C.”

    Personally I am using an MPX5050 DP sensor that measures up to 50 kPa and outputs a 0 – 5 volt signal without the need for any external amplification, so it’s a bit simpler.. I’ll post a link when I’ve finished testing.

  11. Hi,

    Great project that I want to extend to my tank farm.

    I’m interested to know who sells the sensors.

    Chris: I like the simplicity of your approach using the MPV5050 sensor. Have you completed your testing?

  12. Hi Kayno,

    Looking to use your project to monitor a water tank a mile away from my house, do you have the schematic for the Base station and what are you using to generate the graph on your PC. Thanks

  13. @John I don’t have a schematic but it is pretty simple – a PICAXE 18X for the brains, an RF receiver connected to a digital input of the PICAXE to receive the signal, and an LCD character display connected to digital outputs of the PICAXE. See the third part of the PICAXE manual (page 30) for details on interfacing an LCD.

    The sketch for the PICAXE is at: http://kayno.net/wordpress/wp-content/uploads/2010/02/tank-receiver-lcd.txt.

    For graphing I’ve used RRD tool (http://www.mrtg.org/rrdtool/) and the Google Chart Tools (http://code.google.com/apis/visualization/interactive_charts.html)

  14. Hi – I am a bit confused as to how the water side of the sensor is handled. Does water come into contact with the sensor at all ?

  15. Hello I am interested in your work and I would like to make him(it) if authorizes me to you!?
    P.S. If it is possible to send to me give them to schedule(program)
    I thank you in advance.
    Cordially. Victor.

  16. Hello I am interested in your work and I would like to make him(it) if authorizes me to you!?
    P.S. If it is possible to send to me give them to schedule(program) PIC
    I thank you in advance.
    Cordially. Victor.

  17. Hi Prasanna. I am not making/selling kits of this project. Hopefully there is enough information here for you to make one yourself :)

    Cheers
    Kayne

  18. @ilium007 – no, the water doesn’t come into contact with the sensor. There is a short pocket of air in the hose between the sensor and the tank. I’m not 100% sure if it would hurt if water got into the sensor, but I don’t think it would hurt. Double check the specs/google though. You don’t want much air though (i.e. its better to have the water as close to sensor as possible) as air expands and contracts with the outside temp, affecting the readings (albeit only slightly).

  19. ok,but i dont know where is diagrams page. we can see intallation components in a pcb, can i have diagrams infomation,
    tks
    prasanna

  20. I am back on this project !! I have just re-read the response about outside temperature affecting the readings. I am not sure where you are based but I am in QLD in an areas that can see 35+ degrees celcius during the day and quite cool temps at night. Maybe this design is not going to be the best for me. I am looking to use it to automatically pump water from house tanks to elevated bushfire tanks. So when it starts raining the Arduino will chekc the level of the bushfire tanks and pump water out and up the hill allowing the house tanks to re-fill.

  21. Hello:

    I am outside your country.
    Where do you think i could buy the box for the sensor?

    Thanks for your help.

  22. I have nearly finished an arduino shield based on the silicon chip project/practical arduino book.

    I am going to add an Xbee too it though for wireless communication, so watch this space!

  23. Hello:

    Thanks a lot for your fast reply!
    On your picture pressure sensor i can see 2 holes:
    Hole for the water (water terminal).
    Hole for a cable (cable terminal).
    What is the name of the black terminal for the cable (can i buy it on the store you recommended)?
    Did you use a drill? or the box has holes?
    Did you use some kind of material to seal the box in these holes (coupled the water terminal and the cable terminal)?
    what is the name of the small transparent hose inside the box (can i buy it on the store you recommended)?
    The shielded (i think 3 wire cable can be bought on the store you recommended)

    Sorry for so easy questions, but i am away from your country!
    Here we do not have this richness of materials!

    Thanks in advance for your help.

    Robert

  24. @Robert
    The black “terminals” are actually waterproof cable glands: http://www.jaycar.com.au/productView.asp?ID=HP0720. they just tighten around the cable and come with a seal to keep water out.

    I used a spade bit in an electric drill to make the holes.

    The small transparent hoses and all the hose fittings came from Bunnings Warehouse which is just a big hardware store. They are garden irrigation fittings and adapters/reducers to go from the large size pipe fittting on the tank to the small 3mm tube that connects to the sensor.

    The cable for the sensor is 4 core audio cable: http://www.jaycar.com.au/productView.asp?ID=WB1510

    Hopefully you can source these products where you are!

    I would recommend connecting the cable to an arduino, which I am in the process of doing. The PICAXE and AA battery with solar panel didnt work well for me. I will post more about this soon.

  25. Hello:

    You are a very kind person.
    It is wonderful that you are sharing with us your expertise!
    Sorry for so many questions, but it is years that i suffer because i do not have a good tank water level indicator.
    I see that the hose fittings can be bought on Bunnings Warehouse you are referring. It would be great if you could give me the exact name of this hose fitting it seems that they are 2?, this stuff can not be bought here!
    (i could search on ebay if you could help me giving me this name)
    Yes i have seen other comments on this blog and you are referring to arduino, that is the hardware i have.
    I am trying to find also a not so expensive rf transmiter receiver (do you think it is a good idea?) So that the wireless communication can work (with this approach i would need 2 arduino boards?).
    I saw this on ebay
    http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=250981808027&ssPageName=ADME:X:RTQ:US:1123

    do you think that it could work or i need something totally different (sorry again for my ignorance)!
    Last you mentioned a spade bit that you use to make the holes, do you remember the diameter of it?

    Thanks a lot for your patience!

  26. @Robert

    Hi Robert

    If you search for “3mm barbed” on ebay you will find the hose connectors. You just need to get the ones to match your setup. Essentially you need to go from whatever connection you have on your tank down to a 3mm barbed hose connector so that you can have the short piece of 3mm tube between it and the pressure sensor.

    I have tried using inexpensive 433mhz transmitters but I did not have much luck – they were unreliable. I chose Xbee – they are more expensive but if you keep an eye on ebay they pop up cheap every now and then.

    The spade bit to suit the waterproof cable glands is 8mm.

    good luck!
    Kayne

  27. Hello Kayno,
    Thanks for your commitment and everything.
    Please I have two questions.
    1.How do I avoid punching my tank to allow pathway for cable.
    2.Do I have to connect a cable all the way from my arduino to pump relays?Any room for wireless or an idea.
    Thank you for your answer in advance

  28. Please put together a complete parts list for me, i would like to do this project here in guyana on my water system.

  29. Hello:
    Sorry for asking again.
    What are the dimensions for the big box where all the electronics components are installed.
    thanks.

  30. Dear Kayno, I am not very good in graphing would you have the graph you presented for downloading that would be great Thanks

  31. Hello Kayno,

    thanks a lot for your beautiful project, can I know how did you get the result of 31% ?
    by supposing just having a sensor and a pic MCU.

    Thanks in advance.

  32. Dear Kayno,

    your project is very good. Where i can find schematic for the base station ?
    best regards
    swen

  33. I am no expert, but I see no reason why it wouldn’t ramp up to a tank that size. I was using it on a 2,500 gal tank.

  34. Hi Kayno!
    What a lovely solution you got going! This has inspired me to improve a current project with a water tank on my balcony. I’ve been looking at different sensors like the one you use and before I make my decision I want to ask why you chosen the sensor with a dual port and differential pressure type? Does it compensate the value for barometric pressure as well?

  35. Hi Kayno, I’ve seen your project and I am inspired to make another version of it using Raspberry Pi. But I have some questions regarding your design

    1. What joint did you use to connect the transparent tube with the pipe?
    2. Is it possible to use this sensor on Raspberry Pi? I saw many implementation using this device mostly on Arduino

    Thank you for sharing this project

  36. Pi would be cool! Some (late) answers to your questions:

    1. I used an off-the-shelf irrigation “barbed” connector that went from the small tube to a threaded fitting. I then needed fittings to change up the pipe size to match the tank. Something like in this image: http://bit.ly/25RsGQ8
    2. So the sensor uses an ADC on the arduino, and the pi doesn’t have an ADC built in. You would need to add an external one, see https://learn.adafruit.com/reading-a-analog-in-and-controlling-audio-volume-with-the-raspberry-pi/overview for info on this!

    Let me know how you go!

  37. Thank you for your suggestion,

    I also noticed that you used amplifying circuit using LM324. Does it necessary, or can I connect MPX2010 directly into the ADC?

Leave a Reply

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