Skip to content

Install and configure pigpiod

Guy McSwain edited this page Apr 4, 2020 · 9 revisions

Install from Raspbian package manager

sudo apt-get update
sudo apt-get install pigpio
pigpiod -v

This last command display the version of pigpio installed. If not the latest …

Install latest version

If not already installed, you'll need the build-essential package

sudo apt-get install build-essential

Next, run the following shell commands and grab a cup of coffee:

rm master.zip
sudo rm -rf pigpio-master
wget https://github.com/joan2937/pigpio/archive/master.zip
unzip master.zip
cd pigpio-master
make
sudo make install

Running

sudo pigpiod -s 1 \       # GPIO sampling interval in microseconds
             -f \         # disable pipe interface (ie PIGS)
             -n 10.0.0.11 # connect exclusively to this client

This will fork pigpiod and run it in the background. A better way is to run pigpiod as a service so you never have to attach a terminal to the RPi controlling your IO.

Running as systemd service

wget https://raw.githubusercontent.com/joan2937/pigpio/master/util/pigpiod.service
sudo cp pigpiod.service /etc/systemd/system
sudo systemctl enable pigpiod.service
sudo systemctl start pigpiod.service

Henceforth, pigpiod will start and run whenever the system is rebooted. Note, Raspbian ships pigpiod.service with remote connetions disabled (-l option). You will want to edit the service file to remove the -l option and add your other preferred pigpiod configuration options. See all pigpiod parameter descriptions here.

Here's an example of what I'm currently running: (Note the path to the executable shown here is valid for a compiled installation.)

[Unit]
Description=Pigpio daemon
After=network.target syslog.target
StartLimitIntervalSec=60
StartLimitBurst=5
StartLimitAction=reboot

[Service]
Type=simple
ExecStartPre=/sbin/sysctl -w net.ipv4.tcp_keepalive_time=300
ExecStartPre=/sbin/sysctl -w net.ipv4.tcp_keepalive_intvl=60
ExecStartPre=/sbin/sysctl -w net.ipv4.tcp_keepalive_probes=5
# Don't fork pigpiod
ExecStart=/usr/local/bin/pigpiod -g
ExecStop=
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target