Hi all
I am trying to build and operate a project I saw at instructables but have run into a problem. Can someone please help?
First here is the project I am trying to build:
http://www.instructables.com/id/Simple- ... /?ALLSTEPS
I am using a model B pi with an 8gb SDHC card and a fresh install of Raspian Wheezy expanded out to fill out the card. I've overclocked it to 950 mhz. I'm running off a battery pack and have the pi camera hooked correctly into the circuit board.
First I have downloaded the python script mentioned at instructables and this has been stored in /home. I have separately run this from the command line and it works fine. The camera lights up and takes photos periodically. These are stored in a subdirectory that the script creates. I used the command
python raspiLapseCam.py (whilst in /home)
to test this.
So i know the script works. My problem revolves around the fact that I can't get the script to start automatically when I plug in the power.
I followed the instructions as follows
in the /home directory I typed
sudo nano crontab -e
nano opened up a blank page and I added
@reboot python /home/raspiLapseCam.py &
I hit control x and y and a file called crontab was saved in the /home directory
This didn't look right so I went to /etc and tried
sudo nano crontab -e
This time crontab opened up with several lines of instructions. I added
@reboot python /home/raspiLapseCam.py &
at the bottom and saved it as above.
I then tried
sudo shutdown "now"
but I ended up with a command prompt so I tried sudo reboot and the Pi rebooted
When it rebooted I left it to see if it would start taking pictures automatically but none were taken. I waited a while. I just got a command prompt waiting for me to log in.
So essentially my problem is that I want my pi to automatically start
python raspiLapseCam.py
in my home directory on first being booted up without the need to log in. I.e I just add power and the script will start.
What am I doing wrong and how can I get this to work?
Thanking you for your help.
- DougieLawson
- Posts: 42389
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
Re: Help with Timelapse camera project
Edit raspiLapseCam.py
add #!/usr/bin/python
save it
chmod 755 raspiLapseCam.py
That means you can execute it by typing `raspiLapseCam.py` rather than `python raspiLapseCam.py`, which is a bunch easier.
Then we can use an /etc/init.d script to get it started when the system boots.
Start by copying /etc/init.d/skeleton to /etc/init.d/timelapse. cd /etc/init.d && sudo cp skeleton timelapse
edit /etc/init.d/timelapse (use sudo nano or sudo vi) change lines 23 & 24 to refer to the command '/home/pi/raspiLapseCam.py' you need to start at boot time (the skeleton has good comments). save it.
sudo chmod 755 /etc/init.d/timelapse # to make it executable
sudo update-rc.d timelapse enable # gets it started at system boot and killed at shutdown
add #!/usr/bin/python
save it
chmod 755 raspiLapseCam.py
That means you can execute it by typing `raspiLapseCam.py` rather than `python raspiLapseCam.py`, which is a bunch easier.
Then we can use an /etc/init.d script to get it started when the system boots.
Start by copying /etc/init.d/skeleton to /etc/init.d/timelapse. cd /etc/init.d && sudo cp skeleton timelapse
edit /etc/init.d/timelapse (use sudo nano or sudo vi) change lines 23 & 24 to refer to the command '/home/pi/raspiLapseCam.py' you need to start at boot time (the skeleton has good comments). save it.
sudo chmod 755 /etc/init.d/timelapse # to make it executable
sudo update-rc.d timelapse enable # gets it started at system boot and killed at shutdown
Languages using left-hand whitespace for syntax are ridiculous
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
Re: Help with Timelapse camera project
Thanks Dougie
A couple of glitches still.
I added
#!/usr/bin/python
as you said but still it won't start if I type
raspiLapseCam.py
Yes I did the chmod command as you said. I'm not sure what I did wrong?
re editing lines 23 and 24
in my file they are
NAME=daemonexecutablename
DAEMON=/usr/sbin/$NAME
so should this be changed to
NAME=raspiLapseCam.py
DAEMON=/home/$NAME
???
Thanks Peter
A couple of glitches still.
I added
#!/usr/bin/python
as you said but still it won't start if I type
raspiLapseCam.py
Yes I did the chmod command as you said. I'm not sure what I did wrong?
re editing lines 23 and 24
in my file they are
NAME=daemonexecutablename
DAEMON=/usr/sbin/$NAME
so should this be changed to
NAME=raspiLapseCam.py
DAEMON=/home/$NAME
???
Thanks Peter
- DougieLawson
- Posts: 42389
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
Re: Help with Timelapse camera project
I copied my version (currently watching my birdtable) to /usr/local/bin/raspiLapseCam.py
And /etc/init.d/timelapse compared to /etc/init.d/skeleton
Code: Select all
root@pi /usr/local/bin # ls -la r*
-rwxr-xr-x 1 root root 4593 Dec 29 16:41 raspiLapseCam.py
root@pi /usr/local/bin #
Code: Select all
--- skeleton 2012-10-15 17:30:41.000000000 +0000
+++ timelapse 2013-12-29 20:09:39.661877526 +0000
@@ -1,11 +1,11 @@
#! /bin/sh
### BEGIN INIT INFO
-# Provides: skeleton
+# Provides: timelapse
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
-# Short-Description: Example initscript
+# Short-Description: timelapse camera
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.
### END INIT INFO
@@ -19,10 +19,10 @@
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
-DESC="Description of the service"
-NAME=daemonexecutablename
-DAEMON=/usr/sbin/$NAME
-DAEMON_ARGS="--options args"
+DESC="Timelapse camera"
+NAME=raspiLapseCam.py
+DAEMON=/usr/local/bin/$NAME
+DAEMON_ARGS=""
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
Languages using left-hand whitespace for syntax are ridiculous
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
Re: Help with Timelapse camera project
Hi Peter/Doug,
Firstly thank you for this. I'm a student and haven't coded anything in my life before, however, this project is something I want to complete and is my first introduction to python.
I'm sorry as I'm a newbie, but I'm finding it a bit hard to follow your instructions. The first bit threw me:-
"Edit raspiLapseCam.py
add #!/usr/bin/python
save it"
I assume this means, log into systemx, open the file called raspiLapseCam.py with python2 editor. And then type #!/user/bin/python just above where there is already written #!/usr/bin/env python.
Then I save it.
However, I am struggling a bit as it says I don't have permission to alter this file. I've tried going under the properties tab, but I can't change the permission. I've tried making my own file and calling it the same thing, but to no effect.
If you could help, or suggest ways of doing it in terminal, I'm very willing to learn!
Thanks,
Leno
Firstly thank you for this. I'm a student and haven't coded anything in my life before, however, this project is something I want to complete and is my first introduction to python.
I'm sorry as I'm a newbie, but I'm finding it a bit hard to follow your instructions. The first bit threw me:-
"Edit raspiLapseCam.py
add #!/usr/bin/python
save it"
I assume this means, log into systemx, open the file called raspiLapseCam.py with python2 editor. And then type #!/user/bin/python just above where there is already written #!/usr/bin/env python.
Then I save it.
However, I am struggling a bit as it says I don't have permission to alter this file. I've tried going under the properties tab, but I can't change the permission. I've tried making my own file and calling it the same thing, but to no effect.
If you could help, or suggest ways of doing it in terminal, I'm very willing to learn!
Thanks,
Leno
Re: Help with Timelapse camera project
I did this project thanks to all of the info I found here and I am using an /etc/init.d script to get it started when the system boots, but I have one problem.
If I reboot the Pi or do a complete shutdown everything starts up and works perfectly.
However, if the Pi loses power while running (like a power failure) the Pi will restart just fine, but the timelapse will not restart.
I am using the Pi plugged into power, but in a rural setting where power interruptions are somewhat common, and I need it to work when power is restored.
Here's what I'm doing exactly: http://www.raspberrypi.org/forums/viewt ... 66#p679266
Any ideas?
If I reboot the Pi or do a complete shutdown everything starts up and works perfectly.
However, if the Pi loses power while running (like a power failure) the Pi will restart just fine, but the timelapse will not restart.
I am using the Pi plugged into power, but in a rural setting where power interruptions are somewhat common, and I need it to work when power is restored.
Here's what I'm doing exactly: http://www.raspberrypi.org/forums/viewt ... 66#p679266
Any ideas?