Compare commits
23 Commits
V0.2.0
..
Time-Based
| Author | SHA1 | Date | |
|---|---|---|---|
| 3a961af1f8 | |||
| 529379ee3b | |||
| 369a64ea98 | |||
| a2152a6cf0 | |||
| b329d8a3f9 | |||
| a6d4a5ae87 | |||
| 5921a64b8f | |||
| 9e83562a5b | |||
| 4d033affa3 | |||
| c3c76f7e7c | |||
| d97bc89d52 | |||
| bf80f9230c | |||
| e336c071bf | |||
| 8f00a5a941 | |||
| 9e3c27a8dc | |||
| 19f18f1a6b | |||
| d25e59a877 | |||
| 633d5359a3 | |||
| c731847f44 | |||
| e4db614340 | |||
| 072bececb1 | |||
| 0c729180a9 | |||
| 892e2fdc8b |
@@ -1 +1,14 @@
|
|||||||
# Bugmotion
|
# Bugmotion
|
||||||
|
|
||||||
|
This software is mainly intended to detect and capture bugs that are in the given area.
|
||||||
|
|
||||||
|
This is done by using the following Hardware
|
||||||
|
|
||||||
|
- Pi 4 - https://www.raspberrypi.com/products/raspberry-pi-4-model-b/
|
||||||
|
- PIR Sensor - https://www.jaycar.com.au/arduino-compatible-pir-motion-detector-module/p/XC4444?pos=1&queryId=7eb275c75b51605afa44da86b7b83db3
|
||||||
|
- Picamera - https://www.raspberrypi.com/products/camera-module-v2/
|
||||||
|
- LED Light - Any GPIO Compatible Kind
|
||||||
|
- 10K Ohm Resistor - https://www.jaycar.com.au/10k-ohm-0-5-watt-metal-film-resistors-pack-of-8/p/RR0596?pos=13&queryId=60433157b9802b233ba599eda37e22f4&sort=0.relevance
|
||||||
|
|
||||||
|
|
||||||
|
The Current Software uses Python to capture the Pictures of the bugs.
|
||||||
|
|||||||
@@ -1,54 +1,76 @@
|
|||||||
import RPi.GPIO as GPIO #Used to Import the LED
|
import RPi.GPIO as GPIO #Used to Import the LED
|
||||||
import time #Used to allow wait times
|
import time #Used to allow wait times
|
||||||
from picamera import PiCamera #Used to import the Camera
|
from picamera import PiCamera #Used to import the Camera
|
||||||
from gpiozero import MotionSensor #Used to import the MotionSensor
|
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
pir = MotionSensor(4)
|
|
||||||
camera = PiCamera() #Camera Initialization
|
camera = PiCamera() #Camera Initialization
|
||||||
GPIO.setwarnings(False)
|
GPIO.setwarnings(False)
|
||||||
GPIO.setmode(GPIO.BCM) #Setting the GPIO Mode
|
GPIO.setmode(GPIO.BCM) #Setting the GPIO Mode
|
||||||
GPIO.setup(22, GPIO.OUT) #LED output pin
|
GPIO.setup(22, GPIO.OUT) #LED Flash Output
|
||||||
|
GPIO.setup(27, GPIO.OUT) #LED indicator output
|
||||||
|
|
||||||
cwd = os.getcwd() #Sets the Current Working Directory
|
cwd = os.getcwd() #Sets the Current Working Directory
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#To stabilize sensor and Camera
|
def bugmotion():
|
||||||
time.sleep(2)
|
GPIO.output(22, 0) #Sets light off
|
||||||
while True:
|
|
||||||
|
|
||||||
#Waits for Motion from PIR Sensor
|
print("\nProgram Running!")
|
||||||
pir.wait_for_motion()
|
for i in range(3):
|
||||||
|
time.sleep(1)
|
||||||
print("Bug detected")
|
GPIO.output(27, 1)
|
||||||
|
time.sleep(1)
|
||||||
#Turns on the LED Flash
|
GPIO.output(27, 0)
|
||||||
GPIO.output(22, 1)
|
if i == 3:
|
||||||
|
break
|
||||||
#Sets Img path and filename, Saves to Working directory of Script
|
|
||||||
print("\nFile will be Saved in: " + cwd + "/Pictures")
|
|
||||||
file_name = cwd + "/Pictures/Capture_" + str(time.time()) + ".jpg"
|
|
||||||
print("\nFile Name is: " + file_name)
|
|
||||||
|
|
||||||
|
|
||||||
#Used to wait for 0.1 Seconds for Camera to be ready
|
#To stabilize the Camera
|
||||||
time.sleep(0.1)
|
time.sleep(2)
|
||||||
|
while True:
|
||||||
|
|
||||||
#Saves File
|
#Turns on the LED Flash
|
||||||
camera.capture(file_name)
|
GPIO.output(22, 1)
|
||||||
|
|
||||||
#Sets PIR Sensor back to waiting for motion
|
#Sets Img path and filename, Saves to Working directory of Script
|
||||||
pir.wait_for_no_motion()
|
# Grab the current time
|
||||||
|
filePath = cwd + "/Pictures/"
|
||||||
#Used to turn off the LED after 0.2 Secs
|
currentTime = datetime.now()
|
||||||
time.sleep(0.2)
|
picTime = currentTime.strftime("%Y-%m-%d-%H-%M-%S")
|
||||||
|
picName = "Capture-" + picTime + '.jpg'
|
||||||
#Used to turn off the LED
|
completeFilePath = filePath + picName
|
||||||
GPIO.output(22, 0)
|
#file_name = cwd + "/Pictures/Capture_" + str(time.time()) + ".jpg"
|
||||||
|
print("\nFile Name is: " + completeFilePath)
|
||||||
|
|
||||||
|
|
||||||
|
#Used to wait for 0.1 Seconds for Camera to be ready
|
||||||
|
time.sleep(0.1)
|
||||||
|
|
||||||
|
#Saves File
|
||||||
|
camera.capture(completeFilePath)
|
||||||
|
|
||||||
|
#Used to turn off the LED after 0.2 Secs
|
||||||
|
time.sleep(0.2)
|
||||||
|
|
||||||
|
#Used to turn off the LED
|
||||||
|
GPIO.output(22, 0)
|
||||||
|
|
||||||
|
#Used to wait 5 minutes for camera to take a photo
|
||||||
|
time.sleep(300)
|
||||||
|
print("\nTaking photo!")
|
||||||
|
|
||||||
|
def exit_handler():
|
||||||
|
print('Program Shutting Down!')
|
||||||
|
GPIO.output(22, 0) # turns off LED
|
||||||
|
|
||||||
|
bugmotion() #Starts Program
|
||||||
|
atexit.register(exit_handler)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user