A temperature-based fan controller for the Compute Module 4 (CM4) IO board.
The project uses: -
- pre-commit to enforce linting of files prior to committing them to the upstream repository
- Commitizen to enforce a Conventional Commit commit message format
- Black and isort as a code formatter
You MUST comply with these choices in order to contribute to the project.
To get started review the pre-commit utility and the conventional commit style and then set-up your local clone by following the Installation and Quick Start sections: -
poetry shell
poetry install
pre-commit install -t commit-msg -t pre-commit
Now the project's rules will run on every commit, and you can check the current health of your clone with: -
pre-commit run --all-files
This code is designed to tun on the CM4 IO board where, according to the
CM4 datasheet, to enable the I2C bus to the fan controller,
you will need dtparam=i2c_vc=on
set in your /boot/config.txt
.
The fan controller will then be on i2c-10 at the 7-bit address 0x2f.
The fan I'm using is a Waveshare, part number CM4-FAN-3007-12V.
The practical fan speed range (found empirically) is between between 45 (18%) and 255 (100%). The fastest speed while still remaining quiet, i.e. the fastest speed that isn't considered distractingly noisy when running within a couple of feet of the user, is about 70 (27%).
You typically run the controller as a systemd service on the CM IO board. The repository contains an example service file that you can use as a template.
Clone the repository to your CM4 IO board and install the service file: -
git clone https://github.com/alanbchristie/python-cm4-fan-controller
cd python-cm4-fan-controller
Edit the cm4-fan-controller.service
file to suite your needs and then install it: -
sudo cp cm4-fan-controller.service /lib/systemd/system
sudo chmod 644 /lib/systemd/system/cm4-fan-controller.service
sudo systemctl daemon-reload
sudo systemctl enable cm4-fan-controller.service
And then reboot the CM4 to make suer the service starts automatically on boot.
sudo reboot