diff --git a/Fan - Haizemailea.fzpz b/Fan - Haizemailea.fzpz new file mode 100644 index 0000000..25b964b Binary files /dev/null and b/Fan - Haizemailea.fzpz differ diff --git a/README.md b/README.md index 1f7f91a..82f5517 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,13 @@ -# haizemailea +## Hozte-sistema Raspberry Pi 4 batean +https://apunteak.lainoa.eus/post61f18774a1ea181132376291 + +#### v0.1: +* Oinarrizko eskema NPN transistorea switch moduan konfiguratuta, **emitter** edo igorlea *GND*-era ezarrita. + +#### v0.2: +* Haizemailea martxan dagoela adierazten duen LED bat gehitu da zirkuitoan. +* Haizemailearen deskonexioak sor ditzakeen piko iragankorrengandik zirkuitoa babesteko diodo bat gehitu da *antiparaleloan*. + +#### zirkuito simulazioak +https://falstad.com/circuit/circuitjs.html \ No newline at end of file diff --git a/fan_control b/fan_control new file mode 100644 index 0000000..27fb5dc --- /dev/null +++ b/fan_control @@ -0,0 +1,53 @@ +#!/usr/bin/python3 + +import RPi.GPIO as GPIO +import subprocess +import time + +class FanStatus(object): + + ON_THRESHOLD = 50 # 50 (gradu zentigradu) Haizemailea pizten da. + OFF_THRESHOLD = 43 # 43 (gradu zentrigadu) Haizemailea itzaltzen da. + SLEEP_INTERVAL = 20 # (segundoak) Tenperatura neurketa maiztasuna. + + def __init__(self): + super(FanStatus, self).__init__() + self.FanPin = 27 # pin13 + + def setup(self): + GPIO.setwarnings(False) + GPIO.setmode(GPIO.BCM) + GPIO.setup(self.FanPin, GPIO.OUT) + + def get_temp(self): + output = subprocess.run(['vcgencmd', 'measure_temp'], capture_output=True) + temp_str = output.stdout.decode() + try: + return float(temp_str.split('=')[1].split('\'')[0]) + except (IndexError, ValueError): + raise RuntimeError('Akatsa tenperatura eskuratzerakoan') + + def main(self): + # Piztu/Itzaldu balioak egokiak direla ziurtatu + if self.OFF_THRESHOLD >= self.ON_THRESHOLD: + raise RuntimeError('Konfiguraketa akatsa -> ITZALTZE tenperatura PIZTE tenperatura baina txikiagoa izan behar da!') + + while True: + temp = f_status.get_temp() + if temp > self.ON_THRESHOLD and not GPIO.input(self.FanPin): + GPIO.output(self.FanPin, True) + elif GPIO.input(self.FanPin) and temp < self.OFF_THRESHOLD: + GPIO.output(self.FanPin, False) + time.sleep(self.SLEEP_INTERVAL) + + def destroy(self): + GPIO.cleanup() + +f_status = FanStatus() + +if __name__ == '__main__': + f_status.setup() + try: + f_status.main() + except KeyboardInterrupt: + f_status.destroy() \ No newline at end of file diff --git a/fan_control.service b/fan_control.service new file mode 100644 index 0000000..78e8cfa --- /dev/null +++ b/fan_control.service @@ -0,0 +1,15 @@ +[Unit] +Description=Haizemailearen kontrol zerbitzua +After=sysinit.target +DefaultDependencies=no + +[Service] +ExecStart=/script-aren/kokapena/fan_control +Restart=always +RestartSec=10 +WorkingDirectory=/script-aren/kokapena +StandardOutput=/var/log/syslog +StandardError=/var/log/syslog + +[Install] +WantedBy=sysinit.target \ No newline at end of file diff --git a/fan_control_muntaia-0.1.fzz b/fan_control_muntaia-0.1.fzz new file mode 100644 index 0000000..d963cc4 Binary files /dev/null and b/fan_control_muntaia-0.1.fzz differ diff --git a/fan_control_muntaia-0.1.png b/fan_control_muntaia-0.1.png new file mode 100644 index 0000000..bf8dc25 Binary files /dev/null and b/fan_control_muntaia-0.1.png differ diff --git a/fan_control_muntaia-0.2.fzz b/fan_control_muntaia-0.2.fzz new file mode 100644 index 0000000..be3420e Binary files /dev/null and b/fan_control_muntaia-0.2.fzz differ diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..533c7ae --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +RPi.GPIO==0.7.0 diff --git a/simulazioa-0.1.txt b/simulazioa-0.1.txt new file mode 100644 index 0000000..a07a4ee --- /dev/null +++ b/simulazioa-0.1.txt @@ -0,0 +1,21 @@ +$ 1 0.000005 10.20027730826997 50 5 43 5e-11 +s 32 288 112 288 0 1 false +v 448 432 448 368 0 0 40 5 0 0 0.5 +r 112 288 208 288 0 680 +t 208 288 240 288 0 1 -4.706872324968529 0.2192719221397147 100 default +w 448 368 448 224 0 +415 336 80 416 80 0 0.5 6 0.15 0.15 0.02 0.05 1 0 +w 416 80 448 80 0 +w 448 144 448 224 0 +w 448 144 448 80 0 +w 240 272 240 224 0 +w 240 144 240 224 0 +w 240 144 240 80 1 +w 240 80 336 80 0 +w 240 304 240 432 1 +w 240 432 448 432 0 +v -80 416 -80 352 0 0 40 3.3 0 0 0.5 +w -80 352 -80 288 0 +w -80 288 32 288 0 +w -80 416 -80 432 0 +w -80 432 240 432 0 diff --git a/simulazioa-0.2.txt b/simulazioa-0.2.txt new file mode 100644 index 0000000..6185c96 --- /dev/null +++ b/simulazioa-0.2.txt @@ -0,0 +1,29 @@ +$ 1 0.000005 10.20027730826997 50 5 43 5e-11 +r 272 224 336 224 0 220 +s 32 288 112 288 0 1 false +v 448 432 448 368 0 0 40 5 0 0 0.5 +r 112 288 208 288 0 680 +t 208 288 240 288 0 1 -4.770399947854952 0.21961158136024417 100 default +162 448 224 336 224 2 default-led 1 0 0 0.01 +w 448 368 448 224 0 +415 336 80 416 80 0 0.5 6 0.15 0.15 0.02 0.05 1 0 +w 416 80 448 80 0 +d 336 144 400 144 2 default +w 448 144 448 224 0 +w 448 144 448 80 0 +w 400 144 448 144 0 +w 240 272 240 224 0 +w 240 224 272 224 1 +w 336 144 240 144 0 +w 240 144 240 224 0 +w 240 144 240 80 1 +w 240 80 336 80 0 +w 240 304 240 432 0 +w 240 432 448 432 0 +v -80 416 -80 352 0 0 40 3.3 0 0 0.5 +w -80 352 -80 288 0 +w -80 288 32 288 0 +w -80 416 -80 432 0 +w -80 432 240 432 0 +o 0 64 0 4099 0.0000762939453125 0.00009765625 0 2 0 3 +38 0 F1 0 1 101 -1 Resistance \ No newline at end of file