Python

GPIO Reset during setup?

3 1858
xefil  

Hello!

I'ts normal that during initial setup in python  the GPIO status is reset?
I would like to write a script that checks the GPIO status every time I call it.
Trying it, semms that during:

GPIO.setup(<pin>, GPIO.OUT)

The GPIO will be resetted.

Thanks!

Simon
I believe that GPIO definition should be done once at start of the script, then it will be reset just once.
In this case you are setting <pin> as an output.
If you want to check GPIO status, use:
  1. print io.output(<pin>)
Copy the Code

xefil  

Ok, but the script is invoked and executed when needed. I need to wuery the GPIO on which a relay is connected. So, during startup it will be resetted, NO GOOD...
I can in this case have two approach:

1. Have the script always running
2. Don't use python but gpio from cli and bash.

I've used option two, so it works.
I can query gpio status with 'gpio read <IN>' and so write 1|0.

Thanks anyway!

Simon

hodoors  
Note: The author has been banned or deleted.

You have to log in before you can reply Login | Sign Up

Points Rules