Rasberry PI 3 powered septic tank dosing chamber level monitor with dosing pump control and Web Server.

It all started in the summer of 2014.

The wife tells me that the backyard don't smell right. After some investigating I found that our mound septic system was not working and was overflowing. 24 hours and $600 later I had it pumped out, after some cleanup I found that the problem was not the large pump in the bottom of the dosing chamber (thank God) but that the relay had not turned on the pump. The relay was fried, it had gotten some water in it and corroded and quit working. The system did have a 3rd float switch that was supposed to activate a buzzer inside when it got too full but that didn't happen. It turns out the wire that went to the overflow alarm float had got cut in the yard somewhere so that was worthless unless I ran a new line to it from the house. Luckily since the pump still worked I could bypass the bad relay and turn it on manually with the breaker to empty the dosage tank periodically so I had some time. I got a new relay from the manufacturer (was like $30 delivered) and put it in which got it working normally again. I didn't have a lot of faith in the new relay though as the housing for the relay was not completely airtight anymore. The manufacturer had used metal conduit to enclose the wiring and after 25 years of corrosion it was rusting out. After talking with some septic guys they were not surprised I had problems with the relay, they said the biggest problem with my system is they put all the stuff (relay, wire connections) INSIDE the tank itself. Sure enough about 9 months later one of the float switches quit working, this time the relay stuck in the always on position so the pump was running continuously for who knows how long even though it was sucking air. I happen to hear the sound of the pump sucking air otherwise I might have never known, I was amazed the pump had not overheated. I should mention that the system uses a 220 volt pump, so you really need a 220 volt float switch, so you can't use the ones down at Lowes for very long, let alone the fact that changing a float switch is not fun at all mostly because of hooking up the wiring.

So really to fix it right the metal conduit and the 2 watertight housings really needed replaced along with new floats and relay. The parts themselves are probably not that much but the installation was the killer part as some of the stuff is down in the tank pretty far and mounted to the side of the cement. It really surprised me the system ran as long as it did. Having a live 220 Volt circuit in a chamber with 100% humidity all the time wreaks havoc due to corrosion no matter how well you think you have everything sealed.
I was dreading getting it fixed so I had the pump wired direct in the meantime so I would periodically go out and check the level and then go down the basement and flip the breaker on for 10 minutes. This was getting old though and remembering to do it every couple days (more often on weekends) was asking for problems.

So I bought a raspberry 3 and some parts and starting playing with them and the programming. I was amazed at how cheap everything was and how easy it was to control the IO on the raspberry. The distance sensor (SR104) was like $1 delivered, the relay board was like $5. I had the programming working pretty good and started to think about how I would mount it at the septic tank. I could not really find a suitable external enclosure that worked for my setup so I decided on something like a birdhouse that was off the ground and not sealed but would stay dry inside due to lots of ventilation should work and it's not too Ugly. So I built a birdhouse like box out of cedar and mounted everything inside (lots of Zip Ties and cable staples) Admittedly if I had to do it over again I would make some changes as getting to some of the connections on the raspberry are virtually impossible when it's mounted in the box. I used a CAT5 cable for the distance sensor and the plug off a computer power supply to connect it. Because the distance sensors are so cheap I decided at least initially to see how long it lasts on its own without trying to put it in some kind of sealed enclosure.
I had tested everything pretty thoroughly before I actually installed it on the tank so I was able to start controlling the motor right away with it as opposed to just using it to measure the level.

So these are the basic software packages I have setup on it:

- OS is the standard Raspbian. I played with the windows 10 IOT core but once I found out it didn't even have wireless support for the Raspberry yet I went back to Raspbian as its much better supported.

- VNC server - so I can run the GUI based programming tools remotely. This took a little bit to get setup and to start automatically each time.

- Python - for the programs that take the readings and control the pump and send the emails.

- MySQL - for the backend database to store readings and pump events. This was really easy to setup but unless you make some changes to the setup it will quickly take up all your free space so that took a while to get reconfigured after I ran out space the first time.

- Apache for the web server - Hardest part was figuring out its file structure.

- PHP for the web server language

- CRON to schedule jobs, like the one that checks the log and sends email to me when there is problems.

It's been running pretty much nonstop since 6/2/2016, When it ran out of space that took it offline for a day or so, and I had problems with the distance sensor getting wet around 8/20/2016.

Nov 2016 - Having trouble with the SR104 sensors staying dry enough to keep working. I found that spraying them with clear enamel will help them last longer but they are only lasting about a week currently. The Tank is much more moist inside during the colder months than in the summer. I found out though they make a water resistant Ultrasonic Sensor that even hooks up the same was as the SR104, so I have 2 of those ordered, I wish I would have known about them earlier..

Dec 2016 - Got the waterproof sensor (JSN-SR04T) setup but during that time the raspberry got really unstable, sometimes would not boot and sometimes most everything would shut down on it. Found out that the MicroSD card had developed a problem and some files were basically corrupt. Spent a lot of time trying to copy a image of the old card but kept getting CRC errors. Finally gave up and copied the code files that I could read to a new card with fresh Debian installation. Not sure if I actually wore out the old MicroSD card or someother strange problem.

Feb 2017 - Finally figured out what was causing the JSN-SR04T sensor to be erratic sometimes and other times very consistent. The problem appeared to actually be radio interference from the Raspberry affecting it. I moved the JSN-SR04T board away from the Raspberry a few inches and instantly the readings stabilized. This was a frustrating problem as I had tested the hardware on a bench and it was fine on the bench. I also tried different power supplies and programming but it was simply moving it further away from the Raspberry that fixed the problem. Now it consistently gets good readings even as far as 120cm from the sensor. Thanks for checking out my project! If you have any questions shoot me an email at