Building a Zigbee Hot Water Tank Controller With Automatic Refill

by taste_the_code in Circuits > Sensors

22 Views, 0 Favorites, 0 Comments

Building a Zigbee Hot Water Tank Controller With Automatic Refill

I Reverse Engineered a Solar Water Heater Probe - ESP32-H2

Almost every solar water heater on a rooftop uses the same odd looking metal probe to track both the water level and the temperature inside its tank, and it does all of that over just four wires.

I had to build a Zigbee controller around one of these probes for a facility that needs a steady supply of water at 60°C or more, so I worked out how the probe is wired and how to read it with a microcontroller.

In this guide I will show you how the probe works, how to test it on the bench without any water, and how to read it with an ESP32-H2 so you can use one in your own tank monitoring projects.

This Instructable is supported by PCBWay. They are running their 9th project contest at the moment where you can win some great prizes.

Supplies

For the hardware, you will need a solar boiler water level and temperature probe, the kind sold as a replacement sensor for rooftop solar water heater controllers. To read it I used an ESP32-H2 development board, since it has Zigbee built in. You will also need two 10k resistors for the voltage dividers, an RGB LED with suitable current limiting resistors, a small active buzzer, and a relay module to switch the fill valve. I used a two channel relay module but only one channel is needed. For a permanent installation, a transfer switch and a project enclosure are useful too, along with a breadboard or perfboard and some hookup wire.

For software, you need the Arduino IDE with the ESP32 board package installed, which includes the Zigbee examples for the ESP32-H2. You will also need a Zigbee coordinator and a automation platform to see the readings. I use my own platform, ding.mk.

For tools, a multimeter is essential for figuring out the probe, plus a short piece of wire for simulating water, a soldering iron, and wire strippers.


  1. Solar Boiler Water Level and Temperature Probe: https://s.click.aliexpress.com/e/_c37iH8al
  2. ESP32-H2 Board: https://s.click.aliexpress.com/e/_c37H7wDT
  3. ding.mk Platform: https://ding.mk/en
  4. 10k NTC Thermistor: https://s.click.aliexpress.com/e/_c2xfdkSz
  5. Resistors: https://s.click.aliexpress.com/e/_c3uz3LSp
  6. RGB LED: https://s.click.aliexpress.com/e/_c3W4Q4LB
  7. Buzzer: https://s.click.aliexpress.com/e/_c3kIbj1P
  8. Relay Module: https://s.click.aliexpress.com/e/_c3q9uwYD
  9. Transfer Switch E-SG-302: https://s.click.aliexpress.com/e/_c3ZItK97
  10. Zigbee Coordinator: https://s.click.aliexpress.com/e/_c4OxvPol


How the Probe Measures Water Level

MVI_3284.MP4.00_01_00_10.Still002.jpg
MVI_3284.MP4.00_01_10_09.Still003.jpg
MVI_3284.MP4.00_01_18_03.Still004.jpg
MVI_3284.MP4.00_01_20_29.Still005.jpg
MVI_3284.MP4.00_01_33_05.Still006.jpg

The probe is a long tube with metal rings spaced along it. It hangs down into the tank from the top, so as the water rises, more of the rings end up under water. Water conducts electricity, so every submerged ring gets connected to the bottom section of the probe through the water.

Inside the probe there is a chain of resistors connected to those rings. Two of the four output wires are for the level. When the tank is empty, nothing is bridged and the resistance between them is around 60 kilohms. As each ring gets submerged it cuts part of the chain out, so the resistance drops to 30 kilohms, then 20 kilohms, then 10 kilohms, and finally to zero when the top ring shorts the two wires together. Those steps correspond to roughly 20%, 50%, 80% and 100% full. One ring between 80% and 100% does not change the reading on my probe, and I suspect it is related to detecting a full tank.

How the Probe Measures Temperature

MVI_3284.MP4.00_00_30_05.Still001.jpg

