2

I'm using a Gertboard, and the GPIO Python demos were running fine. I started using/modifying the DAC and ADC demo code, and now I can't output to GPIO using Python (e.g. the Gertboard leds-rg.py doesn't flash the LEDs).

It's not a Gertboard configuration issue, because if I disconnect the Gertboard I still can't set the GPIO pins from Python (no errors, but a voltmeter doesn't change). gpio write in a terminal works fine.

In Python I get a warning that the channel is already in use, continuing anyway (using a channel that doesn't have a use for SPI).

gpio readall doesn't show any changes I make in Python including to the pin mode, it does of course reflect changes made using gpio mode and gpio write

In order to get SPI running I had to install a few things: (python-dev, spi-dev) and I also ran apt-get upgrade, and of course had to turn on SPI in raspi-config.

It's a Model 2B running Raspbian, and I'm using Python 2. RPi.GPIO is version 0.5.11.

  • Which GPIO are not working? Ones on the Pi or ones on the Gertboard? – joan Nov 26 '15 at 15:10
  • @joan both. I can take the Gertboard off the Pi, and the ones on the Pi board don't switch. I can pick up the same lines on the Gertboard (with or without straps to other bits of the Gertboard and they don't switch. I'm not trying to use the ATmega IO pins (yet). – Chris H Nov 26 '15 at 15:15
  • It sounds like a transient problem. There is no reason for wiringPi (gpio readall, mode, write) to work and not Python. Perhaps a reboot will sort out the problem. – joan Nov 26 '15 at 15:24
  • @joan, I wish it would - reboots are probably into double figures today as I try things like disabling autoloading the SPI drivers. – Chris H Nov 26 '15 at 15:26
  • Try my pigpio Python module. – joan Nov 26 '15 at 16:01
1

While I still don't know what the underlying issue was, the pigpio library provided a solution (as suggested by @joan in the comments). Swapping the library calls from RPi.gpio to pigpio was simple enough (in code based on the Gertboard python demos).

Apparently device_tree=on in /boot/config.txt can cause problems with RPi.GPIO

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.