Libraries Installation for RPi
From Waveshare Wiki
Libraries Installation for RPi
PS: If you are using the system of the Bullseye branch, you need to change "apt-get" to "apt". The system of the Bullseye branch only supports Python3.
First of all you make sure to use which language C or python Open the terminal of Raspberry Pi and install libraries as guides below
Install Library
If you use the bookworm system, you can only use lgpio library, bcm2835 and wiringPi can't be installed and used.
BCM2835
#Open the Raspberry Pi terminal and run the following command wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.71.tar.gz tar zxvf bcm2835-1.71.tar.gz cd bcm2835-1.71/ sudo ./configure && sudo make && sudo make check && sudo make install # For more, you can refer to the official website at: http://www.airspayce.com/mikem/bcm2835/
WiringPi
#Open the Raspberry Pi terminal and run the following command cd sudo apt-get install wiringpi #For Raspberry Pi systems after May 2019 (earlier than that can be executed without), an upgrade may be required: wget https://project-downloads.drogon.net/wiringpi-latest.deb sudo dpkg -i wiringpi-latest.deb gpio -v # Run gpio -v and version 2.52 will appear, if it doesn't it means there was an installation error # Bullseye branch system using the following command: git clone https://github.com/WiringPi/WiringPi cd WiringPi . /build gpio -v # Run gpio -v and version 2.70 will appear, if it doesn't it means there was an installation error
lgpio
#Open the Raspberry Pi terminal and run the following command wget https://github.com/joan2937/lg/archive/master.zip unzip master.zip cd lg-master sudo make install # You can refer to the official website for more: https://github.com/gpiozero/lg
Install Python Library
#python2 sudo apt-get update sudo apt-get install python-pip sudo pip install RPi.GPIO sudo apt-get install python-smbus #python3 sudo apt-get update sudo apt-get install python3-pip sudo pip install RPi.GPIO sudo apt-get install python3-smbus