树莓派pigpio报Can’t connect to pigpio at localhost(8888)
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)
解决方法:
一:文件中调用os库
import pigpio
import time
import os
open_io="sudo pigpiod"
os.system(open_io)
time.sleep(1)
pi = pigpio.pi() # 初始化 pigpio库`
二:在LX终端手动开启
输入命令 sudo pigpiod 启动pigpio daemon
sudo pigpiod