简体   繁体   中英

Start GPIO Script on startup

I have searched far and wide and tried a million different methods, but nothing works.

This is the scenario.

I have an RPi A+, it is connected to a sound sensor via GPIO.

I need this script to start when the Pi starts up. The Pi won't be near me or connected to a screen, so if the power fails and the Pi reboots, the script must start running again.

What I have now is a working script in a .py file.

The basic function = Detect sounds > log entry into database > send me an email.

I have nothing else, the .py file is just on my desktop.

Please help in plain English. My coding is not very good, and I had many people helping me make this happen, so I am not competent enough to create a script like this by myself - just for context on my skill level.

So basically, all I need is: Pi = on > Script = running. If the Pi goes off and back on again, the script must fire again without ay intervention and start detecting sound.

Thanks so much!

First of all make your python script as a standalone, it should start with something like #!/usr/bin/python and could be executed only by typing the script name in shell.

Then take a look at several topics such as "starting a python program at boot". You will find several methods :

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM