Orange Pi Zero Temperature Management

07/09/18

Last modified on 09/02/18

Categories: Computers Tags: Orange Pi

~/contents


Update 09/02/18: Updated the fan wiring instructions, added circuit diagram, corrected power supply voltage, info about 3.3V vs 5V and PWM.


The smaller Orange boards with H2+/H3 Allwinner have a reputation for running a bit hot. The official ABS case is compact and cute but limits airflow, which is further restricted if you are using the expansion board. I find the expansion board adds about 8 to 10 degrees. According to the Allwinner H2+ datasheet, OP0’s maximum ambient temperature is 70+, and the internal maximum is 125C. Some users have reported the ABS case melting (DDDD:) so I wanted to do what I could to reduce temperatures for my RetrOrangePi Zero.

You can monitor temperature in Armbian with the following:

sudo armbianmonitor -m

If you are interested in tracking CPU temperature, check out RPi-monitor. Once installed, you can visit the dash at localhost port 8888. It doesn’t get much easier than that.

sudo armbianmonitor -r

Additionally, you can check system settings and turn off wifi, USBs, etc. if you don’t need them.

sudo h3consumption

Forum references:

Heatsinks

Heatsinks will reduce the temperature somewhat. A 14x7mm heatsink on the processor reduced idle heat by 5 degrees and a smaller heatsink on the RAM chip reduced idle heat by an additional 2 degrees. These were applied with MX-4 thermal paste. If you purchase off-brand heatsinks with thermal tape you’ll want to remove all the tape and adhesive and apply thermal paste or glue instead.

Enclosure and Positioning

The official ABS case turns your OP0 into a little oven. Drilling holes helps a bit, installing a fan to pull air out of the case helps a lot. There aren’t a lot of commercial enclosure options and none have fans built in, unfortunately. Geekworm sells a transparent acrylic sandwich case. I don’t have this case but I have their PC2 case and you could easily leave some or all of the sides off to improve air flow. If you elevate the pi to allow air to flow under the board you will see a slight temperature reduction.

Power Supply

The power supply used will affect running temperature. 5.2V appears to be optimal, Shenzhen Xunlong sells one with the Pi and I found a Raspberry Pi 2/3 PS worked as well.

Fan

There are several posts about fan installation, including Cooling the Orange and Orange Pi Zero - The Battle Against Heat. I was able to put together a breadboard prototype based on rpi-fan-controller and How to control a fan to cool the CPU of your RaspBerryPi and modified code from Cooling the Orange. I learned the fan/transistor wiring schematic floating around is slightly incorrect and updated my circuit based on this schematic.

I found a tiny 5V 30mm pull-fan significantly cooled an OP0 + heatsink running RetrOrangePi in the ABS case by about 20 degrees, but it was too noisy and became a nuisance. There are several workarounds. The first is to use a 3.3V to 5V fan with a voltage resistor, which is 2 resistors (R1, R2) that reduce the voltage delivered. This way a 3.3V voltage can be obtained from a 5V pin and the fan will naturally spin more slowly. I made a diagram to try to understand the principle, but have not tested it.

5V fan with voltage resistor

The second is to utilize pulse width modulation (PWM), which allows us to pulse the voltage to varying levels. I chose the latter and had good results, see the notes for more info on the library and code used.

5V Fan Wiring

For the wiring I used a 30mm 5V fan, a S8050 NPN transistor, and three jumpers. Connect the fan positive to a 5V pin. Connect the fan negative to the left leg (collector) of a S8050 NPN transistor (the flat front of the NPN should be facing you). Connect the right leg (emitter) of the transistor to GND. Connect the middle leg (base) of the transistor to the desired GPIO pin. Basic fan code (without PWM) looks like this:

#!/usr/bin/python
from pyA20.gpio import gpio
from pyA20.gpio import port
from time import sleep

PIN = port.PA6
gpio.init()
gpio.setcfg(PIN, gpio.OUTPUT)

while 1:
    with open( "/sys/devices/virtual/thermal/thermal_zone0/temp" ) as f:
        content = f.readlines()
    temp = int(content[0])
    if temp >= 55:
        gpio.output(PIN, gpio.HIGH)

    if temp < 50:
        gpio.output(PIN, gpio.LOW)
sleep(1)

We can run the script on startup by editing /etc/rc.local to include the following before the exit line:

nohup /usr/bin/python /home/opi/scripts/pifan.py &

You may find you need to allow permissions on rc.local

sudo chmod +x /etc/rc.local

Be advised the fan will continue to run after shutdown, so you’ll want to make sure to explicitly turn the fan off. I used this method and added a script called K99shutdown_tasks to /etc/rc6.d