How to use RPi.GPIO

Hi,

I'm a beginner in OpenWrt and I'm using RPi zero w.

I installed pip and RPi.GPIO python module but when i use it test program it is giving import error, is there anyway to solve this.

Error i got:

root@OpenWrt:~# python test.py
Traceback (most recent call last):
  File "/root/test.py", line 1, in <module>
    import RPi.GPIO as GPIO    # Import Raspberry Pi GPIO library
  File "/usr/lib/python3.10/site-packages/RPi/GPIO/__init__.py", line 23, in <module>
    from RPi._GPIO import *
ModuleNotFoundError: No module named 'RPi._GPIO'

Thanks

good thinking, it's always wise to create a help me post, without actually posting
the error message you require help with ...

1 Like

Sorry, my bad. I have edited the post with error message i got

I finally found a solution,
Hardware: Raspberry Pi Zero W

Step 1: Expand the disk size since by default it is 104MB link.

Step 2: Install gcc, pip and python3-dev using following commands which are mandatory to install RPi.GPIO

opkg install python3-pip
opkg install gcc
opkg install python3-dev

Step 3: Download the source file and upzip the file using below commands

wget https://pypi.python.org/packages/source/R/RPi.GPIO/RPi.GPIO-0.7.1.tar.gz

tar -xvzf RPi.GPIO-0.7.1.tar.gz

cd RPi.GPIO-0.7.1

timestamps goes missing so hit touch `find . -type f`

Now do python3 setup.py install

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.