<commit_before># Raspberry-fan

![Raspberry](https://upload.wikimedia.org/wikipedia/en/thumb/c/cb/Raspberry_Pi_Logo.svg/190px-Raspberry_Pi_Logo.svg.png)

[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/Selutario/Raspberry-fan/blob/master/LICENSE)


--------------------------------------------


<h3>INSTALL</h3>

1) Download the folder and open Raspberry-fan/src/fan.c.

2) Modify the route where specified with the one of your folder (Write "pwd" on shell inside the folder to meet it).

3) Write "make" (without the quotes) on Raspberry-fan/ (you will need g++ compiler installed).

4) Write on shell: sudo nano /etc/init.d/fan-init

5) Paste and save this: 
    
    
        #! /bin/sh
        # /etc/init.d/fan-init
        
        ### BEGIN INIT INFO
        # Provides:          fan-init
        # Required-Start:    $all
        # Required-Stop:     $remote_fs $syslog
        # Default-Start:     2 3 4 5
        # Default-Stop:      0 1 6
        # Short-Description: Script for fan
        # Description:       Script for fan
        ### END INIT INFO
        
        case "$1" in
        start)
            echo "Starting fan-init"
            # MODIFY THE ROUTE HERE (WRITE pwd ON Raspberry-fan/. TO MEET IT). KEEP sudo WORD
            sudo /home/osmc/Propios/Raspberry-fan/bin/raspberry-fan
            ;;
        stop)
            echo "Stopping fan-init"
        
            ;;
        *)
            echo "How to use it: /etc/init.d/fan-init {start|stop}"
            exit 1
            ;;
        esac
        
        exit 0
   

6) Write: sudo chmod 755 /etc/init.d/fan-init

7) Write: sudo /etc/init.d/fan-init start

8) Write: sudo update-rc.d fan-init defaults

If you want to make sure it is running, write: ps aux | grep "Raspberry-fan"

<br>

----------------------------------
<h3>WHAT YOU NEED (HARDWARE)</h3>

<h4>Components</h4>

1) One fan. <b>IMPORTANT: Following components are for a 5v 0,2A fan.</b>

2) One NPN 2222a transistor.

3) One 680 ohms OR one 560 ohms resistance.

<h4>How to plug them</h4>
<commit_msg>Updated for Systemctl instead of init.d<commit_after># Raspberry-fan

![Raspberry](https://upload.wikimedia.org/wikipedia/en/thumb/c/cb/Raspberry_Pi_Logo.svg/190px-Raspberry_Pi_Logo.svg.png)

[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/Selutario/Raspberry-fan/blob/master/LICENSE)


--------------------------------------------


<h3>INSTALL</h3>

1) Download the folder and open Raspberry-fan/src/fan.c.

2) Modify the route where specified with the one of your folder (Write "pwd" on shell inside the folder to meet it).

3) Write "make" (without the quotes) on Raspberry-fan/ (you will need gcc compiler installed).

4) Write on shell: sudo nano /etc/systemd/system/fan.service

5) Paste and save this: 

    <code>
    [Unit]<br>
    Description=Turn on/off the fan depending on the temperature.

    [Service]<br>
    Type=simple
    ExecStart=<span style="color:red">EDIT-WITH-FULL-ROUTE-TO-YOUR-EXECUTABLE*</span> start<br>
    Restart=Always<br>
    TimeoutStopSec=300

    [Install]<br>
    WantedBy=multi-user.target
    </code>

*Example 

6) Write: sudo chmod 755 /etc/systemd/system/ventilador.service

7) Write: sudo systemctl enable fan.service

If you want to make sure it is running, write: ps aux | grep "Raspberry-fan"

<br>

----------------------------------
<h3>WHAT YOU NEED (HARDWARE)</h3>

<h4>Components</h4>

1) One fan. <b>IMPORTANT: Following components are for a 5v 0,2A fan.</b>

2) One NPN 2222a transistor.

3) One 680 ohms OR one 560 ohms resistance.

<h4>How to plug them</h4>

{'fraction_non_alphanumeric': 0.15851325498770155, 'fraction_numerical': 0.02405028696365127, 'mean_word_length': 2.2562277580071175, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 34, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1806072', 'n_tokens_mistral': 1321, 'n_tokens_neox': 1215, 'n_words': 346}