22 votes

gpio library on windows while developing

If you are just looking to test the whole code and not worry about the actual pins (as windows machines don't have GPIO), then you can fake it. First, in your main python source directory, create a ...
skidoo's user avatar
  • 351
21 votes
Accepted

GPIO: Warning Channel already in use

This code helped me get rid of the warning (the "finally" part at the end): import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) # Broadcom pin-numbering scheme GPIO.setup(6, GPIO.OUT) # ...
user1231247's user avatar
14 votes
Accepted

Where are the uarts on the raspberry pi 4?

The preliminary Pi4 datasheet shows there are 6 UARTs. UART GPIO 0 14/15 1 14/15 2 0/1 3 4/5 4 8/9 5 12/13 Given that UART 0/1 are both connected to the same GPIO you can only use ...
joan's user avatar
  • 70.5k
13 votes

Can we use other GPIO pins as I2C

The whole point of I2C is it is a bus. You can therefore connect multiple I2C devices to the same GPIO provided they have different I2C device addresses. If the devices share an address which can't ...
joan's user avatar
  • 70.5k
12 votes
Accepted

How fast can GPIO pins toggle?

There are some benchmarks from Henner Zeller's repository on GitHub which claimed that directly outputting data to the GPIO could achieve up to 65.8 MHz on a Raspberry Pi 3 (not B+, mind, but I ...
Aurora0001's user avatar
  • 6,278
12 votes

gpiozero Button.when_pressed

It is possible to use parameters with callback functions. See e.g. Documentation for button.when_pressed This can be set to a function which accepts no (mandatory) parameters, or a Python ...
Dirk's user avatar
  • 3,506
11 votes

How to correctly install the python RPi.GPIO library

Assuming you have pip, the python package index installer, which is installed on the latest versions of Raspbian by default You can use: sudo pip install RPi.GPIO for Python 2 and sudo pip-3.2 ...
brainiak4431's user avatar
10 votes

Webserver & GPIO python script (No access to /dev/mem. Try running as root!)

You don't so much need root access as permission to access the gpio device. Raspbian has a user group 'gpio' to enable this. By default the 'pi' user is in the gpio group and can access GPIOs. If you ...
patthoyts's user avatar
  • 501
10 votes

Is there any built in LED connected with GPIO pin?

Yes, it is possible to control the built-in leds. Green LED is easier. According to here, though it is probably Pi 3 specific, since it didn't work for my Pi 4: In the terminal: sudo echo 1 > ...
Botspot's user avatar
  • 1,759
10 votes

Where are the uarts on the raspberry pi 4?

As Joan has stated only 1 of UART0/1 is accessible (UART0 /dev/ttyAMA0 is connected to Bluetooth on later model Pi). There are additional UART on the Pi4. Raspberry Pi4 UART is a more up to date ...
Milliways's user avatar
  • 58.6k
9 votes
Accepted

Is there documentation for RPi.GPIO

The official documentation is http://sourceforge.net/p/raspberry-gpio-python/wiki/Examples/ It doesn't seem to have a traditional API style of documentation.
joan's user avatar
  • 70.5k
9 votes

Debouncing buttons with RPi.GPIO -- too many events detected?

As @joan points out, the bouncetime parameter in RPi.GPIO does almost exactly the wrong thing: it means when your switch bounces, you'll get the very first event, but that may not actually be ...
larsks's user avatar
  • 656
9 votes
Accepted

Error installing RPi.GPIO in virtual environment

It looks like the latest release does not support Python 3.9 but the alpha releases do: https://www.piwheels.org/project/RPi.GPIO/ You can install the alpha version with: pip install rpi-gpio --pre
ben_nuttall's user avatar
  • 2,441
8 votes
Accepted

Can you connect multiple GPIO pins, to one ground pin?

Setting aside the ill-phrased part of the question (connecting multiple GPIO pins (which to my knowledge are 3 volts), to one ground pin) - which indeed short circuits the GPIO pins if they are set to ...
Ghanima's user avatar
  • 15.8k
8 votes

I can't get three LED lights to turn off and on in an order

You need to set the pin as an output before you use it. To do that add the following line: GPIO.setup(red, GPIO.OUT) below the matching lines for green and yellow: GPIO.setup(yellow, GPIO.OUT) ...
Steve Robillard's user avatar
8 votes

