
<p>1 <b>introduction</b></p>
<p>1.1 back in Ohio using my regular voice<br />
1.2 espeak is no worse than operat0rs audio and we all love his shows.</p>
<p>2 <b>the problem</b></p>
<p>2.1 where i live the water table is high and basement flooding is a problem <a href="https://en.wikipedia.org/wiki/Great_Black_Swamp" class="uri">https://en.wikipedia.org/wiki/Great_Black_Swamp</a><br />
2.2 to counteract the water table problem houses have sumps in the basement</p>
<p><em>sump closet</em><br />
<img src="https://hackerpublicradio.org/eps/hpr3217/img_001.jpg" alt="sump closet" /></p>
<p><em>sump close up</em><br />
<img src="https://hackerpublicradio.org/eps/hpr3217/img_002.jpg" alt="sump close up" /></p>
<p>2.2.1 sumps consist of a basin where outside water is collected<br />
2.2.2 a pump, usually electric, that drains the sump<br />
2.2.3 also a good sump system will have some type of backup pump</p>
<p>2.3 the 'real' problem happens when the sump pump(s) fail<br />
2.3.1 primary pumps fail in many ways, mechanical motor failures, floats sticking electrical outage<br />
2.3.2 secondary pumps also fail battery problems, mechanical problems<br />
2.3.3 i wanted a notification system that would let me know that the water level in my sump was rising. i wanted it set so that if the water level hits where the secondary system kicks in i would get some ind of notification. i wanted a system that would not use python or some kind of 'home spy' system available from some friendly corporation.</p>
<p>3 <b>the solution</b></p>
<p>3.1 a raspberrry pi, a simple transistor circuit, a c library that allows access to the pi's gpio's, mutt mail client, some bash scripting and a cron job</p>
<p>
The probe is meerly 2 wires on the end of a pvc pipe. one wire is higher up on the pipe than the other when both wires are submerged, the circuit is complete. the wires are just some old stuff from a stripped out ethernet cable. you could easily cascade anumber of these circuits and provide a water level meter something like this,<br />

<img src="https://www.homemade-circuits.com/wp-content/uploads/2019/06/water-level.jpg" alt="water level meter" /><br />
, instead of running leds, you'd hook each end to a gpio pin on the pie.
</p>
<p>
In picture 2, the closeup you can see the probe its the small pvc pipe with the blue wires running along the side. I attached the end of the wires to the pipe by stripping the ends and wrapping them around a small 1/2" self tapping screw. then I screwed one in towards the bottom and on higher up. the one higer up determines when the water alarm goes off. 
</p>


<p>4 <b>implementation</b></p>
<p>4.1 raspberry pi 3b+<br />
4.1.1 install slackware<br />
<a href="https://sarpi.fatdog.eu/" class="uri">https://sarpi.fatdog.eu/</a><br />
slackware-arm<br />
<a href="https://arm.slackware.com/" class="uri">https://arm.slackware.com/</a><br />
podcast<br />
<a href="https://shows.acast.com/slackchat" class="uri">https://shows.acast.com/slackchat</a><br />
4.1.2 access to gpio's<br />
4.1.2.1 initially sysfs, its deprecated<br />
<a href="https://www.kernel.org/doc/Documentation/ABI/obsolete/sysfs-gpio" class="uri">https://www.kernel.org/doc/Documentation/ABI/obsolete/sysfs-gpio</a><br />
4.1.2.2 i was unable to get libgpio to compile<br />
4.1.2.3 other solutions python. wiringpi, project dead<br />
4.1.2.4 a library pigpiod<br />
<a href="https://abyz.me.uk/rpi/pigpio/pigpiod.html" class="uri">https://abyz.me.uk/rpi/pigpio/pigpiod.html</a><br />
4.1.2.5 slackbuilds pigpiod<br />
<a href="https://slackbuilds.org/" class="uri">https://slackbuilds.org/</a><br />
4.1.3 the circuit<br />
4.1.3.1 a rework of a forrest mims water alarm circuit<br />
<a href="https://en.wikipedia.org/wiki/Forrest_Mims" class="uri">https://en.wikipedia.org/wiki/Forrest_Mims</a></p>
<p><em>circuit diagram</em><br />
<img src="https://hackerpublicradio.org/eps/hpr3217/img_003.jpg" alt="circuit diagram" /></p>
<p>4.1.4 mutt<br />
<a href="https://smalldata.tech/blog/2016/09/10/gmail-with-mutt" class="uri">https://smalldata.tech/blog/2016/09/10/gmail-with-mutt</a><br />
4.1.5 email to text<br />
<a href="https://20somethingfinance.com/how-to-send-text-messages-sms-via-email-for-free/" class="uri">https://20somethingfinance.com/how-to-send-text-messages-sms-via-email-for-free/</a><br />
4.1.6 the script<br />
</p>
<pre><code>#!/bin/bash

SENSOR=4
RELAY=17
INPUT=0
OUTPUT=1
ON=1
OFF=0

ADDRESS1=&lt;your-phone-number&gt;@vtext.com

#if its 6am send system running sanity text
if [ $(date | cut -c 12-16) == &quot;06:00&quot; ]; then

#check to make sure daemon is running
if [ &quot;$(pidof pigpiod)&quot; == &quot;&quot; ]; then
   echo &quot;Something is wrong, pigpiod is not running.&quot; | mutt -s &quot;mutt message&quot; $ADDRESS1
   else
   #make sure pin 4 is input, pin 17 output
   if [ &quot;$(pigs modeg $SENSOR)&quot; = $OUTPUT ]; then
      pigs modes $SENSOR R
   fi
   if [ &quot;$(pigs modeg $RELAY)&quot; = $INPUT ]; then
      pigs modes $RELAY W
   fi
      echo &quot;System running.&quot; | mutt -s &quot;mutt message&quot; $ADDRESS1
   fi
fi

#if its the first wednesday of the month, run a system test
if [ $(date | cut -c 1-3) `= &quot;Wed&quot; ] &amp;&amp; [ $(date | cut -c 12-16) =&#39; &quot;12:00&quot; ] &amp;&amp; [ $(date | cut -c 9-10) -lt &quot;8&quot; ]; then
   echo &quot;Monthly Test.&quot; | mutt -s &quot;mutt message&quot; $ADDRESS1
   pigs w $RELAY $ON
   sleep 1

   if [ $(pigs r $SENSOR) = 0 ]; then
     echo &quot;Test Passed!&quot; | mutt -s &quot;mutt message&quot; $ADDRESS1
   else
     echo &quot;Something is wrong!&quot; | mutt -s &quot;mutt message&quot; $ADDRESS1
   fi
fi

#check to see if water is rising, has the reading on pin 4 been driven low?
if [ $(pigs r $SENSOR) = 0 ]; then
   echo &quot;Alert! The water is rising!&quot; | mutt -s &quot;mutt message&quot; $ADDRESS1
fi</code></pre>
<p><em>testing on breadboard</em><br />
<img src="https://hackerpublicradio.org/eps/hpr3217/img_004.jpg" alt="testing on breadboard" /></p>
<p><em>strip board</em><br />
<img src="https://hackerpublicradio.org/eps/hpr3217/img_005.jpg" alt="strip board" /></p>
<p><em>final installation</em><br />
<img src="https://hackerpublicradio.org/eps/hpr3217/img_006.jpg" alt="final installation" /></p>
<p>5 <b>conclusion</b></p>
<p>5.1 fun project, shows the power of linux and floss and hope it inspires you</p>
