Menu

Home

Ben Croston

RPi.GPIO Python Module

To get started with the RPi.GPIO module, it would be worthwhile reading the examples here.

Installation instructions can be found here

Detailed technical reference of the BCM2835 SOC and Raspberry Pi board can be found here


Related

Wiki: Examples
Wiki: TechRef
Wiki: install

Discussion

  • ChrisMartu

    ChrisMartu - 2020-05-01

    I am new to Raspberry Pi and python and I am trying to learn and understand the RPi.GPIO module but I was not able to locate a

    List of (built-in) Functions

    With description and syntax
    Can somebody please point me in the right direction

     
  • Emmanuel ANDRE

    Emmanuel ANDRE - 2021-02-01

    Not sure if it helps but you can try this (non interactive) :
    python -c 'import RPi.GPIO as GPIO; print(dir(GPIO))'

    You will get a list of functions :
    ['BCM', 'BOARD', 'BOTH', 'FALLING', 'HARD_PWM', 'HIGH', 'I2C', 'IN', 'LOW', 'OUT', 'PUD_DOWN', 'PUD_OFF', 'PUD_UP', 'PWM', 'RISING', 'RPI_INFO', 'RPI_REVISION', 'SERIAL', 'SPI', 'UNKNOWN', 'VERSION', 'builtins', 'cached', 'doc', 'file', 'loader', 'name', 'package', 'path', 'spec', 'add_event_callback', 'add_event_detect', 'cleanup', 'event_detected', 'getmode', 'gpio_function', 'input', 'output', 'remove_event_detect', 'setmode', 'setup', 'setwarnings', 'wait_for_edge']

    you can test the capital ones like this :
    python -c 'import RPi.GPIO as GPIO; print(GPIO.VERSION)'

    0.7.1a3

     
    • ChrisMartu

      ChrisMartu - 2023-10-08

      Thank you Emmanuel

       
  • Kobra

    Kobra - 2023-10-08

    I just get that this cant be installed on my windows system even thought I just want to have it install so I can do coding on my windows system and known that it will work for my PI systems

     
  • Ken Brooks

    Ken Brooks - 2024-07-01

    I tried the standard install command on my apple silicon macintosh. It didn't work because a header file called sys/epoll.h is missing from the system.A little research suggests that this header file belongs to Linux, not clear that it belongs to Macintosh. Here's the full output:

    % pip install RPi.GPIO
    Collecting RPi.GPIO
      Downloading RPi.GPIO-0.7.1.tar.gz (29 kB)
      Preparing metadata (setup.py) ... done
    Building wheels for collected packages: RPi.GPIO
      Building wheel for RPi.GPIO (setup.py) ... error
      error: subprocess-exited-with-error
    
      × python setup.py bdist_wheel did not run successfully.
       exit code: 1
      ╰─> [37 lines of output]
          running bdist_wheel
          running build
          running build_py
          creating build
          creating build/lib.macosx-10.9-universal2-cpython-312
          creating build/lib.macosx-10.9-universal2-cpython-312/RPi
          copying RPi/__init__.py -> build/lib.macosx-10.9-universal2-cpython-312/RPi
          creating build/lib.macosx-10.9-universal2-cpython-312/RPi/GPIO
          copying RPi/GPIO/__init__.py -> build/lib.macosx-10.9-universal2-cpython-312/RPi/GPIO
          running build_ext
          building 'RPi._GPIO' extension
          creating build/temp.macosx-10.9-universal2-cpython-312
          creating build/temp.macosx-10.9-universal2-cpython-312/source
          clang -fno-strict-overflow -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -O3 -Wall -arch arm64 -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.12/include/python3.12 -c source/c_gpio.c -o build/temp.macosx-10.9-universal2-cpython-312/source/c_gpio.o
          source/c_gpio.c:170:9: warning: cast to smaller integer type 'uint32_t' (aka 'unsigned int') from 'uint8_t *' (aka 'unsigned char *') [-Wpointer-to-int-cast]
              if ((uint32_t)gpio_mem % PAGE_SIZE)
                  ^~~~~~~~~~~~~~~~~~
          source/c_gpio.c:171:34: warning: cast to smaller integer type 'uint32_t' (aka 'unsigned int') from 'uint8_t *' (aka 'unsigned char *') [-Wpointer-to-int-cast]
                  gpio_mem += PAGE_SIZE - ((uint32_t)gpio_mem % PAGE_SIZE);
                                           ^~~~~~~~~~~~~~~~~~
          2 warnings generated.
          source/c_gpio.c:170:9: warning: cast to smaller integer type 'uint32_t' (aka 'unsigned int') from 'uint8_t *' (aka 'unsigned char *') [-Wpointer-to-int-cast]
              if ((uint32_t)gpio_mem % PAGE_SIZE)
                  ^~~~~~~~~~~~~~~~~~
          source/c_gpio.c:171:34: warning: cast to smaller integer type 'uint32_t' (aka 'unsigned int') from 'uint8_t *' (aka 'unsigned char *') [-Wpointer-to-int-cast]
                  gpio_mem += PAGE_SIZE - ((uint32_t)gpio_mem % PAGE_SIZE);
                                           ^~~~~~~~~~~~~~~~~~
          2 warnings generated.
          clang -fno-strict-overflow -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -O3 -Wall -arch arm64 -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.12/include/python3.12 -c source/common.c -o build/temp.macosx-10.9-universal2-cpython-312/source/common.o
          clang -fno-strict-overflow -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -O3 -Wall -arch arm64 -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.12/include/python3.12 -c source/constants.c -o build/temp.macosx-10.9-universal2-cpython-312/source/constants.o
          clang -fno-strict-overflow -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -O3 -Wall -arch arm64 -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.12/include/python3.12 -c source/cpuinfo.c -o build/temp.macosx-10.9-universal2-cpython-312/source/cpuinfo.o
          clang -fno-strict-overflow -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -O3 -Wall -arch arm64 -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.12/include/python3.12 -c source/event_gpio.c -o build/temp.macosx-10.9-universal2-cpython-312/source/event_gpio.o
          source/event_gpio.c:24:10: fatal error: 'sys/epoll.h' file not found
          #include <sys/epoll.h>
                   ^~~~~~~~~~~~~
          1 error generated.
          error: command '/usr/bin/clang' failed with exit code 1
          [end of output]
    
      note: This error originates from a subprocess, and is likely not a problem with pip.
      ERROR: Failed building wheel for RPi.GPIO
      Running setup.py clean for RPi.GPIO
    Failed to build RPi.GPIO
    ERROR: Could not build wheels for RPi.GPIO, which is required to install pyproject.toml-based projects
    
    [notice] A new release of pip is available: 24.0 -> 24.1.1
    [notice] To update, run: pip3 install --upgrade pip
    % 
    
     

Log in to post a comment.