When I built a telemetry system for DMR repeater, I observed high temperatures of the transmitting radio, especially during summer and hot periods of the year.
I realized that a cooling system could be helpful to dissipate the heat produced by Motorola radio.
The acquisition system was already done, so only the actuation system was needed.
I searched on the internet, and I found some scripts used to control a fan installed on the microprocessor of the raspberry Pi.
I took one python script and modified to acquire the temperature of the external sensor connected to the MCP3008.

The original script was here (reads the System CPU temperature) and the customized version is here.

Some notes for the correct script configuration:

  • Script Cycle time must be configured. Default value of 30sec is good for starting;
  • Log file name must be declared.
  • Output pin to be used for fan switch on;
  • Both upper and lower thresholds must be declared, as for every hysterical control;
  • The logging function can be useful during the first tuning period. Once the thresholds have been found, the function can be eliminated;
  • Value, beta and pull-up resistor of NTC must be declared inside the script for a correct temperature conversion. The NTC, in series with the pull-up resistor, must be connected to the the same 5V coming from the Raspberry and powering the MCP3008.


  • ADC channel connected to the NTC sensor must be specified.
  • Adafruit library for MCP3008 must be installed before running the script.
  • A compensation variable is useful to align the temperature reading to a reference thermometer.

I used two small 12V PC fans, which fits well to the Motorola heatsink:


The Raspberry output pin cannot directly drive the fan, so a small BJT driver is needed. I built one with a 2N2222 NPN transistor and a 1KOhm resistor, 1/4W on the base.
Here below the schematic is reported:


This is the prototype board of the fan driver:


The general block diagram is the following:


Once the hardware is ready, we can try to manually switch on pin 25 and see if the fans start, using “GPIO” library from shell:

gpio mode 25 out
gpio write 25 1

The above commands set pin 25 as an output and then sets the pin to a logic 1.

If the fans starts, we can try to configure and launch the script. Remember to give the execution permission (sudo chmod +x MCP3008_raspy_thermostat.py).

In the logfile, we can read the temperature acquired by the NTC and eventually tune the “compensation” variable to align the temperature reading with a reference thermometer.

Then, we can tune the thresholds for best results.

I hope this project could be useful.
Alfredo IZ7BOJ