My seawater aquarium sometimes makes noises because the water level on my NYOS Opus G2 can only be adjusted using a handwheel and a pump, but is constantly changing due to deposits. So sometimes it's too low or too high.
Since I (wisely) bought a pump with a 0-10V interface, my idea was to measure the distance to the water surface in order to regulate the pump accordingly.
Unfortunately, there are no (affordable) sensors that provide me with the water level as an analogue value so that I can later control the pump with a PID regulator.
Since optical methods are too error-prone, I decided to use a hall sensor.
With this I can measure a distance of up to 35mm, which is more than sufficient for my application.
My hardware:
Mainboard: ESP32 D1 Mini
https://www.amazon.de/AZDelivery-Bluetooth-Internet-Entwicklungsboard-kompatibel/dp/B08BTLYSTM/ref=sr_1_3?th=1
Potentiometer: 10K
https://www.amazon.de/gp/product/B07ZJL91YP/ref=ppx_yo_dt_b_asin_title_o01_s02?ie=UTF8&psc=1
0-10V PWM converter:
https://www.amazon.de/gp/product/B09FYWWMQS/ref=ppx_yo_dt_b_asin_title_o01_s00?ie=UTF8&psc=1
3.3V step down converter:
https://www.amazon.de/gp/product/B07DP2MDJQ/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&th=1
Hall sensor:
https://www.amazon.de/AZDelivery-KY-003-digitaler-Transistor-Arduino/dp/B07V2N9T6W/ref=sr_1_3_sspa?crid=3FHG8DF7I68B5&th=1
I'll build an own PCB for it later. If you are also interested in such a circuit board, write it down in the comments.
The software for arduino is included.
You'll need a 10x5mm neodym magnet and two ~ 120mm 5mm acrylic tubes.
Installation:
Solder out the hall sensor from the board and solder three wires to it.
Ensure, that you use the correct colors for Gnd, Vcc and the signal. On the KY-003, Gnd and Vcc are reversed on the PCB! Insulate the wires as best you can. I just used electrical tape.
Bend the hall sensor 90° so that it lies flat on the bottom of the sensor holder. The greatest distance to a magnet can be measured in this direction. I used hot glue to attach the sensor in the sensor holder and make it waterproof.
Then assemble the complete sensor, but don't glue the magnet in tight yet. For me, the polarity was still crucial to reach the 35mm.
After that I measured the analog values for the respective distance in 5mm steps with a caliper and wrote them into the source code. This is necessary because the hall sensor does not provide linear values proportional to the distance. I compensate this in software.
The analog values are transmitted via the serial interface.
You can also use a potentiometer temporary to tune the pump to a specific control range in this stage (set Mode to EMode::Potentiometer for this). With my pump (Aqua Medic DC Runner 3.3) I took the analogue values for 33% and 70%. Below 30% this pump switches off. After entering the analog values you no longer need the potentiometer.
The constants for the PID regulators are defaults, but they worked fine for me.
The PID sets the water level (kDesiredWaterLevel_mm) reliably for me. This distance and the holder is of course designed for the overflow box of a Nyos Opus.
So you have to design your own holder to adapt this to your application.
Print settings:
PETG is recommended as it does not leach into the water.
For the swimmer ("Schwimmer") I'm using 5% infill and 4 walls. Of course, the part must never sink and be absolutely tight. I made the hole for the magnet a little deeper to also protect it from the salt water with hot glue.
If you want to support me, please buy me a coffee (via PayPal) ;-).
Depending on your interest, I might also make a video.
UPDATE:
Just added MQTT support and a picture with plots of the input/output values.
You can see, that the sensor keeps the waterlevel in a range of +- 1mm (11 mm is the setpoint for the PID). The accuracy of the sensor is somewhat affected by the poor analog inputs of the ESP32 and a 2m long cable.
The author marked this model as their own original creation.