imdavid95
Posts: 8
Joined: Sat May 31, 2014 10:54 pm

PARENT DETECTOR (PIR MODULE)

Sat May 31, 2014 11:02 pm

Salve a tutti, cercavo di seguire questa guida --> http://www.raspberrypi.org/learning/parent-detector/
Il problema è che quando scrivo il codice in python per il modulo pir e lo compilo, mi da i seguenti errori:

riga 1: import: not found
riga 2: import: not found
riga 4: sensorPin: not found
riga 6: syntax error: word unexpected (expercting")")

Ho provato a reinstallare la libreria gpio ma da ancora lo stesso errore.
premetto che io sono un programmatore ma non ho mai utilizzato sistemi linux, quindi siate il più chiari possibile, grazie per la pazienza.

User avatar
DeeJay
Posts: 2027
Joined: Tue Jan 01, 2013 9:33 pm
Location: East Midlands, UK

Re: PARENT DETECTOR (PIR MODULE)

Sun Jun 01, 2014 6:26 am

Add a new first line - missing from the tutorial -

Code: Select all

#!/usr/bin/env python        
import RPi.GPIO as GPIO
import time

sensorPin = 7
...
How To Ask Questions The Smart Way: http://www.catb.org/~esr/faqs/smart-questions.html
How to Report Bugs Effectively: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html

imdavid95
Posts: 8
Joined: Sat May 31, 2014 10:54 pm

Re: PARENT DETECTOR (PIR MODULE)

Sun Jun 01, 2014 1:11 pm

DeeJay wrote:Add a new first line - missing from the tutorial -

Code: Select all

#!/usr/bin/env python        
import RPi.GPIO as GPIO
import time

sensorPin = 7
...

Thank you so much!
I have another problem at step 5, when i run the program:

Traceback (most recent call last):
File " ./pirCamere.py", line 5, in <module>
import picamera
ImportError: no module named picamera

I have tested the camera module and it works.

User avatar
DeeJay
Posts: 2027
Joined: Tue Jan 01, 2013 9:33 pm
Location: East Midlands, UK

Re: PARENT DETECTOR (PIR MODULE)

Sun Jun 01, 2014 1:43 pm

See Step 4 of the same tutorial.

"To control the Camera Board using Python we need to install a module called picamera. Use the following commands to do this at the Linux prompt:"
How To Ask Questions The Smart Way: http://www.catb.org/~esr/faqs/smart-questions.html
How to Report Bugs Effectively: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html

imdavid95
Posts: 8
Joined: Sat May 31, 2014 10:54 pm

Re: PARENT DETECTOR (PIR MODULE)

Sun Jun 01, 2014 4:28 pm

DeeJay wrote:See Step 4 of the same tutorial.

"To control the Camera Board using Python we need to install a module called picamera. Use the following commands to do this at the Linux prompt:"
I did it but it don't work, the same error

User avatar
DeeJay
Posts: 2027
Joined: Tue Jan 01, 2013 9:33 pm
Location: East Midlands, UK

Re: PARENT DETECTOR (PIR MODULE)

Sun Jun 01, 2014 9:13 pm

It works for me, so I don't think I can be of any more help.

(Just to check: do you have a file named picamera.py in the directory from which you are running these tests? That would confuse the import mechanism... )
How To Ask Questions The Smart Way: http://www.catb.org/~esr/faqs/smart-questions.html
How to Report Bugs Effectively: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html

User avatar
MattHawkinsUK
Posts: 538
Joined: Tue Jan 10, 2012 8:48 pm
Location: UK
Contact: Website

Re: PARENT DETECTOR (PIR MODULE)

Sun Jun 01, 2014 9:57 pm

Make sure you do :

Code: Select all

sudo apt-get update
before installing picamera.
My Raspberry Pi blog and home of the BerryClip Add-on board : http://www.raspberrypi-spy.co.uk/
Follow me on Google+, Facebook, Pinterest and Twitter (@RPiSpy)

User avatar
DougieLawson
Posts: 36322
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: PARENT DETECTOR (PIR MODULE)

Mon Jun 02, 2014 8:54 am

You will also want to do

Code: Select all

sudo raspi-config
to enable the camera (but do not choose the reboot on exit this time) because you'll also want

Code: Select all

sudo apt-get install rpi-update && sudo rpi-update && sudo reboot
to get the latest firmware.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

imdavid95
Posts: 8
Joined: Sat May 31, 2014 10:54 pm

Re: PARENT DETECTOR (PIR MODULE)

Mon Jun 02, 2014 9:51 am

