Skip to main content

Control

The main purpose of the square connector at the end of the Blade is to connect a Fan Unit. The output is 5V and should work with any fan that supports 5V. The speed of the fan can be controlled with PWM.

The connector can also be used to control any 5v PWM fan, or as an additional UART port (UART5 on CM4)

PWM fan (Standard Fan Unit)

note

When using the Standard(STA) Fan Unit Unit the speed of the fan can only be controlled from port A

Using GPIO12 and GPIO13 the compute module can pass a PWM signal to the fan. Using a python script you can read and control the fan.

Clone the GitHub repository to your blade

git clone https://github.com/uptime-industries/compute-blade-pwm-fan-control.git
cd ./compute-blade-pwm-fan-control/

To read the fan speed

python ./read_fan_speed.py

To control the fan speed

python ./fan_control.py

To run the script with nohup

nohup python fan_control.py
note

nohup is a POSIX command which means "no hang up". Its purpose is to execute a command such that it ignores the HUP (hangup) signal and therefore does not stop when the user logs out.

UART connection (Smart Fan Unit)

Enable uart5 in config.txt by adding:

enable_uart=1
dtoverlay=uart5

Next install a console (we use cu) and modify the permissions to /dev/ttyAMA5. We can now connect to the Fan Unit over UART.

sudo apt install cu
sudo chmod 666 /dev/ttyAMA5
sudo cu --line /dev/ttyAMA5 --speed 115200

Deploying to Fan Unit over USB (Smart Fan Unit)

Before starting, remove all power from the Fan Unit. Next hold down the BOOTSEL button and plug in the USB Type-C.

The Fan Unit will appear as a drive on your computer. Download the Circuit Python .uf2 file and move into the drive. The drive will then disappear and a new one named CIRCUITPY will be connected. The example code should be placed here to run.