Sitemap

Member-only story

Microcontroller Water Sensor

Using an STM32 “Blue Pill” ADC peripheral and PWM for Audio

11 min readOct 18, 2026

--

The types of sensors most common nowadays that are sold in kits for use with microcontrollers tend to be digitized for ease of use. Typically, they will communicate a single value of on/off or they will send back some handily digitized number that can be used either directly or after some calculations. These calculations can get rather involved, as with BMP devices. However, there are still some analog devices you can hook up, to learn something about that peripheral. Some call the “analog” term a misnomer, because what we really have is discrete numbers for digital output, vs continuous values for analog. It is called that because of the analogous relationship between the signal and the voltage.

One sensor that is fairly common that produces analog output is a water level sensor. Rather obvious in construction, these rely on a parallel group of exposed traces on a board (conductive, flat wires on a PCB), a power input, and a transistor. When water is not purified, it contains sufficient dissolved materials to make it conductive. Hence, when the traces are covered with water to more or lesser extent, there is greater conductivity between the transistor’s base input, which allows more conductivity between power and ground, crossing the transistor.

The circuit and senor input: a glass of water

--

--

Leslie Foster
Leslie Foster

Written by Leslie Foster

Programmer / Developer / Software Engineer since late 1980s