I did all you write, here ( https://www.mediafire.com/?7k8o4lxwufm4jg0 ) there is the link to download the screenshot of the photo, where you can see the error message.. i can't connect the raspberry on internet

imdavid95
Posts: 8
Joined: Sat May 31, 2014 10:54 pm

Re: PARENT DETECTOR (PIR MODULE)

Tue Jun 03, 2014 8:15 pm

Please i need really help.. is for my Term Paper

User avatar
DougieLawson
Posts: 36322
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: PARENT DETECTOR (PIR MODULE)

Tue Jun 03, 2014 8:31 pm

So you don't have a internet connection. Please post the output from the following

ifconfig -a
route -n
ping -c3 192.168.ggg.ggg # your home router/gateway address
cat /etc/resolv.conf
ping -c3 8.8.8.8 # google
ping -c3 google.com


On your windows machine
ipconfig /all

Check the wire between your RPi and your home router, check the LEDs on both ends of the wire.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

imdavid95
Posts: 8
Joined: Sat May 31, 2014 10:54 pm

Re: PARENT DETECTOR (PIR MODULE)

Sat Jun 07, 2014 2:19 pm

I connect the raspberry on internet and i run the .py and it worked.
At step 6 when i run the program, when PI see the movement and start recording it crash and write on the console:

Code: Select all


pi@raspberrypi ~ $ sudo ./pirCamera.py
GPIO pin 7 is HIGH
mmal: mmal_vc_port_parameter_set: failed to set port parameter 32:2:ENOSYST
raceback (most recent call last):
File "./pirCamera.py", line 30, in <module>
    cam.start_recording(fileName)  # new
File "/usr/lib/python2.7/dist-packages/picamera/camera.py", line 795, in start_recording
    self, camera_port, output_port, format, resize, **options)
File "/usr/lib/python2.7/dist-packages/picamera/encoders.py", line 431, in __init__
    parent, camera_port, input_port, format, resize, **options)
File "/usr/lib/python2.7/dist-packages/picamera/encoders.py", line 124, in __init__
    self._create_encoder(**options)
File "/usr/lib/python2.7/dist-packages/picamera/encoders.py", line 491, in _create_encoder  
prefix="Enable to set SEI")
File "/usr/lib/python2.7/dist-packages/picamera/exc.py", line 112, in mmal_check
raise PiCameraMMALError(status, prefix)
picamera.exc.PiCameraMMALError: Enable to set SEI: Function not implemented


Thank you for the help.

User avatar
davidevb6
Posts: 37
Joined: Wed Jul 24, 2013 3:22 pm

Re: PARENT DETECTOR (PIR MODULE)

Tue Jun 24, 2014 9:11 pm

Enable PiCamera

Code: Select all

	sudo apt-get update
	sudo pip install picamera
	sudo apt-get install python-picamera
to test if working

Code: Select all

		raspistill -o cat.jpg -t 10000
if you receive this error
mmal: Failed to run camera app. Please check for firmware updates
you need to:
set 256 MB of ram in your video card using rasp-config
check this 2 file

Code: Select all

sudo nano /etc/modprobe.d/raspi-blacklist.conf
blacklist spi-bcm2708
blacklist i2c-bcm2708

Code: Select all

sudo nano /etc/modules 
	w1-therm
	w1-gpio pullup=1
	i2c-dev
	i2c-bcm2708
	spi-bcm2708
	snd-bcm2835
	bcm2708_wdog
IS IMPORTANT THE ORDER OF MODULE !!!!
if you have different order, you could have some problem.
Last edited by davidevb6 on Fri Jun 27, 2014 12:00 am, edited 1 time in total.

MrEngman
Posts: 3858
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: PARENT DETECTOR (PIR MODULE)

Tue Jun 24, 2014 9:57 pm

davidevb6 wrote:#Enable PiCamera#
sudo apt-get update
sudo pip install picamera
sudo apt-get install python-picamera
#to test#
raspistill -o cat.jpg -t 10000
#if you receive this error#
mmal: Failed to run camera app. Please check for firmware updates
#you need to:#
#set 256 MB of ram in your video card using rasp-config#
#check this 2 file#
sudo nano /etc/modprobe.d/raspi-blacklist.conf
blacklist spi-bcm2708
blacklist i2c-bcm2708

sudo nano /etc/modules
w1-therm
w1-gpio pullup=1
i2c-dev
i2c-bcm2708
spi-bcm2708
snd-bcm2835
bcm2708_wdog

IS IMPORTANT THE ORDER OF MODULE !!!!
if you have different order, you could have some problem.
Nice and confusing. Why do you need to do this? I went through the Parent Detector Tutorial and it works without problems. No need for any of that.

A couple of things that haven't been mentioned. I found it a bit awkward plugging in the camera cable. Make sure it's plugged in OK. The other thing is the camera can take a fair chunk of current so make sure you use a decent power supply. Failing when it detects motion and starts the camera recording will generate a current spike and so could indicate an inadequate power supply.


MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

User avatar
davidevb6
Posts: 37
Joined: Wed Jul 24, 2013 3:22 pm

Re: PARENT DETECTOR (PIR MODULE)

Fri Jun 27, 2014 1:19 am

:oops:
I've formatted my answer, now is more clear (i hope).
yeap, probably some modules are not necessary but are the same settings i use, so i'm sure it works.

probably there is not necessary to enable 1wire module

the only things i want to explain are "keep attention to the order of loading module" it taken me a lot of time to come out of this issue :P

Return to “Italiano”