Posts: 1
Joined: Sun Jan 08, 2017 8:31 am

start PI camera on reboot

Sun Jan 08, 2017 8:48 am

I searched and tried different ways to start a python script which starts the PIcamera on a raspberry PI3.

first attempt : through crontab

sudo crontab -e added :

Code: Select all

@reboot python3 /home/pi/
script :

Code: Select all

from picamera import PiCamera
    from time import sleep
    camera = PiCamera()
    camera.framerate = 15

second attempt through crontab :

Code: Select all

sudo crontab -e

added :

Code: Select all

@reboot /home/pi/ >/home/pi/log/cameralog.log 2>&1
script stays the same :

Code: Select all

    cd /
    cd home/pi
    /usr/bin/python3 /home/pi/
    cd /
third attempt :
removed all from crontab and used rc.local

Code: Select all

sudo nano /etc/rc.local

added :

Code: Select all

/usr/bin/python3 /home/pi/
None of the above ways is starting the script at reboot.

I'm new to raspberry and python. what's wrong?

Posts: 94
Joined: Tue Mar 10, 2015 6:19 am

Re: start PI camera on reboot

Sun Jan 08, 2017 8:05 pm

I have solved a very similar problem this way:

in /etc/rc.local, I added:
sudo python /media/usb_1/WATCHDOG.PY &

(do not to forget the "&" at the end of the line and place it before the line with exit)

Via network, I create shut.r (in which case WATCHDOG restarts the PI) or shut.h (to shut it down properly).

I am a beginner, too. If someone knows a less complicated way, I will be gladful.

When the PI boots, camera starts with the line:
sudo python /media/usb_1/PI_CAM.PY
which I added as the last line in /etc/profile.

(I learned the hard way that programs launched from etc/profile can be stopped with CtrlC.)

Return to “Beginners”