24 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
18 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
  • 71k
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
  • 71k
13 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,551
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,308
12 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
  • 60k
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,769
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
  • 655
9 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
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,451
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.9k
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
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
  • 71k
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
  • 71k
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,451
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
  • 22k
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,675
5 votes

How to connect a graphic card to Raspberry pi?

I originally flagged this as being, possibly seriously, Off-Topic but technically there is a further method that make it possible to connect a graphics card to the RPi and have the latter generate ...
SlySven's user avatar
  • 3,621
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
  • 71k
5 votes

GPIO: Warning Channel already in use

You can safely ignore the warning. As the message says add GPIO.setwarnings(False) to the start of your script to disable warnings. GPIO.cleanup() sets any GPIO you have used within RPi.GPIO to ...
joan's user avatar
  • 71k
5 votes
Accepted

Getting feedback from a hall sensor with Raspberry Pi

I did an experiment using a Hall sensor with magnets connected to a motor shaft. Detail and code are available at https://www.raspberrypi.org/forums/viewtopic.php?p=632413 You should be able to ...
joan's user avatar
  • 71k
5 votes
Accepted

RPI GPIO Ports default on?

Yes, it is normal. GPIO 0-8 have their internal pulls to 3V3 enabled at boot. That will allow enough current to flow to dimly light a LED.
joan's user avatar
  • 71k
5 votes
Accepted

I can't get RPI.GPIO working

You are correct the RPi GPIO module does come preinstalled on recent versions of Raspbian, and is almost certainly already installed. The problem is that the name of the Library is wrong. Change ...
Steve Robillard's user avatar
5 votes
Accepted

Differences in GPIO between Raspberry Pi 2 B and 3 B

It basically depends on what aspect you are looking at. The pins of all with 40pin headers (B+, Pi2, Pi3) are identical. The functions which are allocated to the pins differ slightly. The Pi3 has a ...
Milliways's user avatar
  • 60k

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