Page 1 of 1

where to start

Posted: Mon May 11, 2015 6:15 pm
by Jones23
Hi,
Please help, as part of a college project I am trying to use the RPi B+ to take a photo when triggered by a pir sensor. I have practically zero experience with using a Pi and not sure of many things :)
Where do I start? how do I open a file to save the code onto so it doesn't disappear when I turn it off? is there a viewer on the RPi that will show the pic taken? Basically im lost as to how to best start this and need some advice for a dummy. If anyone can advise me that would be amazing.
Does anyone know if there is somewhere i can go and meet some experts in person?

any advice would be greatly appreciated
K jones

Re: where to start

Posted: Mon May 11, 2015 8:32 pm
by B.Goode
The Raspberry Pi Foundation project here - https://www.raspberrypi.org/learning/parent-detector/ - has a lot in common with what you want to achieve. From the same source there are loads of other Getting Started resources here: https://www.raspberrypi.org/help/

For help in person, look out via the Community Pages for a Raspberry Jam in your area, or look out for other similar activities such as CoderDojo or Hackspaces.

Re: where to start

Posted: Wed May 13, 2015 1:57 pm
by gordon77
Try this...assuming you've got to the stage of trying to write some Python software..

Code: Select all

import RPi.GPIO as GPIO
import os
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO_PIR = 7  # pin 26
GPIO.setup(GPIO_PIR,GPIO.IN)

print "  Press Ctrl & C to Quit"

try:
   
   while GPIO.input(GPIO_PIR)==1:
       Motion = 0
   print "  Ready"
   
   Motion = 0
   
   while True :
      if GPIO.input(GPIO_PIR)==1:
         if Motion == 0:
            print "  Motion detected!"
            path = "raspistill -n -o photo.jpg"
            os.system (path)
            Motion = 1
         
      else:
         if Motion == 1:
            print "  Clear "
            Motion = 0
         

except KeyboardInterrupt:
  print "  Quit"
It assumes you have a PIR detector wired to pin26 (GPIO7), and a Pi camera installed.

Re: where to start

Posted: Wed May 13, 2015 5:38 pm
by Jones23
Thanks, Ive used the parent detector and have made a file that with the PIR triggering the camera. I now know how to recall each video file taken as it shows. Im unsure how to change the settings so I can dictate the length of time of the video. I can follow instruction but really have little understanding of writing code with python or anything else. Ultimately I want the video to send an email and/or send the video to a viewer on an iPhone. Is this possible? I'm just trying to read through all the resources but losing lots of time if looking in the wrong place so any help advice again really appreciated. Really looking to meet with someone if possible im in bucks, uk and will check again on the forums for a jam.
Cheers guys

Re: where to start

Posted: Wed May 13, 2015 5:56 pm
by gordon77

Re: where to start

Posted: Wed May 13, 2015 7:40 pm
by Jones23
Thanks Gordon,
Im happy with the basic functions of the camera now. Can I not adjust the code ive got from the parent detector. It appears to be by default a 5 sec video so I just change this don't I? but I cant see where it is in the code
Once that's done I want to send it to a viewer on my iPhone or as an email/sms whichever is easier. Ive read the html link regarding sending emails but I didn't understand what I was reading. I need a human teacher I think! :oops:

Re: where to start

Posted: Wed May 13, 2015 7:43 pm
by kusti8
I recommend reading a brief tutorial on Python, to get the works of it and Linux, before you delve into it all here. It will make life so much easier!

For the iPhone part, you could make your own app with sockets (which I did which takes way more time) or send an email which would be the easiest.

Re: where to start

Posted: Wed May 13, 2015 8:06 pm
by B.Goode
Jones23 wrote:Thanks Gordon,
Im happy with the basic functions of the camera now. Can I not adjust the code ive got from the parent detector. It appears to be by default a 5 sec video so I just change this don't I? but I cant see where it is in the code
https://picamera.readthedocs.org/en/rel ... -to-a-file

I need a human teacher I think!
Since this is a college project, don't you have one already?

Re: where to start

Posted: Wed May 13, 2015 8:11 pm
by gordon77
Jones23 wrote:Thanks Gordon,
Im happy with the basic functions of the camera now. Can I not adjust the code ive got from the parent detector. It appears to be by default a 5 sec video so I just change this don't I? but I cant see where it is in the code
Once that's done I want to send it to a viewer on my iPhone or as an email/sms whichever is easier. Ive read the html link regarding sending emails but I didn't understand what I was reading. I need a human teacher I think! :oops:
If l'd read the links provided l'd have seen you are using picamera!

Other responders have sent links to the picamera docs where you'll see how to set the length of the video

Gordon