Mouse Early Warning System
by Simon Culverhouse in Living > Pest Control
1196 Views, 6 Favorites, 0 Comments
Mouse Early Warning System
Living in the countryside, mouse infestation can be a problem. The biggest issue is that by the time we know that they are in the house, for example, we see one or food in the larder starts to get nibbled, we're infested.
We find that mouse invasion occurs at various times throughout the year. Having traps permanently in place means checking regularly to see if they have caught anything. As these are in the roofspace (where the mice tend to arrive first), it's not easy and so doesn't get done.
With this motion detection system in place we have been able to deal with the mice as soon as they start to move in.
For this and my other projects visit my website www.myprojectcorner.com
Supplies
- Raspberry Pi
- HC-SR501 PIR Motion sensor
- Plastic electrical cable connector box
- Length of 4 core telephone cable
- Dupont connectors
Drill Box Lid
Using a 22mm wood drill bit, make a hole in the lid of the plastic cable box.
Connection Cable
Make up the cable to connect the sensor box to the Raspberry Pi. I am connecting to an existing Pi which is around 3 meters away.
Cut 3 female/female Dupont wires in half, and solder to each end of the length of cable (making sure the colors correspond at each end). Protect from short circuits with heat shrink or electrical tape.
Attach the PIR Dome
Using a hot glue gun (or just glue), fix the infrared sensor to the lid. Pass one end of the cable through the side hole, and connect to the sensor.
Finish to Motion Sensor
Connect one end of the cable to the PIR sensor, and close the box.
Connection to the Raspberry Pi
Connect
PIR Sensor to Raspberry Pi
- VCC to 5v (pin 2 or 4)
- GRD to GRD (pin 6 or 9)
- OUT to GPIO4 (pin 7)
Python Script
I use Free Mobile (France) and so connect to the Free SMS API to send text messages. I would think most other mobile networks have a similar service for home automation.
Create a new Python file, copy in the following code.If using Free Mobile enter details for user and pass, then save the file.
#!/usr/bin/python3 import urllib.request from gpiozero import MotionSensor pir_mice = MotionSensor(4) url = "https://smsapi.free-mobile.fr/sendmsg?user=********&pass=********&msg=Mouse+Detected" while True: pir_mice.wait_for_motion() print("Mouse!") urllib.request.urlopen(url) pir_mice.wait_for_no_motion()
Now run the python script and wait for a mouse alert on your phone.
It may be overkill to use a Raspberry Pi just to run one sensor, I already have a Pi in the loft running other stuff.
I'm now working on a portable version using an esp8266 board.