September 08, 2020 (updated at: October 09, 2022)
Use the RGB Cooling HAT, by Yahboom, with Docker on your Raspberry Pi
This tutorial was tested on a Raspberry Pi 4 with the RGB Cooling HAT model “YB-EBV02 VER1.1”, by Yahboom, on both 32-bit and 64-bit OS.
The hardware creators do provide installation documentation and official code, but putting all the parts together can be challenging.
If you’re willing to use Docker and run the 32-bit version of Raspberry Pi OS, you can activate everything with one command (after enabling I2C with raspi-config).
docker run -d --restart unless-stopped --network host --privileged laury/raspberry-pi-rgb-cooling-hat:latestTo run the software on a 64-bit OS, you’ll need to enable QEMU first and then run the container with the --platform flag.
docker run --privileged --rm tonistiigi/binfmt --install all
docker run -d --restart unless-stopped --platform="linux/arm/v7" --network host --privileged laury/raspberry-pi-rgb-cooling-hat:latestThe container image tagged with latest enables the default functionality of the accessory. If you’d like the RGBs to be turned off, use the v1.1.0-noRGB image tag.
You can also build the Docker image yourself using the following Dockerfile. Just remember to target ARMv7 architecture. The easiest way to achieve that is to build on the Raspberry Pi itself.
FROM python:2.7
RUN apt update &&\
apt install -y i2c-tools git
RUN pip install Adafruit-GPIO==1.0.3 \
Adafruit-BBIO==1.2.0 \
Adafruit-SSD1306==1.6.2 \
smbus==1.1.post2 \
image==1.5.32 \
vcgencmd==0.1.1 \
RPi.GPIO==0.7.1
WORKDIR /tmp
RUN git clone --depth 1 https://github.com/raspberrypi/firmware.git &&\
cp -a firmware/hardfp/opt/vc/* /usr
RUN git clone https://github.com/YahboomTechnology/Raspberry-Pi-RGB-Cooling-HAT.git &&\
unzip Raspberry-Pi-RGB-Cooling-HAT/4.Python\ programming/RGB_Cooling_HAT.zip &&\
mkdir /app &&\
cp -a RGB_Cooling_HAT/* /app &&\
rm -rf /tmp/*
WORKDIR /app
CMD python /app/RGB_Cooling_HAT.py