monitoring_serveur_et_activites_du_disque_dur_avec_raspberry_pi
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédente | Dernière révisionLes deux révisions suivantes | ||
monitoring_serveur_et_activites_du_disque_dur_avec_raspberry_pi [2019/05/12 16:24] – Benjamin Labomedia | monitoring_serveur_et_activites_du_disque_dur_avec_raspberry_pi [2019/05/12 22:34] – [Install brute] Benjamin Labomedia | ||
---|---|---|---|
Ligne 83: | Ligne 83: | ||
</ | </ | ||
+ | **Script pour extinction propre de la pi avec bouton externe** | ||
+ | |||
+ | pioff.py | ||
+ | <code python> | ||
+ | # | ||
+ | #This script was authored by AndrewH7 and belongs to him (www.instructables.com/ | ||
+ | #You have permission to modify and use this script only for your own personal usage | ||
+ | #You do not have permission to redistribute this script as your own work | ||
+ | #Use this script at your own risk | ||
+ | |||
+ | import RPi.GPIO as GPIO | ||
+ | import os | ||
+ | |||
+ | gpio_pin_number=21 | ||
+ | #Replace YOUR_CHOSEN_GPIO_NUMBER_HERE with the GPIO pin number you wish to use | ||
+ | #Make sure you know which rapsberry pi revision you are using first | ||
+ | #The line should look something like this e.g. " | ||
+ | |||
+ | GPIO.setmode(GPIO.BCM) | ||
+ | #Use BCM pin numbering (i.e. the GPIO number, not pin number) | ||
+ | #WARNING: this will change between Pi versions | ||
+ | #Check yours first and adjust accordingly | ||
+ | |||
+ | GPIO.setup(gpio_pin_number, | ||
+ | #It's very important the pin is an input to avoid short-circuits | ||
+ | #The pull-up resistor means the pin is high by default | ||
+ | |||
+ | try: | ||
+ | GPIO.wait_for_edge(gpio_pin_number, | ||
+ | #Use falling edge detection to see if pin is pulled | ||
+ | #low to avoid repeated polling | ||
+ | os.system(" | ||
+ | #Send command to system to shutdown | ||
+ | except: | ||
+ | pass | ||
+ | |||
+ | GPIO.cleanup() | ||
+ | #Revert all GPIO pins to their normal states (i.e. input = safe) | ||
+ | </ | ||
===== Références ===== | ===== Références ===== | ||
monitoring_serveur_et_activites_du_disque_dur_avec_raspberry_pi.txt · Dernière modification : 2020/10/05 10:39 de serge