first commit
This commit is contained in:
parent
1586bd21de
commit
479ebdd354
BIN
Fan - Haizemailea.fzpz
Normal file
BIN
Fan - Haizemailea.fzpz
Normal file
Binary file not shown.
13
README.md
13
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
|
53
fan_control
Normal file
53
fan_control
Normal file
@ -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()
|
15
fan_control.service
Normal file
15
fan_control.service
Normal file
@ -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
|
BIN
fan_control_muntaia-0.1.fzz
Normal file
BIN
fan_control_muntaia-0.1.fzz
Normal file
Binary file not shown.
BIN
fan_control_muntaia-0.1.png
Normal file
BIN
fan_control_muntaia-0.1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 37 KiB |
BIN
fan_control_muntaia-0.2.fzz
Normal file
BIN
fan_control_muntaia-0.2.fzz
Normal file
Binary file not shown.
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
RPi.GPIO==0.7.0
|
21
simulazioa-0.1.txt
Normal file
21
simulazioa-0.1.txt
Normal file
@ -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
|
29
simulazioa-0.2.txt
Normal file
29
simulazioa-0.2.txt
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user