Sump Pump Water Level: the Hardware

What you need:

* 2  X pieces of wood 4X6. 1/4” and the other 1/2” thick
* 1 X 3 inches pipe. length varies depending of the deep of your pit.
* A couple of screw
* 1 X 1k resistor
* 1  X Raspberry pi
* 1X HC-SR04 ultrasonic sensor
* Wire Sump Pump Water Level the Hardware

Step 1: The Sensor

  Step 1 Sump Pump Water Level the Hardware
The sensor mesure the time it took to an ultrasound to get back to it.

Step 2: Create the Base

  Step 2 Step Sump Pump Water Level the Hardware First, cut a 3 inches hole in the thicker 4”X6” piece of wood. Stick the pieces of wood together.

Step 3: Prepare the Base for the Sensor.

  Step 3 Sump Pump Water Level the Hardware

Drill two 3/4” hole in the center of the 3” hole. The distance between them is 1”. Add 3 screw to hold the pipe.

Step 4: Add the Sensor

Step 4 Sump Pump Water Level the Hardware

Mount the sensor on 2 spacer to keep the sensor level. Stick the sensor to the spacer with hot glue.

Step 5:

Step 5 Sump Pump Water Level the Hardware

Add 8 screw to hold the wired. Optional: add a plexyglass cover to protect your masterpiece.

Step 6: Connection

  Step 6 Sump Pump Water Level the Hardware

How to connect to the raspberry:

Pin 1 GND: connect to the ground of the rasp.
Pin 2 Echo to gpio 9
Pin 3 Trig to gpio 11. Add a 1k resistor
Pin 4 VCC to the 3.3V

Note 1: According to the manual, the sensor used 5v. But it work perfectly at 3.3v.

Note 2: Beware, we see the back of the sensor in this pic, so the order of the pin are reverse.

Step 7: Add the Pipe

Step 7 Sump Pump Water Level the Hardware

Add the pipe to the controller and thighten the 3 screw.

Step 8: The Code

Step 8 Sump Pump Water Level the Hardware

First, you need to save the code on the rasp with the extension *.py. Then run the command python myfile.py

Code:

#!/usr/bin/python
#+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#|R|a|s|p|b|e|r|r|y|P|i|-|S|p|y|.|c|o|.|u|k|
#+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#
# ultrasonic_1.py
# Measure distance using an ultrasonic module
#
# Author : Matt Hawkins
# Date   : 09/01/2013

# Import required Python libraries
import time
import RPi.GPIO as GPIO

# Use BCM GPIO references
# instead of physical pin numbers
GPIO.setmode(GPIO.BCM)

# Define GPIO to use on Pi
GPIO_TRIGGER = 11
GPIO_ECHO = 9

# You need to change the variable "compensation" according to the distance from the edge of the pit to the sensor
compensation = -11

print "Ultrasonic Measurement"

# Set pins as output and input
GPIO.setup(GPIO_TRIGGER,GPIO.OUT)  # Trigger
GPIO.setup(GPIO_ECHO,GPIO.IN)      # Echo

# Set trigger to False (Low)
GPIO.output(GPIO_TRIGGER, False)

# Allow module to settle
time.sleep(0.5)

# Send 10us pulse to trigger
GPIO.output(GPIO_TRIGGER, True)
time.sleep(0.00001)
GPIO.output(GPIO_TRIGGER, False)
start = time.time()
while GPIO.input(GPIO_ECHO)==0:
start = time.time()

while GPIO.input(GPIO_ECHO)==1:
stop = time.time()

# Calculate pulse length
elapsed = stop-start

# Distance pulse travelled in that time is time
# multiplied by the speed of sound (cm/s)
distance = elapsed * 34000

# That was the distance there and back so halve the value
distance = distance / 2
distance = distance + compensation

print "Distance : %.1f" % distance

# Reset GPIO settings
GPIO.cleanup()

Note: You need to change the variable “compensation” according to the distance from the edge of the pit to the sensor

Note 2: The distance are in cm.

Thank to Matt Hawkins for this code

Step 9: Final Result

Step 9 Sump Pump Water Level the Hardware

Voila! All you have to do now is to fixed the sensor in your pit.

Step 10: Next Tutorial

Step 10 Sump Pump Water Level the Hardware

In the next week, I will show you how to present the result of the sensor on a web page.

I’m not as good as I want to in english, so feel free to send me any correction in my text.

Source:  Sump Pump Water Level: the Hardware

0/5 (0 Reviews)

About The Author

Hassan Zaka

I am an expert in accounting and have diverse experience in technical writing. I have written for various industries on finance, business, and technology. I have a clear and simple writing style and use infographics and diagrams to make my writing engaging. I can benefit any organization needing technical writing services.

Follow Us:
LinkedinTwitter
Home Automation >> Custom Home Automation Projects >> Raspberry Pi >> Sump Pump Water Level: the Hardware

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top