Getting Started
Last revision 2025/12/29
This guide offers comprehensive instructions for assembling and testing a Pan-Tilt HAT with Raspberry Pi, focusing on enabling the I2C interface, installing necessary libraries, and ensuring correct servo connections to avoid damage.
Note: Before you assemble servos to Pan-Tilt HAT, please test the servo independently with test codes, otherwise, the servo may get stuck or even damaged since it is not at its original position. Refer to the instructions below:
HardWare Configuration
Enable I2C Interface: command1: sudo raspi-config
Select Interfacing Options -> I2C ->yes Enable i2C Kernel Module

Restart Raspberry Pi:command2: sudo reboot
Install Library
If you are using the bookworm system, you can only use the lgpio library, and bcm2835 and wiringPi cannot be installed or used.
- Install lgpio,open Raspberry Pi end and run the following commands:
command1: wget https://github.com/joan2937/lg/archive/master.zip
command2: unzip master.zip
command3: cd lg-master
command4: sudo make install
For more information,please refer to:https://github.com/gpiozero/lg
- Install BCM2835, open Raspberry Pi end and run the following commands:
command1: wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.68.tar.gz
command2: tar zxvf bcm2835-1.68.tar.gz
command3: cd bcm2835-1.68/
command4: sudo ./configure && sudo make && sudo make check && sudo make install
For more information, please refer to:http://www.airspayce.com/mikem/bcm2835/
- Install wiringPi
command1:sudo apt-get install wiringpi
For Raspberry Pi system after may 2019, an upgrade is required.
command2:wget https://project-downloads.drogon.net/wiringpi-latest.deb
command3:sudo dpkg -i wiringpi-latest.deb
command4:gpio -v
run gpio -v version 2.52 will appear, if not, installtion error happens
Download Program
command1: sudo apt-get install p7zip-full
command2: wget http://www.waveshare.net/w/upload/9/96/Pan-Tilt_HAT_code.7z
command3: 7z x Pan-Tilt_HAT_code.7z -r -o./Pan-Tilt_HAT_code
command4: sudo chmod 777 -R Pan-Tilt_HAT_code
command5: cd Pan-Tilt_HAT_code/RaspberryPi/
Test
Connect:

Please Connect them correctly.
| Brown | GND |
|---|---|
| Red | 5V |
| Orange | S1/S0 |
Pay attention to the mount position of the tilt servo. Wrong place may cause servo damage. Do not assemble servos when testing. Make sure the servo can rotate 360 degrees freely and then connect hardware: pan servo to S1, tilt servo to S0. Open the test file in program folder.
command1: cd test
command2: make clean
command3: make
command4: sudo ./main
Assembly

Assembled:

A: pan servo
B: tilt servo
- How to assemble Camera?
The module comes with a M2 screw package independently. It has 5 screws and 10 nuts. Screw the camera on with M2 screws, and then attach the Acrylic plate onto it, and fasten them together with nuts.

Additional Information
- How to assemble Camera: The module comes with a M2 screw package. Screw the camera on with M2 screws, attach the acrylic plate, and fasten with nuts.

- Assembly steps:
(A: pan servo, B: tilt servo)
Note
- The Pan-Tilt HAT is unassembled, you need to get it done by yourself.
- Raspberry Pi board and Camera are not included.
Was this article helpful?
