Water Softener Salt Level Monitor

2,257

7

Introduction: Water Softener Salt Level Monitor

About: Finding a simple solution to a problem.

Water softeners work using a process called ion exchange in which calcium and magnesium ions from hard water are exchanged with sodium chloride (salt) via a special resin. The water goes into a pressure vessel where it moves through the resin beads, and the calcium and magnesium are replaced by sodium. The resin beads will eventually become exhausted and unable to pick up any more hard minerals. The recharge or regeneration process passes a salt water solution through the resin beads which detaches the hardness minerals and flushes them harmlessly to the drain. The resin beads are left refreshed and ready to make more softened water.

Ion exchange water softeners come in many shapes and sizes but they all have one thing in common, a brine tank that needs filling with salt every few weeks to guarantee a regular supply of soft water. Water softeners are not exactly attractive pieces of equipment and so they are banished to some inaccessible place meaning a special visit is required to check the salt level. More often than not, the cue for adding more salt comes from household members griping about hard water.
A fit and forget salt level sensor is required that can send a reminder when the salt is low in the softener. In this Instructable, a range sensor is used to measure the salt level in the water softener every few hours and the result posted on ThingSpeak. When the salt level gets low, ThingSpeak will send a reminder email to fill up the brine tank with salt.
All the components for this project are available on eBay, as usual, the cheapest parts come from Asia. Even having to buy all the components, the total cost will be about US$10. A multitude of skills like soldering or using the Arduino IDE are needed to make this project. All these techniques are covered in other Instructables and are not repeated here.

Supplies

AA battery holder
VL53L0X ranging module
BAT43 Shottky diode
100nF capacitor
2 x 5k resistors
2 x 470 Ohm resistors
FT232RL serial adapter module
AA size Lithium Thionyl Chloride Battery
ESP-07 microcontroller module
Sundries, wire, box etc.

Step 1: Salt Level Detector

A VL53L0X is used to sense the salt surface in the water softener. The sensor works by sending out a pulse of light and measuring the time it takes to reflect back. Best results come from using a white reflective surface in the dark, exactly what we have in the salt bin.
The sensor itself is very small and difficult to handle. As such, it can be bought as a module containing an I2C interface. This makes it much easier to connect up with other microcontrollers like the Arduino or Raspberry Pi. As the laser and sensor windows are very small, a layer of clingfilm is used to stop any dirt blocking the device.
The module needs to lie flat at the top of the water softener and so wires or solder should not protrude on the sensor side of the module. This was achieved by resting the module during soldering, sensor down, on a piece of wood to stop solder or wire forming bumps on the sensor side.

Step 2: Programming the ESP-07

The intention was to make the salt level monitor battery driven and so a bare-bones version of the ESP8266 chip module was chosen to minimize standby current and give at least a year’s battery life. Unlike some of the more sophisticated versions which include voltage regulators and a USB interface, some extra components must be added to the bare-bones ESP-07 used in this project.
A serial adapter is temporarily wired in to flash the ESP-07 and monitor the serial port during testing. Bear in mind that the serial adapter will be removed once we are happy that everything works correctly, don’t make it too solid. For some reason, the SDA and SCL lines needed swapping to make the sensor work, try this if the range is stuck at full scale. Maybe a quirk of Chinese manufacturing?
A lithium thionyl chloride battery is used to power this project. The AA size of this battery has a steady voltage of 3.6V and 2600 mAh capacity, ideal to power the ESP-07. These batteries can be found at specialist battery suppliers but not in the usual retail outlets. I guess they dare not let the general public loose on a battery of twice the normal voltage!

When the ESP-07 powers up, the pins do strange things until it finishes the start up routine. As a safety measure, resistors are included in the connections to the module outputs to prevent any damaging currents.
The Arduino sketch for this project is attached in the text file. As usual, you will need to edit it with your own router credentials and an API key from your ThingSpeak account. Also, a static IP address is used to speed up WiFi connection time and save current. This may involve changing the IP addresses to match your network. Note commas are used in the IP address and not a period!
There is a vast amount of information on the internet about flashing and using the ESP8266 if you need more help. In summary, flashing proceeds as follows:

Start up the Arduino IDE on the PC and make sure the ESP8266 board is installed and selected
You may need to install the libraries for the sensor and WiFi
Load in the monitor sketch attached below and modify as required
Check sketch compiles without errors
Connect GPIO0 to ground via a 5k resistor
Slot battery into the holder
Plug in the USB adapter
Upload code checking it connects properly
Remove battery and then remove GPIO0 connection.
Start up serial monitor and replace battery
You should be greeted with the serial prints from the sketch before the module goes into sleep

