I usually use RPi.GPIO module like this to set up the GPIO pins:

import RPi.GPIO as GPIO
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_UP) 

Is it possible to change mode of a pin to ALT5 like I would do with wiringpi's gpio tool :

> gpio -g mode 15 alt5 // sets GPIO 15 pin to ALT 5 mode

but with Python's RPi.GPIO ?

1 Answer 1


No. As far as I am aware RPi.GPIO only supports modes INPUT and OUTPUT. Modes ALT0, ALT1, ALT2, ALT3, ALT4, and ALT5 are not supported.

  • Ok! Is it me or the RPi.GPIO module documentation is really lacunar? No real exhaustive API, or maybe I looked at the wrong place? I'll do gpio -g mode 15 alt5 before my Python script begins then...
    – Basj
    Commented Apr 5, 2015 at 13:40
  • A linked issue: I am now able to set RXd (GPIO 15) to RX1 (ie a 2nd serial port). But I don't have /dev/ttyAMA1 , I only have /dev/ttyAMA0. Do you know how to create that second serial port @joan ?
    – Basj
    Commented Apr 5, 2015 at 13:41
  • @Basj No, sorry, I don't know how to create /dev/ttyAMA1. To what end though? You'll still only have one serial link, just with a different name, as it uses the same gpios. You'd need to have a compute module to get an additional serial port.
    – joan
    Commented Apr 5, 2015 at 13:52
  • Because @joan I want to use TX0 (ttyAMA0) for one thing (a 7segment display), and RX1 (ttyAMA1) for another thing (receive some MIDI IN!)... Therefore, I need 2 different half-ports (for the 7segment display, I only need TX, and for MIDI IN, I only need RX) with 2 different baud setting...
    – Basj
    Commented Apr 5, 2015 at 14:41
  • @Basj You should be able to do that with /dev/ttyAMA0 without any fuss. Open the port once for reading and again for writing. You can certainly set different input/output baud rates from C
    – joan
    Commented Apr 5, 2015 at 14:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.