Biologist
Posts: 15
Joined: Mon Sep 17, 2018 4:43 am

wildlife cam help

Mon Sep 17, 2018 5:49 am

Hello I have a pi3 with camera running stretch desktop. I am trying to build a triggered camera for a lab experiment where the camera is triggered to start recording when a fast vibration sensor is triggered and then stop when another sensor is triggered down stream. i am completely new to linux and python. any help with this would be great.

B.Goode
Posts: 6544
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: wildlife cam help

Mon Sep 17, 2018 11:08 am

Welcome to the Raspberry Pi forums..

There are lots of nature/wildlife webcam projects documented on the Raspberry Pi Foundation blog: https://www.raspberrypi.org/blog/


Perhaps something there might provide inspiration or guidance?


For a 'first steps' approach to connecting many common types of sensor to an RPi, have look at the Raspberry Pi Foundation 'Physical Computing' tutorial -
https://projects.raspberrypi.org/en/pro ... -computing

Biologist
Posts: 15
Joined: Mon Sep 17, 2018 4:43 am

Re: wildlife cam help

Mon Sep 17, 2018 2:37 pm

thanks for the tutorial steering. I know how the sensors work but just needed to know how to control them with the board.

I have seen several camera builds but they all rely on Wifi. My problem is I need to record an animals choice in and experiment inside a walkin cooler where wifi is not guaranteed. I just need it to store the file on a flash drive which I know is possible.

I currently have pi 3 with wifi running the stretch desktop OS and have installed motion but pycurl keeps stopping the process. This is the site I have been following. https://github.com/ccrisan/motioneye/wi ... n-Raspbian.

I have loaded MotionEYEOS on another sd card but I am not sure how it actually works without wifi or really how to edit anything on it. I also have zero without wifi that I originally wanted to use but seems without the wifi it does not want to work.

alphanumeric
Posts: 1538
Joined: Tue Jan 19, 2016 2:17 pm
Location: Sydney, Nova Scotia, Canada

Re: wildlife cam help

Mon Sep 17, 2018 3:29 pm

Motion Eye OS will not even boot up without an Ethernet connection. With the stock install it looks for an ethernet connection and will just endlessly reboot until it finds one. Once it has one you can log in and setup a WIFI connection if you want, and change any of the other settings. I don't know what happens you setup the WIFI and it doesn't get a connection? I have three cameras setup with Motion Eye that stream video over my LAN via WIFI. I tried and failed to get the motion detection to work reliably the way I wanted. I'm just streaming to my PC's Web Browser. I can manually set it to record continuously if I want. Or record the feed on my PC from my PC.

User avatar
neilgl
Posts: 243
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near Aston Martin factory

Re: wildlife cam help

Mon Sep 17, 2018 3:39 pm

Maybe you could use the vibration sensors to set an input high on the pi, then use that to start recording images.
e.g. using GPIO 18, cam.py

Code: Select all

from picamera import PiCamera
camera = PiCamera()
import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BCM)
GPIO.setup(18,GPIO.IN)
while True:
    input_value = GPIO.input(18)
    if input_value == 1:
      camera.capture('/home/pi/Desktop/image.jpg')
    sleep(1)
You could adapt that to check for the downstream sensor being triggered to stop recording. No wifi needed.
Is the issue with the sensors interfacing to the pi GPIO 3.3v inputs or something else?

Biologist
Posts: 15
Joined: Mon Sep 17, 2018 4:43 am

Re: wildlife cam help

Tue Sep 18, 2018 6:10 pm

Code: Select all

  ode: Select all

from picamera import PiCamera
camera = PiCamera()
import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BCM)
GPIO.setup(18,GPIO.IN)
while True:
    input_value = GPIO.input(18)
    if input_value == 1:
      camera.capture('/home/pi/Desktop/image.jpg')
    sleep(1)   
I just have never done this before so I am just trying understand how to tackle this. Very much visual mechanical learner. So if I understand the code you sent, if I enter another segment to turn off the camera like your true statement it should work? How would I add the IR leds to turn on as well? adding another statement in the while true?

i.e. minus the led on/off sequence

Code: Select all

 
 from gpiozero import LED, 
 from picamera import PiCamera
camera = PiCamera()
led = LED(17)
button = Button(18)
import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BCM)
GPIO.setup(18,GPIO.IN)
while True:
    input_value = GPIO.input(18)
    if input_value == 1
      camera.start_recording('/home/pi/video.h264')
      button.wait_for_press()
      led.toggle()