The other two output wires, white and green on my probe, connect to a 10k NTC thermistor sitting in the second ring. An NTC thermistor is a resistor whose value goes down as it gets warmer. At around 25°C it reads close to 10 kilohms, and it drops as the water heats up. By measuring its resistance we can calculate the water temperature.

Identify the Wires With a Multimeter

Before connecting anything, figure out which wire does what on your own probe, since colors can vary between manufacturers. Set your multimeter to resistance and measure across pairs of wires. The pair that reads a little over 10 kilohms at room temperature is the thermistor. The pair that reads around 60 kilohms with the probe dry is the level sensor.

Now take a short piece of wire and touch it between the bottom section of the probe and each ring above it in turn, while watching the level pair on the multimeter. You should see the resistance step down from 60 kilohms through 30, 20 and 10, down to zero at the top ring. Note which wire connects directly to the bottom section, because that matters for the next step.

Wire Up the Voltage Dividers

MVI_3285.MP4.00_00_16_24.Still001.jpg

A microcontroller can measure voltage but not resistance, so each sensor goes into a voltage divider. For each one, connect a 10k resistor between 3.3 volts and an analog input pin on the ESP32-H2, then connect the probe between that same pin and ground. As the probe resistance changes, the voltage on the pin changes with it.

Do this once for the thermistor pair and once for the level pair, using two separate analog pins. In my build one of the level wires is powered through the sensor side of the divider while the other divider is tied to 3.3 volts at all times, but the principle is the same for both.

Add the Outputs

MVI_3283.MP4.00_02_23_21.Still001.jpg
MVI_3285.MP4.00_01_20_21.Still002.jpg

Connect the RGB LED to a digital pins through current limiting resistors. I use it as a status light, showing green when there is enough water at the right temperature and switching colors when the water is low or not hot enough. Connect the buzzer to another pin through a transistor so it can sound an alarm when the tank runs empty.

Then connect the relay module input to a digital pin. The relay switches the valve that lets fresh water into the tank. If you are adding this to an existing solar controller, wire a transfer switch so the valve can be driven either by the original controller or by your relay. I also added a mode input that puts the device into working mode when it is pulled to ground.

Write the Firmware

video.00_04_29_26.Still001.jpg

Start from the Arduino Zigbee examples for the ESP32-H2. In your loop, read both analog pins, convert the level voltage into a percentage by checking which resistance step it falls into, and convert the thermistor voltage into a temperature using the standard NTC calculation for a 10k thermistor.

Then add the control logic. In my case the water must be at least 60°C, but a solar boiler on a sunny day often runs much hotter. When the tank is too hot and not full, the relay opens the valve and adds cold water, which mixes in and leaves more water at a usable temperature. I set the upper limit to 62°C to give the system a little room so it does not switch constantly. Finally, report the temperature, set point and level over Zigbee. Since the device is mains powered, configure it as a Zigbee router so it also strengthens the rest of your network.

Test It

MVI_3279.MP4.00_00_13_20.Still001.jpg

With the probe dry on the bench, the dashboard should show 0% water. Put the device into working mode and it should immediately raise the low water alarm, with the buzzer sounding and the LED showing the empty state.

Now use your piece of wire to bridge the bottom of the probe to each ring. After a few seconds the level on the dashboard should step through 20%, 50%, 80% and 100% as you move up the probe, and drop back to 0% when you disconnect the wire. The temperature should read close to room temperature, and if you warm the thermistor section in your hand you should see it rise. Once all of that works, you can install the probe in a real tank and check the relay opens the valve when the conditions are met.

Conclusion

MVI_3281.MP4.00_00_35_08.Still001.jpg

That is how a common solar boiler probe measures both level and temperature on four wires, and how to read it with an ESP32-H2 and a couple of resistors. I could not find any documentation on these probes when I started, so I hope this helps anyone who wants to monitor a water tank, a rain barrel, or anything else that holds liquid. My finished version now lives in a box at a production facility, keeping the tank topped up with hot water every day.

If you liked this build, follow along on the Taste The Code YouTube channel for more projects like it.