Is there any built in LED connected with GPIO pin?

though it is probably Pi 3 specific, since it didn't work for my Pi 4 It works on the 4 as well, you just need to set the right trigger. The instructions that you provided are not applicable to the 4 ...
icuwopcui's user avatar
7 votes
Accepted

connecting common anode rgb led

Connect the common anode pin to 3.3 volt and each of the other pins to a GPIO (add a current limiting resistor between the LED and the GPIO pin. To Light one of the colors set the corresponding GPIO ...
Steve Robillard's user avatar
7 votes

RPi.GPIO not found in virtual environment

The problem is that you don't have the GPIO module installed in your virtual environment. To correct this, run the following from within your virtual environment: for Python 2 pip install RPi.GPIO ...
Steve Robillard's user avatar
7 votes
Accepted

Is the gpio readall command compatible with RPi 4?

As far as I am aware it should work provided you download and install the latest version of wiringPi. http://wiringpi.com/wiringpi-updated-to-2-52-for-the-raspberry-pi-4b/ cd /tmp wget https://...
joan's user avatar
  • 70.5k
7 votes
Accepted

RPi.GPIO Cleanup() only specific pins?

See RPi.GPIO documentation. Cleanup At the end any program, it is good practice to clean up any resources you might have used. This is no different with RPi.GPIO. By returning all channels you have ...
joan's user avatar
  • 70.5k
7 votes

Install GPIO problem

You can't install RPi.GPIO on Windows. If you want to mock GPIO calls on a PC, try gpiozero which has a mock pin interface: https://gpiozero.readthedocs.io/en/stable/api_pins.html
ben_nuttall's user avatar
  • 2,441
6 votes

How to correctly install the python RPi.GPIO library

Another potential cause could be because the RPi.GPIO library has C bindings and therefore need to have python-dev installed in order to compile correctly when installing. Make sure you've got the ...
adam's user avatar
  • 161
6 votes
Accepted

I need to control 8 LED's but I can only control 3? [helpful pictures attached]

The problem is the breadboard (though some would call it a feature). The breadboard you have has split power rails (Marked by the red and blue lines on the edge of the board). If you look carefully ...
Steve Robillard's user avatar
6 votes
Accepted

Blink script gives me "name error 'BCM' is not defined"

It's GPIO.BCM you want. Dot rather than comma. GPIO.setmode(GPIO.BCM)
Andy Lamb's user avatar
  • 359
6 votes
Accepted

Is there a GPIO current limit function available, and where is the documentation?

Yes. The definitive source for RPi hardware documentation is the Raspberry Pi Foundation. The Foundation updated their published documentation to include programmable GPIO current limits recently (Jan,...
Seamus's user avatar
  • 21.1k
6 votes

How can Rpi SPI python read the MFRC522 RFID / NFC module?

Question How can Rpi python read a SPI MFRC255 RFID/NFC tag? Short Answer Part 1 - Introduction to I2C and SPI NFC/RFID Chips and Modules Part 2 - Setting up SPI MFRC522 Module Part 3 - ...
tlfong01's user avatar
  • 4,645
5 votes

How to connect a graphic card to Raspberry pi?

Graphics cards are usually connected via PCI or PCI Express bus. The Raspberry Pi has no such bus. It has a built-in graphics card, however. It's fast enough to run Quake 3 :-) Edit: Actually, there ...
neuhaus's user avatar
  • 584
5 votes
Accepted

How to connect a graphic card to Raspberry pi?

It's probably not exactly what the original question had in mind... but technically, it is possible to connect graphic cards to the Raspberry Pi using a bus it provides, namely USB. However, it ...
Ghanima's user avatar
  • 15.8k
5 votes

How do I make a device tree overlay for just a single GPIO?

Either I'm blind, or the whole concept of device tree overlays is very badly documented. Here is what I've found: Install prerequisites: sudo apt-get update sudo apt-get install raspi-gpio device-...
rudolfbyker's user avatar
5 votes

GPIO 02 and 03 seem always high when used as an input (with pull down resistors attached)

GPIO 2 and 3 are special in that they have hard wired 1k8 pull-up resistors to 3V3 fitted on board. That's to allow their use as I2C bus 1 (I2C requires pull-ups for SDA/SCL for proper bus operation)....
joan's user avatar
  • 70.5k

Only top scored, non community-wiki answers of a minimum length are eligible