Raspberry Pi based Flood Alarm

  • #1
The local fish store had a display tank break and flood half the floor space, and fish perished in the process. So I made an SMS Alarm system that might help in the event of future floods. It may save fishy lives in the future.

It uses the (free) Pushbullet service to send messages to the app on your phone. At this time I've found that Android takes the pushbullet notification and displays it like any notification. On IOS, it was just showing it inside the app but not on the lock screen, even with notifications for Pushbullet enabled. If any IOS users can indicate why this may be I'd appreciate it, as the user I built it for uses an iPhone.

Let's begin...

This guide will allow you to send notifications to your phone when flooding occurs around your aquarium. It assumes you have basic knowledge of the PI and beginner Linux skills.

All that's needed is a Raspberry Pi, two lengths of wire (try to keep it relatively short), and a wi-fI or ethernet connection.

Attach the ground wire to the GND pin. GND is the 3rd pin on the outside edge of the board.
Attach the signal wire to GPIO pin 18. Pin 18 is the 6th pin on the outside edge of the board.

If you have a Raspberry PI then you probably already have the Raspbian OS installed.
You'll also need the python install tools. Boot your PI and make sure you have what you need by installing the following from a terminal window:

sudo apt-get install build-essential python python-pip

Once the downloads are complete and the tools are installed you'll need to get the Pushbullet library. Return to the terminal window and enter:

sudo pip install pushbullet.py

Now you have just about everything you need!

Next your going to need to visit Pushbullet.com and set up an account and install the app on your phone. This part is explained on the Pushbullet website, so there's no need to go into it here.

After you have a Pushbullet account you'll want to go to settings and Create an Access Token. When you do it will show you a line of random characters. That's your Pushbullet key. It gives access to your account to applications that you use it with. Do NOT share your Pushbullet key with anyone else.

Copy those characters into a text editor. You'll need them shortly.

Return to your Raspberry PI terminal window create a file to paste the following program in. You can do this by typing the following:

sudo nano alarm.py

Copy this program into Nano by pasting it. Then put your Pushbullet key in the sixth line of the program where it tells you to do so.

import RPi.GPIO as GPIO import time import subprocess from pushbullet import Pushbullet pb = Pushbullet("PASTE YOUR PUSHBULLET KEY HERE") GPIO.setmode(GPIO.BCM) GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP) while True: input_state = GPIO.input(18) if input_state == False: print('Circuit closed') push = pb.push_note("WARNING!","Water detected at floor level!") time.sleep(300)

Save your file by hitting CTRL-O and then hitting enter.

Exit Nano by hitting CTRL-X.

The program is set to check for flooding, and if it detects it send you an alert via pushbullet every 5 minutes. Place one wire at floor level, and the other wire slightly above it, enough that they don't accidentally short and close the circuit. When water connects the two wires it will send an alarm.

Run the program in a terminal window with the following command:

sudo python ./alarm.py

As long as the program is running, triggering of the switch will result in the alerts being sent to your phone.

You can also configure the script to launch automatically when the PI boots or any time a new terminal window is opened.

In your home folder, you'll want to edit .bashrc so:

sudo nano /home/pi/.bashrc

At the end of the file add:
sudo python /home/pi/alarm.py &

Additionally Pushbullet has browser plugin support that will allow you to set up notifications to go to your desktop as well. Handy for when you have your laptop with you but your phone is out of juice.

If you find this guide really useful you can always shoot me a tip at paypal.me/caseyshobbies
Or not. That's fine too
  • Thread Starter
  • #2
I'm going to have to add a resistor or something to the circuit.
Noticing that after a period it may start giving false alarms. So I think there's a charge building up in the wire.
  • #3
That's a pretty nifty idea, good if you don't have a home security setup with flood alarms available for it.
  • #4
Seams complicated. Why not just get a wireless water alarm?

  • Thread Starter
  • #5
Seams complicated. Why not just get a wireless water alarm?
Then this post wasn't for you, was it?

Similar Aquarium Threads



Top Bottom