Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Old July 30th 20, 08:03 AM posted to rec.radio.amateur.moderated,rec.radio.amateur.equipment
external usenet poster
 
First recorded activity by RadioBanter: May 2017
Posts: 21
Default [ZS6BNE] Python on the Pi - My trail camera


ZS6BNE's Blog

///////////////////////////////////////////
Python on the Pi - My trail camera

Posted: 29 Jul 2020 02:09 AM PDT
https://zs6bne.wordpress.com/2020/07...-trail-camera/


My old Pi Too slow as a desktop PC




Ive had this old Pi for quite a few years now. Its so slow that it cant be
used for much other than playing around with it but its ideal for the
purpose of being a trail camera. I fitted the PiCam module and also a WiFi
adapter. This model, unlike the latest models, was pretty much a bare bones
computer.




So I did a little Python programming to talk to the camera module and just
recently included a facility to send me a mail whenever a photo was taken.




In this case too, I use an external infrared movement detector which has a
normally closed contact. The contact is wired between ground and pin 17 on
the GPIO port. Contact bounce has been handled within the Python program. A
simple solution with exciting possibilities.








Here is my latest Python code.



from picamera import PiCamera
from pygame import *

screen = display.set_mode ((640, 128))
display.set_caption ('Eds trail camera INITILIZED - Press q to Quit')

import smtplib
import time
import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.IN, GPIO.PUD_UP)

camera = PiCamera()

stop = False
counter = 0

def my_callback(channel):
snaptime = time.strftime('%A %d %b %Y %H:%M:%S')

smtpUser = '
smtpPass = 'yourpassword'

toAdd = '
fromAdd = smtpUser

subject = snaptime
header = 'To: ' + toAdd + '\n' + 'From: ' + fromAdd
+ '\n'+ 'Subject: ' + subject
body = 'Eds trail camera was triggered through movement detection. '

print header + '\n' + body

s = smtplib.SMTP('smtp.gmail.com', 587)

s.ehlo()
s.starttls()
s.ehlo()

s.login(smtpUser,smtpPass)
s.sendmail(fromAdd, toAdd, header + '\n\n' + body)

global counter

# DEBOUNCE Code

if (counter = 10):
counter = 0

camera.annotate_text_size = 30
camera.annotate_text = snaptime

time.sleep(0.1) # Allow 100 ms for IR LED's to switch on (At
night)
camera.capture('/home/pi/snapshot_' + snaptime + '.jpg')

print ('Camera was tiggered on ' + snaptime)

camera.rotation = 180

#camera.start_preview()

GPIO.add_event_detect(17, GPIO.RISING, callback = my_callback)

while (stop == False) :

time.sleep(0.1)
counter = counter + 1 # Allow for trigger contact bounce

for e in event.get():
if e.type == KEYDOWN:
if (e.key == K_q):
print ('Trail camera stopped')
stop = True
else:
print('Press q to Quit')

#camera.stop_preview()




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[ZS6BNE] ZS6BNE - My Morse Code (CW) Journey ZS6BNE via rec.radio.amateur.moderated Admin Dx 0 July 18th 20 03:10 PM
[ZS6BNE] RaDAR - Preparing the trail ZS6BNE via rec.radio.amateur.moderated Admin Antenna 0 February 25th 19 08:51 AM
[K0NR] Yaesu FT-1DR: A Trail Friendly SOTA HT K0NR via rec.radio.amateur.moderated Admin Moderated 0 March 24th 16 08:00 PM


All times are GMT +1. The time now is 10:30 AM.

Powered by vBulletin® Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright 2004-2020 RadioBanter.
The comments are property of their posters.
 

About Us

"It's about Radio"

 

Copyright © 2017