Hi,
We use the adafruit gpio library to communicate from our Python application with the gpio. The python webapp is running on a uwsgi server.
We have a camera on gpio 6, but after a restart of the server or board ( reload of the library and recreation of the object ) the gpio is set to zero and switch off the camera.
Also any other gpio triggering is setting the values of all the gpio's to 0 after we reinitialise the object. Anyone has a solution for this problem?
Gpio initializing on first load adafruit gpio library
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- Driess
- Posts: 1
- Joined: Thu Feb 19, 2015 1:09 pm
- tdicola
- Posts: 1074
- Joined: Thu Oct 17, 2013 9:11 pm
Re: Gpio initializing on first load adafruit gpio library
Just to check, after your program restarts you can control the GPIO pins as you expect right? Is it that only during the time when your program isn't running, like if it's being restarted or the Raspberry Pi is rebooting, that the GPIO pins are going back down to a 0 level?
If so that's typically normal behavior because the GPIO pins don't remember their old state when a program that used them stops running. When the Raspberry Pi's GPIO library stops running it does some cleanup and puts the pin back in a 'high impedance' state where they aren't set to a specific value and can float up or down. An easy way to work around this problem is to add a pull-up resistor to the GPIO pin so it's pulled up to a high voltage level when it's in that high impedance state. For example a 10kilo-ohm resistor connected from the GPIO pin up to the 3.3V power pin (don't use the 5V pin as it can damage the GPIO pin!) would work great. Then when your program controls the GPIO it can set it to 0 or 3.3V by setting the pin low or high as normal, but when the program stops running and the GPIO pin goes back to high impedance it will get pulled up to 3.3V instead of potentially hitting 0 volts.
Let me know if that's the issue you're running into, or if it's something else. If it's something else can you get a rough list of steps to reproduce it too? Thanks!
If so that's typically normal behavior because the GPIO pins don't remember their old state when a program that used them stops running. When the Raspberry Pi's GPIO library stops running it does some cleanup and puts the pin back in a 'high impedance' state where they aren't set to a specific value and can float up or down. An easy way to work around this problem is to add a pull-up resistor to the GPIO pin so it's pulled up to a high voltage level when it's in that high impedance state. For example a 10kilo-ohm resistor connected from the GPIO pin up to the 3.3V power pin (don't use the 5V pin as it can damage the GPIO pin!) would work great. Then when your program controls the GPIO it can set it to 0 or 3.3V by setting the pin low or high as normal, but when the program stops running and the GPIO pin goes back to high impedance it will get pulled up to 3.3V instead of potentially hitting 0 volts.
Let me know if that's the issue you're running into, or if it's something else. If it's something else can you get a rough list of steps to reproduce it too? Thanks!
Please be positive and constructive with your questions and comments.