CPB Capacitive Water Sensor
This is my capacitive liquid level sensor for the Circuit Playground Bluefruit. The two probes within the pipe measure the capacitance of the electronic field between them. A liquid rising between the probes increases the capacitance of the field.
Capacitive liquid sensors are common, but are rarely used with microcontrollers as basic as the CPB and tend to be expensive. My sensor can be used in applications ranging from gas tanks to fish tanks and scaled to any size you see fit.
Image citation: http://ardupiclab.blogspot.com/2015/11/a-precise-capacitive-water-level-sensor.html
Supplies
You will need:
- Adafruit Circuit Playground Bluefruit or similar device with capacitive touch
- Copper wire (Must be insulated and free of water)
- A small section of PVC pipe
- A jar of water
- A laptop
- Aligator clips
- Adhesive
- Jar of water
Cut (and Maybe Insulate) Probes
In this project, I used 8-gauge bare copper wire from Home Depot, with electrical tape to insulate them. Yes, I know. I could've used insulated wire. But who has that kind of foresight? Do this twice. One for the signal and one for ground.
Attach Probes to a Hollow Vessel of Your Choosing
Pick a vessel, any vessel! In an attempt to be resourceful, I thought it would be a good idea to use the handle section of a Hefty bag as my sensor vessel. While it worked at first, the liquid soon entered the bag and shortly after. I then ran to Home Depot again for some PVC pipe.
Code!
Or use my code! I used the touchio library. Apparently you can get raw capacitance values from the CPB sensors. While they are a bit imprecise and arbitrary, they do the trick.
I created a calibration function that returned the average capacitance value (10 readings per second for 5 seconds). Capacitive sensors need to know the maximum capacitance to deliver an accurate reading. For this particular use, I hardcoded the sensitivity. In past tests, I was able to get a consistent reading based on calibration, but it can be a bit finicky due to the CPB's internal calibration software. See my code below!
Downloads
Put It All Together
Now, connect the signal probe to A1 and the ground probe to a ground on the CPB. Readings are represented through the blue neopixels. Red neopixels means that the calibration function is running. (See demo above)
If the readings seem inaccurate, this is because the CPB is adjusting them to detect accurate touches. This makes it difficult to get consistent values, hence the need for calibration.
I hope you liked my project! -Sam