Reducing the cycle time to about 20 seconds will make debugging much easier. Also, depending on your router, the connection time may need adjusting to give a reliable link. Once everything is working, the USB adapter may be removed and the monitor can be wired up for service.

Attachments

Step 3: Final Wiring

When we think the monitor is setup how we like it, the wiring can be tidied up as in the picture. The red power LED should be removed as this is a power drain during deep sleep. It can be gently pinged off with a screw driver or unsoldered. If the WiFi signal is on the low side, the range may be improved by connecting an external antenna. In this case, the link joining the ceramic antenna must be removed like the LED. There must always be an external antenna connected if the ESP-07 is operated without the ceramic antenna link.

Step 4: Installation of Sensor

The sensor needs mounting above the highest salt level in the brine tank. In this installation, the lid of the water softener proved to be a convenient place to position the sensor. A small hole is drilled in the lid so that the sensor can view the salt level. As the brine mixture is very corrosive, a layer of cling film is used to cover the hole and protect the sensor. The battery and ESP-07 can also be mounted next to the sensor on the lid.
There is always the option of plugging in an external antenna if the WiFi signal strength proves marginal.
In this installation, the sensor, ESP-07 and battery were just glued to the top of the lid as the water softener was tucked away in a cupboard. A proper case would be needed in more exposed situations.

Step 5: Battery Life

In order to estimate the battery life, we need to measure the standby current and current when the monitor is awake. This proved quite difficult because the ESP-07 can easily lock up when making changes like altering meter ranges. The final solution was to add a 0.1 Ohm resistor into the power lead and measure the current with a scope during the wake period. Each measurement lasted 6.7 seconds with an average current of 77mA.
Sleep current was measured by putting a diode and 5k resistor in parallel into the power lead. The diode carries the wake current but the low standby current is carried by the resistor. This gave a standby current of 28.8 uA.
The sleep time in the program is set to about 1 hour between measurements. Over a year, the monitor will use 250 mAh in standby and 1255 mAh awake or 1505 mAh total. The 2600 mAh battery used in this monitor should easily last over a year.
The battery life may be extended even further by measuring the salt level less frequently. Unfortunately the sleep time of the ESP-07 cannot be easily made longer than about an hour. One way round this problem is to wake up the ESP-07 every hour and then put it back to sleep again immediately. There is a choice of not waking up the modem and the chart shows this halves the amount of power used. By measuring the salt level only 4 times a day, we can expect a battery life of about 5 years.
The code below uses the ESP8266 RTC memory to store how many times the module has been in deep sleep. In this sketch, there are 6 sleep periods before making a measurement which gives 7 hours between readings. Of course this can be fine tuned to your application. Always snap the battery firmly in place, an interrupted connection can lockup the ESP-07 and drain the battery. The battery should last several years before replacement with these longer sleep times. Again it is best to test the module with 10 second sleeps, 7 hours is a long time to wait to check if it is working...

Step 6: Salt Level Chart

The two charts show the salt level in the water softener and the WiFi signal strength, a useful trouble shooting tool.
Regeneration of this water softener is meter controlled and being a twin tank model, the tanks can switch at any time of the day. The salt level chart indicates when regeneration happened and the time between regenerations gives an idea of water usage. Not only does this monitor show when more salt is needed but on a metered softener, it can highlight excessive water usage.
The VL53L0X has a range of up to about 2m, depending on the reflecting surface. Other applications are possible like monitoring oil or water tank levels where the depth changes slowly over time.

Step 7: Email Reminder

Reminder emails about low salt levels can be sent from ThingSpeak. This involves setting up two Apps from the APPS menu, the first is a MATLAB Analysis that will compose and send an email if the salt level exceeds a defined limit. The other App is a TimeControl where you can decide how often to check the salt level.
Setting up the TimeControl App is quite intuitive, in this case, the salt level is checked daily by running the MATLAB Analysis. A nagging email will be sent daily once the salt level reaches the low level.
The MATLAB Analysis used in this Instructable is attached below. It will need updating with your own channel ID and ApiKey. Also, the minimum salt level for your tank needs inserting in the ‘if’ statement. Hopefully this provides enough detail to receive emails without having to delve into the intricacies of ThingSpeak coding.

Build a Tool Contest

Participated in the
Build a Tool Contest

Be the First to Share

    Recommendations

    • Metal Contest

      Metal Contest
    • Tinkercad Student Design Contest

      Tinkercad Student Design Contest
    • First Time Author Contest

      First Time Author Contest

    Comments