Giter Club home page Giter Club logo

rpi-fan's Introduction

rpi-fan

Basic Node.js Fan controller for Raspberry Pi.

When The temperature reachs a specific threshold value, the gpio is activated and the transistor lets the fan spin! You can see the current RPi temperature and Fan status using the built-in server functionality or installing the basic RPi-Dashboard: https://github.com/roccomuso/rpi-dashboard

Once the fan starts to spin, there will not be a temperature check for 5 minutes. This behavior avoids too many fan switches in short periods of time.

Hardware

  1. Scheme (works on both Raspberry Pi and Raspberry Pi 2 model):

circuit scheme

For Raspberry Pi pinout, check out https://www.raspberrypi.org/documentation/usage/gpio-plus-and-raspi2/

  1. Recommended Transistor: 2N7000

  2. Recommended Fan: 5V - 0.2A

Software

Configuration

  1. You can edit the gpio number, temperature threshold, refresh time etc. directly in the config.json file:

     "PIN_NUMBER" : 18,
     "REFRESH_TIME" : 60,
     "TEMPERATURE_THRESHOLD" : 45.0
    
  2. Optionally, you can also activate a web server to show the current temperature on http://ip_address:SERVER_PORT/. Make sure to choose a free port.

     "WEB_SERVER": true,
     "SERVER_PORT": 4949
    

Another available option is to pass these parameteres through the CLI:

	node index.js -n 18    # 'Choose the GPIO number'
	node index.js -p 4949  # 'Start the server on port 4949'
	node index.js -t 45    # 'Set a temperature threshold of 45 degrees'
	node index.js -r 60    # 'Check the temperature every 60 seconds'

Run on start up

  1. clone the repo on the /home/pi/Desktop:

     git clone https://[email protected]/roccomuso/rpi-fan.git
     cd rpi-fan && npm install
    
  2. add this rule to crontab:

  • Launch from CLI crontab -e and add the following line:

      @reboot /usr/local/bin/node /home/pi/Desktop/rpi-fan/index.js >/tmp/fan_output 2>/tmp/fan_error
    

(General console.log and error messages are respectively in /tmp/fan_output and /tmp/fan_error - Update: /tmp/fan_output can now be seen on the web server page.)

You can also better use a process manager (like PM2):

sudo pm2 start index.js --name="rpi-fan"

Author @ Rocco Musolino - hackerstribe.com

rpi-fan's People

Contributors

roccomuso avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

rpi-fan's Issues

Errore all'avvio di index.js

module.js:339
throw err;
^

Error: Cannot find module 'onoff'
at Function.Module._resolveFilename (module.js:337:15)
at Function.Module._load (module.js:287:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object. (/home/pi/rpi-fan/index.js:6:12)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Function.Module.runMain (module.js:467:10)

Questo è quello che visualizzo quando dò da terminale node index.js

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.