Water Depth Gauge With Capacitive Difference Sensor W01

by tonygo2 in Circuits > Microcontrollers

2187 Views, 21 Favorites, 0 Comments

Water Depth Gauge With Capacitive Difference Sensor W01

DSCN4767.JPG

I was lucky to receive a prototype example of the Capacitive Difference Sensor W01 to try out and decided to build a gauge to sense the depth of water in a rectangular glass vase. I'd not seen such a sensor before and found the project interesting. The sensor is a white plastic cuboid 25x22x15mm with a long grey cable terminating in green, yellow, brown and white wires and shield ends.

Supplies

img07032023_019.jpg

Capacitive Difference Sensor W01

Raspberry Pi Pico (or other RP2040 chip) micro controller board (I used a Pimoroni Pico Lipo)

Rectangular glass vase approximately 220x100x80mm 

4 cell AA battery box with switch and AA batteries

Six 4.7 K Ohm resistors

Strip board

2.54mm pitch female header strip

2.54mm pitch male header strip

Connecting wire

Single sided transparent tape

Optional: SSD1306 128x64 pixel display

Documentation and First Thoughts

img07032023_021.jpg

The output from the sensor is a voltage, 0-5 volts, on both the green and yellow wires so we need two ADC pins to measure the changes. Most hobby microcontroller boards are 3.3 volts so some protection is needed. A voltage divider circuit with three 4.7K Ohm resistors will reduce 5V to 3.33V.

The input voltage of the sensor is 6 to 12 volts so we will need to increase the available 3.3V or 5V by adding a battery to the circuit. (We will need to be careful in checking the circuit before we connect it up as voltages greater than 3.3V will cause great damage to the Pico.)

We will need an interface board between the sensor and the Pico.

We need to hold the sensor in position - sticky tape.

Interface Circuit

Cap Circuit Final.jpg

This does two things:

  • Increases the voltage from 3.3V on the Pico to approximately 8.9V for the sensor VCC pin.
  • Reduces the possible 5V down to 3.3V for the ADC pins on the Pico.

I decided to build the circuit on stripboard as a more permanent alternative to a breadboard.

I used a 4 AA cell battery pack because I had one to hand but a single AA or AAA cell should also work if you use the 5V pin (VBUS physical pin 40) on the Pico instead of the 3.3V pin. Just check you are getting between 6 and 12 volts.

The Interface Board

DSCN4768.JPG

There are no cut tracks on the underside of the strip board. The strips run from top to bottom on the under side.

The top right socket is for the battery box with positive on the right and negative on the left.

The top left socket is for the sensor. Moving left to right yellow, green, white, brown = A, B, GND, VCC.

The voltage divider resistors are on the far left. The sensor outputs, yellow and green, are connected to the right hand end of the three resistor sets. GND is connected to the left hand end and the pick up points are between the two right hand resistors in each set.

The bottom socket is connected to the Pico. Left to right: Yellow (A) to GP28 (ADC2),Green (B) to GP27(ADC1), GND and 3.3V.

After soldering up the board I carried out some very careful checking to avoid any shorts circuits or mistakes.

Test Code

Code.jpg

The code is very simple as it just reads the two ADC pins and prints their values and their difference. Output is to the SSD1306 display and the Shell window in Thonny. (You will need to have loaded the SSD1306 library onto your Pico for the display to work.)

If you have not included the display in your circuit you can comment out all the references to it.

I first tested the project by moving a large Swiss Army knife (plenty of steel) close to the sensor on both sides and watched the numbers move. (No Magic Smoke was observed so all was OK with the circuit!)

You can download the code here:

Testing With the Glass Vase and Water

Cap Sensor-2.jpg
Capacitive Difference Sensor W01 Demonstration

The Pico Lipo allows the setup to be powered by a Lipo battery while disconnected from the computer if the program has been saved in the Pico's memory and called main.py.

I moved everything near to the kitchen sink and taped the sensor to the side of the vase. I started the program running and slowly poured water into the vase. The numbers started moving and as the vase filled with water the DIFFERENCE value rose. The sequence was recorded in the video.

Conclusions

This is a very nice sensor and very easy to access readings from simple code. You do need a computer with two ADC ports to make use of it. Most modern microprocessor boards already have them included. (If using a Raspberry Pi Computer you will need to add an ADC chip between the interface board and the GPIO Pins. This is very easy to do and has been written up in many places in the Web.

It would be easy to add to this project by taking a series of readings with different depths of water and producing a graphical output on the display or by adding a pump or tap to refill a container as the value drops below a certain level and then stop before it over flows.

An interesting sensor with plenty of scope for further experimentation.

I hope you have found this interesting and useful.

My sensor was a prototype and the final product will be appearing on Kickstarter in the near future.

You can find other examples of the sensor being used here:

https://www.youtube.com/results?search_query=marius+czardybon