DIY Capacitive analog sensor to measure water depth

Hi! I am a freelance writer who develops micro:bit MakeCode projects for adult and student beginners. I am trying to replicate a user-designed DIY capacitive water level sensor I found online but the code is not working for me the way it does in the original videos. The sensor consists of two parallel strips of copper tape on an index card, sealed in a ziptop plastic bag, and connected to P0 and GND.

You can see my version here (https://vimeo.com/902019316) and here (https://twitter.com/KathyCeceri/status/1745569547367711008).

This is where I found the project I am copying: https://wakelet.com/wake/HioyItaO1dWBCs1rEY-4c

This is how I tried to reconstruct the code shown in the online descriptions: https://makecode.microbit.org/_7UW3PHWyvg3c

My issues: In the original videos, the line graph on the serial page is smooth. Mine works but is jaggedy.The videos also show the capacitance changing on the microbit LED grid. I can’t get that to work for me. One possible problem: Their values are in the 0-270 range. Mine are between 9000-11000.

On a related note, is it possible to get analog readings off a pin if you set it to capacitive touch? If so, that might be easier for beginners to code. I believe this can be done with the capacitive pins on the Adafruit CPX using a MakeCode Input block called “button pin [A1] value.” You can see it here:

Thank you!

2 Likes