I wanted to share another project that I have done to monitor the salt level in my water softener. There are two things that I want to monitor; 1) the level of salt in the brine tank so that I know when its time to dump some more in and 2) How often it is regenerating. I have the first part of this complete, but the second part is not. I was trying to think of ways to measure this. I thought of various ways, at a high level, but none that seemed too practical. (measuring the weight of the brine tank for one) I had run across a guy who was trying to do the same thing but was displaying it on an electronic bar graph. The idea here was to use an IR distance measuring sensor. This is the approach I set out to try.
The sensor is a Sharp GP2D12. It has a range of about 10cm to 80 cm. This is almost perfect for my brine tank. I picked a couple of these up. They were only about $10 each. They have an analog output. I planned to use the analog inputs on my HomeVision. I ran some cat5 cable from my hub location to the brine tank. I bolted a couple of pieces of wood to the top and bottom of the brine tank lid with some galvanized bolts. I mounted the sensor to the bottom of the lid. I drilled one more hole to route the cable through the lid. The other end of the connector is an RJ11 so that the lid can be disconnected without removing the sensor. I plan to mount a handle to the top so that the lid can be hung from a nearby hook while refilling, but haven’t done that yet.
The next problem is reading the distance from this sensor. Its output voltage is not linear to the distance. From what I have read, there are slight differences in each sensor and it should be calibrated. My excitement to get this implemented took me down the path of using the curve that was listed in the datasheet. I have to admit that my math is more than a little rusty so determining the formula from the curve was a challenge. However, again, I found someone who had created a simplified formula for the standard curve. I needed to make some small adjustments to this because it assumed a 10-bit precision A/D converter and mine only has 8-bit precision.
Unfortunately, the HomeVision interface doesn’t allow for reading the analog ports, but it does allow for reading variables. So, I wrote a periodic event in HomeVision to take the value and put it in a HomeVision variable. This can be read by the plugin. I added some code on the HS side to take that value when it changes, convert the value to distance, convert the distance to the height of the salt from the bottom instead of down from the lid and, bingo, I had the height of the salt in a HomeSeer virtual device. I added some more code the change the graphic to give some visual cue of the salt height and I was done. I have noticed that the height seems to vary a little when it should not. I suspect that the salt is not a very good surface to reflect the IR. What I may try doing is adding a piece of plastic that will sit on top of the salt to be a better surface. However, even with the slight variance, it is still quite good enough for what I need. I am very happy that I was able to do this for about $15.
I have written some additional code that will send a text message to me and my son to load up some more salt when it gets to roughly 5 inches of salt remaining.
I have also created an HStouch display for this. Look at the bottom of the following screenshot… (HSTouch is a plugin for writing home automation displays for android/apple/windows)
My plan for the second part, measuring how often it is recycling, is still to be done. My first and only thought so far is to use one of my remaining mini float switches to monitor the water filling in the brine tank. I have a Kinetico softener that is run off of water pressure, not an electronic control unit so no option to hook up to that control unit.