We have upgraded the community system as part of the upgrade a password reset is required for all users before login in.

Recommended way to read a GPIO pin on start-up



  • Hello,

    I'm wondering what the recommended way is, to read a GPIO pin set to input after start-up. Here's my use case:

    I've an Arduino which is setting a digital pin to high and there's a wire which connects the Ardino's digital pin to a GPIO pin on the Omega. When the Omega detects a high on the input pin it is supposed to run an ash command.

    Right now, I'm doing this by starting a python script which loops continuously until it detects a high on the pin and then fires of the ash command. Even though I've a python command which is calling this file from the rc.local file, which was supposed to run the python script on-boot, that doesn't happen and I have to manually start the script using python file_dir/file_name.py.

    How do I ensure that rc.local is actually starting my python script? Is this the right way to read a pin on-boot? Because it seems a bit convoluted for something so simple.



  • This post will be usefull to you for your boot sequence script:
    https://community.onion.io/topic/711/resolved-reboot-doesn-t-seem-to-work-in-cron/6

    That being said, these little devices are FAST, and weird things may happen on the electric level during power-up. To be sure that your script takes a valid GPIO measurement, you should make sure that your whole system (any and all processors in your project) is up and running and stabilized. A way to do this is to add a small delay in your script that is run at boot time if need be (for example, 500ms or 1 sec) before doing anything else.



  • @Syed-Hasan I would support all that @fossette says in the previous post.

    You should pay particular attention to 2 issues:

    1. Make sure that the system is fully operative by using a delay as suggested by @fossette
    2. As is mentioned in the referenced post, make sure the program you want to run at boot terminates in a timely manner and doesn't end up blocking the start up process - e.g. run it in the background


Looks like your connection to Community was lost, please wait while we try to reconnect.