Fan control of Raspberry

Written by pmd - - no comments


Python3 program

I have red a lot of pages how to control a fan using PWM signal.
Some of them:


Finally, it seems my fans don't have much effect on the temperature. About 5°C. So I decided to set an hysteresis:

  • Switch ON fans if temperature > 75°C
  • Switch OFF fans if temperature < 60°C
  • Do nothing if 60°C <= temperature <= 75°C
$ nano
# -*-coding:Utf-8 -*

import os
from gpiozero import LED
from time import sleep
import RPi.GPIO as GPIO

fanPin = 2
testMode = False

def getCPUtemperature():
    res = os.popen('vcgencmd measure_temp').readline()
    temp =(res.replace("temp=","").replace("'C\n",""))
    #print("temp is {0}".format(temp)) #Uncomment here for testing
    return temp

    GPIO.setup(fanPin, GPIO.OUT)
    while True:
        if testMode:
            duty_cycle = input("Nouveau PWM (%) ? ")
            temp = float(getCPUtemperature())
            if temp > 75:
            elif temp < 60:
            sleep(5) # Read the temperature every 5 sec, increase or decrease this limit if you want
except KeyboardInterrupt: # trap a CTRL+C keyboard interrupt
    GPIO.cleanup() # resets all GPIO ports used by this program

Set linux service

$ nano /etc/systemd/system/manageFan.service
Description=start fan management at system startup
After =
Wants =

ExecStart=/usr/bin/python3 /home/pi/


Fix audio amplifier

Written by pmd - - no comments





What happened

The amplifier is a Романтика 15-120С. It sounds quiet nice but sometime the sound gets no so clear either on right or left speaker.
To fast improve sound quality, I unpluged and replugged AUX input 3.5 jack. Dumb but done. One day it resulted on no more sound at all.

I quickly found dead fuse F3. I took one of the fuse of the other channel and F3 died again. Dumb but done.

I put 2 working fuse on left channel, and 2 dead fuse on right channel. Switched on the amplifier. Left channel is working. Good.

After reading internet, I quickly suspected that power transistor of the right channel were shorted. It was the case.

Test a transistor

How to test a TRANSISTOR with a multimeter PNP or NPN
How to check fuses, diodes, transistors, voltage regulators
3 Ways to Check Capacitors in Circuit with Meters & Testers

Troubleshooting (eyes+multimeter)

Le fusible FU3 de l'alim +27V cramé.
Les deux transistors de puissance VT3 et VT4 en cours-circuit.
 => +27V s'est vidé en quasi direct dans le -27V (R23 et R24 de 0.22ohm sur le chemin)
R15 et R20 cramées sur la carte principale.
R17 et R23 cramées sur la carte module de la voie droite.

Power transistors that were in service before the problem

Left channel (working), original ones:

Right channel (not working), not original ones:


Remplacement des transistors
PNP A1941 => A1943
NPN C5198 => C5200
Les nouveaux sont un peu plus gros. Il me reste à les coller sur le radiateur (je n'ai pas pu reprendre les anciens mica).

Remplacement des résistances sur la carte principale
R15 et R20. J'ai mis des 1/4W en comparant visuellement...
Ces résistances servent à prévenir l'utilisateur qu'un certain niveau de puissance a été atteint à travers l'alimentation d'une LED.

Remplacement des résistance sur la carte module
R17 100 ohm je voulais mettre 1/4W mais le vendeur n'avait plus que du 2W.
R23 0.22 ohm. A la base la résistance avait une forme de ressort (j'imagine que ces résistance doivent avoir une petit propriété inductive ?). Le vendeur n'en avait pas. J'ai hésité entre 2W et 5W. J'ai mis une 2W de forme classique.

Power transistor replacing broken ones


To make new PCB

Futur ?

Maybe i could use stuff like this to repair last stage: Amplifier Board - AIYIMA A2D847


Rss feed of the category