Episode: 3217 Title: HPR3217: Sump Minion Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr3217/hpr3217.mp3 Transcribed: 2025-10-24 18:59:31 --- This is Hacker Public Radio Episode 3217 for Tuesday 1 December 2020. Today's show is entitled Some Million and In Part on the Series, Hobby Electronics. It is hosted by Brian in Ohio and in about 18 minutes long and Karina Clean Flag. The summer is my first internet on things device without using Python. This episode of HBR is brought to you by AnanasThost.com. Get 15% discount on all shared hosting with the offer code HBR15. That's HBR15. Better web hosting that's honest and fair at AnanasThost.com. Hello Hacker Public Radio. Brian in Ohio here back. I'm out from under my rock. I'm back in Northwest Ohio using my regular voice and although it was kind of fun doing that eSpeak episode, eSpeak's pretty cool. It's actually very fast as type up what you want to say and have eSpeak read it out for you and I don't understand why nobody would complain about the audio. It's no worse than operators episodes and we all love his shows don't we? Anyway, I wanted to talk a little bit about a problem that I had here at my house that I found a solution to and I thought it might be interesting to you all. Okay, the problem is is that here in Northwest Ohio I we live in a place where with a very high water table we live in an area that used to be called the Great Black Swamp was we're basically on the shores of the the great lakes here in the US. It's the largest source of fresh water in the planet I believe and we because of that you can just dig down a little bit not very far and hit water and so if you have a basement in your house you're going to have water issues. To correct that problem houses here in this area have a sump's put in and a sump and I've got a couple of pictures here the sump consists of a a basin that's in your basement and there's some piping that that directs the water from outside into this sump collection area and then that water is pumped out usually done pumped out by an electrical pump and a good sump system has some kind of backup usually has two pumps in it so my sump system has the picture one or is just kind of looking into the the closet where it sits and then picture two is looking down into the sump with the cover off and you see the the pump it's the main pump is the black device with the green on top and there's a secondary pump that is the the secondary pump is the black part that's got a hose clamp around it with a little white knob thing that's that's connected to this there's a PVC pipe with a wire that runs down to it and so those are the two pumps in my sump system the the real problem isn't necessarily the sump the sump itself it's one the sump pumps fail and so the primary pump can fail in many ways of course it can have mechanical failure it's a it's a pump sitting in water so rust is a problem a lot of these pumps have some kind of float system that turns the pump off and on those flump those floats can get stuck they can have sediment get into them and mess them up and of course if you have some kind of electrical outage you can have your sump won't work if it's a because it's powered by electric and so if you have a thunderstorm that knocks out the power and there's water rising you won't have their your primary pump will not work that so I have a secondary pump those can be different flavors some of them are electrical also but usually those have a battery backup and those all of all of the secondary pumps have the same problem they can fail in different ways mechanically but secondary pump that relies on some kind of battery if there's a long power outage you might have to at least recharge that battery it might run into problems there my secondary pump actually uses a city water as a mechanism to run a turbine to draw the water out so if there's an assumption here that if your power is out and your city water is out you're probably experiencing the zombie apocalypse and you've got other bigger problems than your sump pump at that point or your sump it's in general so I wanted a system I've had a couple of of floodings of the basement for a variety a couple of different reasons so I wanted a system that would notify me when the water level in the sump was rising and I wanted it set so that though when the water level hits where the secondary system kicks in I would get that notification and I wanted a system that wouldn't use some kind of home spy system that's available from one of your friendly corporations out there and I really didn't want to use Python because I don't really know Python and I didn't want to just install Python libraries and for a solution I wanted to be able to do it with tools that I understood so the solution I came up with uses a raspberry pie a simple transistor circuit a C library that allows me access to the pies GPIO pins those are the general purpose input and output pins and those are those that header of 40 pin for number 26 pins I think it is I'm not sure what the number is the little pins that stick out out of the the raspberry pies that allow those live access to hook things up to them and I use the male client and some bash scripting in a cron job to get this job done so here's how I did it I use a raspberry thrive the raspberry pie 3B that's what I had laying around I installed of course slackware because that is the best operating system excuse me that's the best Linux distribution that's out there and I used the Sarpy projects the slackware arm on the raspberry pie I've got links in the show notes for these things there's actually their developers of the slackware arm fork of the or part of the slackware project they have a podcast I'm going to link to that they've got about 15 shows out pretty good listening and so after installing slackware on my raspberry pie I wanted access to those general purpose input output pins and initially I was a little bit of looking around and there's a way to control this pins using calls to sysfs that are really just echoing into sysfs a virtual file system that that creates these connections to these input now put pins from the kernel to the real world and but unfortunately that sysfs system is deprecated as a link in the show note to to what's happening there and it's being replaced by I think it's called live GPIO so I tried to compile that and get it working and I and I could not do it so I was a little bit frustrated at that point there's some other solutions of course is using python which I really don't want to use there's a project called wiring pie which kind of makes the access to the GPIO pins very similar to the way Arduino or wiring does it and it's but unfortunately that project's dead it seems like and then there's a project out there called pie GPIOD it's it's still active there's a slack builds for it I've got the slack builds is the official unofficial extra repository for slackware users and a great source of software out there and they had a slack builds for it so I built it up installed it into my pie and then had access to the to the GPIOs and that library is actually pretty amazing it allows access from the c c functions it allows it has a python wrapper and it has a bash commands that allow you access to the GPIOs it was very cool very easy to install the the syntax of the commands are as kind of yeah I'd I'd have written it differently but I I'm not complaining I'm just saying that's what I would do if I designed it but I'm not going to change it works just fine the circuit I used a rework of a circuit that forced mims I have a bunch of forest mims books in my library and if you don't know who forest mims is I've got a link to a Wikipedia article in the show notes and he's put out a bunch of radio shack here in the usway in this this this retailer radio shack where you get electronic stuff when I was growing up and some one of the things they had was these little engineers notebooks and they were in graph paper form and that circuits and stuff and just endless hours as a kid of looking at those and dreaming about making things that really didn't come into fruition till now when I'm an older guy but anyway so there's a forest mims has a circuit that involves a transistor a couple of three resistors and it allows you to detect water pretty easily and so I've got a picture of that circuit and that and I did it and try to do it in forest mims style graph paper and it gives a kind of a block overview the circuits to the right and then what I would my main the main change that I did was I installed a relay board and I'll describe how I did this later in the show this relay board allows me to do a functional test of the system whenever I want to by by basically shorting across the probe pins and then the system runs and it does what it's going to do which I'll describe what it does when I get there so that's the third picture now too as far as notification goes I remember that you can send text messages via emails and so what I there's a link in the show note for different systems for different carriers for for my carrier Verizon it's your phone number at vtex.com is who you would email to and it comes up as a text message and so the best text messaging system for Raspberry Pi on the command line is mutt so I set up a mutt client and I've got a link to on how I did that to my gmail account and that is how I am notified if there's a problem in my sump it the system detects when the water gets high through the circuit if it's if the water is you know shorted out the the probe pins and the circuit goes to a logic level zero because it's driven low then a a mutt message is said to my my phone letting me know that there's a problem that this water is coming up and then I can go investigate to see what's going on so and so the script that I came up with that I run on a cron job every minute it basically it has a few parts the first part is daily at six a.m. it sends me a message just to let me know that that that pie is still running that that Raspberry Pi is working that the GPIO Damon the PI GPIO D Damon which is what's running in the background on on the on the Raspberry Pi is is still running if not it sends me a message because only only root can start that Damon up so I would have to intervene SSH into that into that Raspberry Pi and restarted it for some reason it died it makes sure that the the pins that I use which are pin four and pins 17 on the on the Raspberry Pi the pin four is the input pin from the sensor the pin 17 is the output to the relay which turns the relay off and on when I want it and make sure those are correctly set up as input and output and if those two since at six a.m. if those two those three things those the two pins and the Damon is running it sends me a message it says that the system is running and then once a month I picked the first Wednesday of the month at noon using those using a little bit of cut commands against date and it the system runs a monthly test sends me a message that it's going to run a monthly test it basically energizes that relay short shorting the pins of the probe the water probe and then makes and then the the circuit thinks that the water is risen the the input to the GPIO goes from a logic high because the pin is held high normally it's driven low and it's detected and I get a water running mess water rising message does that once a month and then then the last part of the of the script is just the nor just what the main purpose of this project is is this checks to see that the sensor pin is not not at a logic zero driven low it says if it's a zero then the water is risen that that circuit is active and it sends me a message that the water is rising but usually hope you know everything's going well it would be a one and I don't get anything so I first put this the a breadboarded up the circuit I put in all and that's a picture picture for there the raspberry pie with all the wires a big old mess of wires there to run the system and did a bunch of testing got the script working and and then once I was confident that would work I made a strip board which is picture five where a couple little headers ones to the to the right on the picture that's a transistor in the resistors are on top and then on the left is the is where the wires that connect to the to the some pump and to the relay board are put in and then the the header that's to the right on the picture facing down is what plugs into the raspberry pie and then I had a case I did a little cutting and pasting and I stuck that relay board onto the top of the case and secured the whole thing into a two by four in the some closet and that's where the where my some minion lives and hopefully I'll never have another water problem again that would require a flooding of my basement for me that I could be able to intervene before I get a flooding problem and that's the hope and right now I feel confident that that's what this device will do for me so in conclusion it was a fun project I think it shows the power of Linux and floss there's so many different ways to approach a problem and different solutions out there this is a solution I I chose and certainly it's not a static problem it's something that I can tinker with and if I find new and better ways to do it that's what I'll do it I'll implement those changes so anyway I hope it inspires you to take one of those raspberry pies and and hook things up to the physical world and and make things move well that's in the show if you have any comments go ahead and email me or post a comment or better yet make your show for HPR telling us about how you solve the problem like this or just anything that's a raspberry pie related would be interesting to hear all right enough of that Brian and Hynes signing off and I want to remind everybody to go fast take chances you've been listening to hecka public radio at hecka public radio dot org we are a community podcast network that releases shows every weekday Monday through Friday today's show like all our shows was contributed by an HPR listener like yourself if you ever thought of recording a podcast then click on our contributing to find out how easy it really is hecka public radio was founded by the digital dot pound and the infonomicum computer club and it's part of the binary revolution at binrev.com if you have comments on today's show please email the host directly leave a comment on the website or record a follow-up episode yourself unless otherwise stated today's show is released on the creative comments attribution share a light 3.0 license