Installing Robot HAT v4 on Ubuntu
I have double checked the install.py
file and i2samp.sh
script and reviewed the breif notes I made at the time and I think just a few simple steps should successfully install a robot-HAT v4 on a Raspberry Pi 5 runnung Ubuntu 24.04
1) Clone robot hat repository to home directory (follow instructions on Sunfounder website)
-
cd ~/ git clone -b v2.0 https://github.com/sunfounder/robot-hat.git cd robot-hat
- DO NOT run the
instal.py
file as it will fail - Install required packages and setup manually as below
2) Install required packages from APT repository
-
raspi-config (not bundled in Ubuntu 24.04)
-
i2c-tools
-
espeak
-
libsdl2-dev
-
libsdl2-mixer-dev
-
portaudio19-dev
-
sox
-
sudo apt install raspi-config i2c-tools espeak libsdl2-dev libsdl2-mixer- dev portaudio19-dev sox
3) Install required python packages
-
smbus2
-
gpiozero
-
pyaudio
-
spidev
-
pyserial (package not on apt. Use python3-serial instead)
-
pillow (newest version python3-pil with ubuntu and is automatically selected instead
by apt)
-
pygame>=2.1.2 (was unable to install version 2.1.2 from apt. used python3-pygame
instead which downloads v2.5.2-2 instead)
I installed each package system-wide using:
-
sudo apt install python3-<PACKAGE_NAME>
If installing into a virtual environment, use pip instead
-
python3 -m pip install <PACKAGE_NAME>
4) Enable I2C and SPI interfaces
-
Open raspberry pi configuration tool by typing following into terminal
-
sudo rasp-config
-
Select option 3 - Interface options and enable I2C and SPI
5) Copy hardware dtoverlays to overlays directory
-
Copy required harware overlays from within
robot-hat
directory to/boot/firmware/overlays/
directory -
cd robot-hat
-
cp ./dtoverlays/* /boot/firmware/overlays/
-
This will copy
sunfounder-robothat5.dtbo
andsunfounder-servohat+.dtbo
to the directory -
Edit
config.txt
to apply these overlays at time of boot -
cd ~/ sudo nano /boot/firmware/config.txt
-
Add the following lines to
config.txt
after the[All]
-
dtoverlay=sunfounder-robothat5 dtoverlay=sunfounder-servohat+
-
Exit with
ctrl-X
andY
to save changes
6) Reboot and try python programs in test folder
-
NOTE: you MUST copy the
robot_hat
folder (robot_hat module) into thetests
folder for the python testing programs to work -
Motor and servo demo files should now work
-
Sound card setup and audio testing follows separately