简体   繁体   English

启动时启动GPIO脚本

[英]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. 我有一个RPi A +,它通过GPIO连接到声音传感器。

I need this script to start when the Pi starts up. 我需要这个脚本在Pi启动时启动。 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. Pi不会在我附近或连接到屏幕,因此如果电源出现故障并且Pi重启,则脚本必须重新开始运行。

What I have now is a working script in a .py file. 我现在所拥有的是.py文件中的工作脚本。

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. 我没有别的,.py文件仅在我的桌面上。

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. 因此,基本上,我需要做的是:Pi =打开>脚本=运行。 If the Pi goes off and back on again, the script must fire again without ay intervention and start detecting sound. 如果Pi关闭并重新打开,脚本必须在没有任何干预的情况下再次启动并开始检测声音。

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. 首先,使您的python脚本成为独立脚本,它应该以#!/usr/bin/python开头,并且只能通过在shell中键入脚本名称来执行。

Then take a look at several topics such as "starting a python program at boot". 然后看看几个主题,例如“在启动时启动python程序”。 You will find several methods : 您会发现几种方法:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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