0

I have a script with GPIO.event_detected(port) to count number of times a hall effect sensor is initiated. My script works amazing when executed in python3 IDLE run module. Counts are accumulated per datetime.datetime.now().

When I execute the script in terminal shell, I only receive 1 total count per timestamp; maximum 2 or 3 if I blow hard into hall effect sensor. Why do my counts vary when executed in shell vs. IDLE? I have a while loop within the script to basically sum up each count per datetime.datetime.now(). Again works perfect in IDLE module execute but not in terminal shell. Is this because the shell is not fast enough to count GPIO counts?

What I am trying to achieve is have my script run on startup in rc.local. Is it possible to execute a python3 script in IDLE run module during startup? So it shows the python 3.4.2 shell view and runs?

  • If you want help you need to supply a code listing. You are asking us to guess which is a waste of our time. – joan Jun 3 '18 at 9:54
0

Easy. Make a executable file, which executes the following command:
/usr/bin/idle3 -r <**YOUR_FILE_PATH**>
And move it to rc.local
If your script has to be run as root, just put sudoin front onf the command.

  • First: rc.local is running with root rights, so never use an additional sudo within it. Second: Please take note that using /etc/rc.local has limitations due to Compatibility with SysV. We have seen many problems here on this site using it. Following the recommendation of the developers from systemd you should avoid using it. – Ingo Nov 3 at 10:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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