-2

I am making a project which contains face and object recognition. I activated functions with push button. My question is how can i run automatically my GPIO script when reboot raspberry.

I've tried write in .bashrc file. But it causes error(i guess its about camera) that;

mmal: mmal_vc_component_enable: failed to enable component: ENOSPC mmal: camera component couldn't be enabled.

Do you have any suggestions?

closed as unclear what you're asking by Aurora0001, Ghanima Apr 20 '18 at 22:26

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Make a service to start with systemd. – Ingo Apr 20 '18 at 12:40
  • Can you explain more specific ? – Mertozcan Apr 20 '18 at 12:41
  • Try to make a service with systemd. I don't make it for you. Look at the internet. There are many examples. You can also look at man systemd.unit. If you get stuck with a specific problem on this I can help you. To give you an idea you can look at this example for a systemd service. And please take the Tour. – Ingo Apr 20 '18 at 12:58
  • Possible duplicate of Execute script on start-up – Aurora0001 Apr 20 '18 at 14:16
  • Please be more specific about your problem, i.e. you give us an error message but not the script itself you try to run. That way possible answers are just guesswork. Provide all relevant input and make sure to outline how your issue is not covered by the more generic example given in the Q&A linked by Aurora. Thanks! – Ghanima Apr 20 '18 at 22:30
1

You can do this quite easily by adding a line to your crontab file. Do this:

From your $ shell prompt, enter man crontab. Read what it says. When you finish, dismiss the man page be entering q, and then enter crontab -e on the command line.

The nano editor will start, and show you a "default" crontab in which each line is commented - it begins with "#". Using nano, move the insertion point to the first new line at the end of the file. Enter this:

@reboot /usr/bin/python3 ~/somefolder/somefile.py &

Where ~/ is your home directory (probably /home/pi), "somefolder" is a folder in your home directory containing the Python script you want to run, and "somefile.py" is your Python script. The & lets your Python script run "in the background", and doesn't hold things up.

After you've added this line, use nano's Write (^O) to save the file, and accept whatever filename it suggests. Then exit nano using ^X. You'll get a confirmation message that your crontab file has been updated.

Reboot your pi, and your Python script will execute; and it will execute each time your pi reboots.

Not the answer you're looking for? Browse other questions tagged or ask your own question.