引脚编码方式:
同一个引脚不同编码方式中代号不同
1.板载编码
这种编码方式是按照树莓派主板上引脚排针编号。
分别对应1~40号排针。能够直接看见
2.BCM编码
3.WiringPi编码
查看编码:
1.查看板载编码
pinout
2.查看全部编码
gpio readall
报错解决:
gpio: error while loading shared libraries: libpthread.so.0: ELF load command address/offset not page-aligned
【解决方法】树莓派4B安装wiringpi失败、gpio -v与gpio readall命令not found(arm64架构)、
原因分析:
这个错误是由于libpthread.so.0库文件加载时出现了地址偏移不对齐的问题。这可能是由于库文件损坏或错误的安装过程导致的。
64位的树莓派不能够直接用 pip install wiringpi 命令装wiringpi,否则装的是armhf架构的不兼容
解决方案:
1.安装libpthread5
sudo apt-get install libpthread5
pip install RPi.GPIO
2.彻底卸载装错的wiringpi
sudo apt-get remove wiringpi
sudo apt-get purge wiringpi
hash -r
3.安装适合64位ARM架构的wiringpi版本
sudo apt-get update
sudo apt-get install git-core
git clone https://github.com/WiringPi/WiringPi.git
cd WiringPi
./build
4..验证
gpio -v
gpio readall
解决√
(步骤二的源码可以换地址↑)
sudo apt-get update
sudo apt-get install git-core
git clone https://github.com/WiringPi/WiringPi.git
(或者git clone https://hub.njuu.cf/WiringPi/WiringPi.git)
(或者git clone https://hub.nuaa.cf/WiringPi/WiringPi.git)
(或者git clone https://hub.yzuu.cf/WiringPi/WiringPi.git)
cd WiringPi
./build
pigpio 无法在 Pi 5 上运行
出现报错:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Can't connect to pigpio at localhost(8888)
Did you start the pigpio daemon? E.g. sudo pigpiod
Did you specify the correct Pi host/port in the environment
variables PIGPIO_ADDR/PIGPIO_PORT?
E.g. export PIGPIO_ADDR=soft, export PIGPIO_PORT=8888
Did you specify the correct Pi host/port in the
pigpio.pi() function? E.g. pigpio.pi('soft', 8888)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
尝试解决
https://blog.csdn.net/lengyuefeng212/article/details/112977539
1.控制台运行
sudo pigpiod
没用
2.创建一个服务文件,开机自启
sudo nano /etc/systemd/system/pigpio.service
添加以下内容:
[Unit]
Description = pigpiod deamon
After = rc-local.service
[Service]
Type = simple
User = root
Group = root
ExecStart = sudo pigpiod
Restart = always
[Install]
WantedBy = multi-user.target
到这儿
设置开机自启
sudo systemctl enable pigpio.service
(没有用)和法一没有区别
3.文件中调用os库
写入进程序:
import pigpio
import time
import os
open_io="sudo pigpiod"
os.system(open_io)
time.sleep(1)
pi = pigpio.pi() # 初始化 pigpio库`
没用
还是使用WiringPi罢