22 Commits

Author SHA1 Message Date
Jordan-Fielding
529379ee3b Merge pull request #4 from Jordan-Fielding/Development
Update main.py
2022-07-11 10:52:17 +10:00
Jordan-Fielding
369a64ea98 Update main.py 2022-07-11 10:49:10 +10:00
Jordan-Fielding
a2152a6cf0 Update main.py 2022-07-08 14:00:05 +10:00
Jordan-Fielding
b329d8a3f9 Update main.py 2022-07-08 13:59:48 +10:00
Jordan-Fielding
a6d4a5ae87 Merge pull request #3 from Jordan-Fielding/Development
Update main.py
2022-07-08 13:58:31 +10:00
Jordan-Fielding
5921a64b8f Update main.py 2022-07-07 15:36:48 +10:00
Jordan-Fielding
9e83562a5b Update main.py 2022-07-07 15:21:30 +10:00
Jordan-Fielding
4d033affa3 Update main.py 2022-07-07 15:19:33 +10:00
Jordan-Fielding
c3c76f7e7c Update main.py 2022-07-07 15:18:02 +10:00
Jordan-Fielding
d97bc89d52 Update main.py 2022-07-07 15:15:46 +10:00
Jordan-Fielding
bf80f9230c Update main.py 2022-07-07 15:11:29 +10:00
Jordan-Fielding
e336c071bf Update main.py 2022-07-07 10:59:04 +10:00
Jordan-Fielding
8f00a5a941 Update main.py 2022-07-07 10:56:47 +10:00
Jordan-Fielding
9e3c27a8dc Update main.py 2022-07-07 10:42:48 +10:00
Jordan-Fielding
19f18f1a6b Update main.py 2022-07-07 10:40:35 +10:00
Jordan-Fielding
d25e59a877 Update main.py 2022-07-07 10:35:45 +10:00
Jordan-Fielding
633d5359a3 Update main.py 2022-07-06 11:13:46 +10:00
Jordan-Fielding
c731847f44 Merge branch 'Production' of https://github.com/Jordan-Fielding/Bugmotion into Production
 Conflicts:
	main.py
2022-07-06 11:09:58 +10:00
Jordan-Fielding
e4db614340 Update main.py 2022-07-06 10:10:33 +10:00
Jordan-Fielding
072bececb1 Update main.py 2022-07-06 10:08:38 +10:00
Jordan-Fielding
0c729180a9 Update README.md 2022-07-05 16:31:28 +10:00
Jordan-Fielding
892e2fdc8b Update main.py 2022-07-05 16:17:56 +10:00
2 changed files with 73 additions and 29 deletions

View File

@@ -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.

87
main.py
View File

@@ -2,53 +2,84 @@ import RPi.GPIO as GPIO #Used to Import the LED
import time #Used to allow wait times
from picamera import PiCamera #Used to import the Camera
from gpiozero import MotionSensor #Used to import the MotionSensor
from datetime import datetime
from subprocess import call
import os
pir = MotionSensor(4)
camera = PiCamera() #Camera Initialization
GPIO.setwarnings(False)
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
#To stabilize sensor and Camera
time.sleep(2)
while True:
def bugmotion():
GPIO.output(22, 0) #Sets light off
#Waits for Motion from PIR Sensor
pir.wait_for_motion()
print("Bug detected")
#Turns on the LED Flash
GPIO.output(22, 1)
#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)
print("\nProgram Running!")
for i in range(3):
time.sleep(1)
GPIO.output(27, 1)
time.sleep(1)
GPIO.output(27, 0)
if i == 3:
break
#Used to wait for 0.1 Seconds for Camera to be ready
time.sleep(0.1)
#To stabilize sensor and Camera
time.sleep(2)
while True:
#Saves File
camera.capture(file_name)
#Waits for Motion from PIR Sensor
pir.wait_for_motion()
#Sets PIR Sensor back to waiting for motion
pir.wait_for_no_motion()
#Used to turn off the LED after 0.2 Secs
time.sleep(0.2)
#Used to turn off the LED
GPIO.output(22, 0)
print("\nBug detected")
#Turns on the LED Flash
GPIO.output(22, 1)
#Sets Img path and filename, Saves to Working directory of Script
# Grab the current time
filePath = cwd + "/Pictures/"
currentTime = datetime.now()
picTime = currentTime.strftime("%Y-%m-%d-%H-%M-%S")
picName = "Capture-" + picTime + '.jpg'
completeFilePath = filePath + picName
#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)
#Sets PIR Sensor back to waiting for motion
print("\nWaiting for no Motion!")
pir.wait_for_no_motion()
#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 stabilize Sensor and allow the Camera to refocus
time.sleep(2)
print("\nSystem Ready!")
def exit_handler():
print('Program Shutting Down!')
GPIO.output(22, 0) # turns off LED
bugmotion() #Starts Program
atexit.register(exit_handler)