Coder Social home page Coder Social logo

simple-pi-fan-control's Introduction

Plan

I would have to switch the fan directly using a small piece of software via a GPIO pin. The program reads the CPU+GPU temperature and then switches the fan. The OS should start the program periodically or automatically.

Structure

The GPIO pins of the Raspberry Pi have 3V3 logic and cannot switch the power even of such a small fan directly. That's why a switching amplifier is needed. This is quite easy to implement with a transistor.

Hardware required in addition to the Raspberry Pi and its case with fan

  • 1 NPN transistor e.g. BC547 B
  • 1 Resistor 4,7 kOhm

See circuit diagram and wiring image

The Python code

  • Only required package: RPi.GPIO

  • control.py : FanControl class

    • In an infinite loop temperature is checked in a certain time interval
      • If the temperature is greater than or equal the max value, and the pin is not already activated, GPIO pin will set to HIGH
      • Is the temperature lower than or equal to the minimum value, and the pin is set to HIGH, GPIO pin will set to LOW
  • config.py : Settings:

    • GPIO pin of connected fan
    • Max temperature at which the fan is switched on
    • Min temperature at which the fan is switched off
    • Check interval, in seconds
  • main.py: An instance of FanControl will load with passed parameters.

Auto run at boot up

One possibility is described in service directory. Refer to README

Installation possibilities and steps

  • Clone this repository and configure manually
  • Install distribution, service enabled automatically
  • Adapt config.py

simple-pi-fan-control's People

Contributors

kaulketh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.