What is a water softener?
A water softener is a filtration system that removes calcium and magnesium from water. This process helps improve the efficiency and lifetime of household items that use water, like water heaters and pipes. It also helps make the water taste better.
As part of this system, we need to periodically add salt to a brine tank. This salt is important for the filtration process, and forgetting to refill the tank can gunk up the water.
How Can Arduino Help?
I have forgotten to set a timer to refill the salt tank a few times. To help with this, I wanted to create a solution that reminded me automatically. My goals for the project were:
- Send a notification to my phone when the tank needs refilling.
- Notify me if the lid isn’t properly attached to the tank.
I had some leftover HC-SR04 ultrasonic rangefinder sensors from a previously abandoned project. These sensors had the added benefit of being no-contact, which, in this case, helps tremendously because salt can be harmful to electronics.
These sensors send out a sound pulse and then measure the time it takes for the pulse to return, similar to sonar in submarines. I planned to mount these sensors to the top of the salt tank, facing downwards, after drilling some holes in the lid.
Because I used more than one ultrasonic sensor, I needed to control the timing of the sound pulses. If you try to read from all three sensors at once, you’ll find they interfere with each other.
The Arduino starts a HTTP web server when it boots with a hardcoded IP address. When it receives a request, it reads each of the sensors and responds with JSON.
I added logic to discard potentially invalid readings. If a sensor returns a
0 value, it is discarded and retried (up to a maximum number of attempts). Each sensor is read several times and then averaged together.
If the standard deviation of these readings is too high, then all of the readings are thrown away and retried (also up to a maximum number of attempts). The average sensor value and standard deviation are returned in the JSON so the requestor can determine their confidence in the data.
After ensuring everything worked properly on the breadboard, I soldered all of the components together.
A Note About Interfacing with the HC-SR04
Connecting a HC-SR04 to an Arduino is very simple. Here are the connections I made:
|Trig||Any GPIO Pin|
|Echo||Any GPIO pin (See note)|
Note: If your Arduino expects a 3.3V signal for its GPIO pins but your HC-SR04 outputs 5V, you’ll need to use a voltage divider on the Echo pin. I implemented this using a 1kΩ and 2kΩ resistor.
Then, I mounted the device to the top of the salt tank by drilling some holes in the lid with a Dremel. To prevent any dust from getting in the small gaps between the sensors, I added some cardboard and tape. The Arduino is zip-tied to prevent it from moving around when the lid is removed.
If the salt level is getting low, or if the server thinks the lid was accidentally left off the device, the Ruby on Rails app will trigger a push notification to my phone through the Pushover service.
At some point, I’d like to move this dashboard to a Raspberry Pi. For now, I’m happy with it running on my Mac Mini during the day. I don’t keep the Mini running longer than I normally would, so it doesn’t add to the electric bill.
So far, I’m happy with the result. If you have questions, comments, or suggestions, shoot me a line!
- Arduino Maker WiFi 1010
- HC-SR04 Ultrasonic Rangefinder
- 5V 2.5A Power Supply
- 1kΩ resistor
- 2kΩ resistor
- Jumper Wire
- Solderable Breadboard
If you liked this project, you might also be interested in the RFID keepsake box I made for my girlfriend (now wife).
Some reflection on the past and goals for the future.
How to implement phrase recognition using HoloLens and Unity.