GPIO.setup(23,GPIO.IN)
while True:
    input_value = GPIO.input(23)
    if input_value == 1
     camera.stop_recording()
     button.wait_for_press()
     led.toggle()
sleep(10)  
Last edited by Biologist on Tue Sep 18, 2018 8:15 pm, edited 1 time in total.

DirkS
Posts: 9478
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: wildlife cam help

Tue Sep 18, 2018 6:41 pm

Biologist wrote:
Tue Sep 18, 2018 6:10 pm
I just have never done this before
Well, for a start you should any Python code in code tags...
https://www.raspberrypi.org/forums/view ... 32&t=84477

Biologist
Posts: 15
Joined: Mon Sep 17, 2018 4:43 am

Re: wildlife cam help

Tue Sep 18, 2018 8:20 pm

Sorry I have since fixed it.

User avatar
neilgl
Posts: 243
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near Aston Martin factory

Re: wildlife cam help

Wed Sep 19, 2018 7:23 am

I might take a look at that when I get back from working in Woking
(but I don't have any IR LEDS or vibration sensors)

User avatar
joan
Posts: 13613
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: wildlife cam help

Wed Sep 19, 2018 7:30 am

How much is in your budget. You could buy a decent motion detect security camera to record to internal SD card for less than a 100 GBP.

User avatar
neilgl
Posts: 243
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near Aston Martin factory

Re: wildlife cam help

Thu Sep 20, 2018 3:25 pm

You probably want something simpler - like this
Press button - led comes on and video starts recording to /home/pi/Desktop
Release button - led goes off and video stops recording

Code: Select all

from gpiozero import Button
from gpiozero import LED
from picamera import PiCamera
from signal import pause

button = Button(18)
led = LED(17)
camera = PiCamera()

def capture():
    led.on()
    camera.start_recording('/home/pi/Desktop/video.h264')

def stopcapture():
    camera.stop_recording()
    led.off()

button.when_pressed = capture
button.when_released = stopcapture

pause()

Biologist
Posts: 15
Joined: Mon Sep 17, 2018 4:43 am

Re: wildlife cam help

Thu Sep 20, 2018 8:28 pm

If I set the button (vibration sensor) to turni the led and tha camera on when the button is pressed and then off when the button is released wont it just kick the camera on until it stops receiving current from the button? Or can I just assign the release to a different GPIO?

User avatar
neilgl
Posts: 243
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near Aston Martin factory

Re: wildlife cam help

Fri Sep 21, 2018 3:39 pm

That code stops the recording when the (single) button is released.
Yes you could use a different GPIO to stop the capture I.e stopcapture on a when_pressed function for button2.

Biologist
Posts: 15
Joined: Mon Sep 17, 2018 4:43 am

Re: wildlife cam help

Sun Sep 23, 2018 2:16 am

Ok so I finally got a chance to try this. I used this code

Code: Select all

from picamera import PiCamera
from gpiozero import LED
from gpiozero import Button
from signal import sleep

button = Button(17)
button2 = Button(27)
button3 = Button(10)
led = LED(4)
led2 = LED(22)
camera = PiCamera()
camera.rotation = 90

def capture():
	led.on()
	camera.start_recording('/media/pi/FWL ROCKS/video.h264')
def stopcapture():
	camera.stop_recording()
	led.off()
	led2.on()
	sleep(10)
	led2.off()
button.when_pressed = capture
button2.when_pressed = stopcapture
button3.when_pressed = stopcapture

pause()
however it does not start recording and instead shows me a bunch or red. I attached a photo.
Attachments
IMG_0350 (1).jpg
IMG_0350 (1).jpg (30.2 KiB) Viewed 680 times

Biologist
Posts: 15
Joined: Mon Sep 17, 2018 4:43 am

Re: wildlife cam help

Sun Sep 23, 2018 2:38 am

I feel like this is gotten very complicated for my purposes. I just need it to start recording when my study animal enters a chamber and stop recording when it enters the next chamber in line. I do need ir led as the chamber is blacked out. I can have it plugged in and on at all times. I should also mention that the animal is a reptile so PIR sensors are not reliable way since the reptile might be the same temperature as the sensor/enviornment.

Return to “Camera board”