jardin_script_python_pi5
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
jardin_script_python_pi5 [2025/06/25 13:47] – admin | jardin_script_python_pi5 [2025/07/22 17:35] (Version actuelle) – [Les variables] admin | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | ====== Création d'un script python ====== | + | ====== Création d'un script python |
Au cours de cette deuxième séance, nous allons construire pas à pas un script python. | Au cours de cette deuxième séance, nous allons construire pas à pas un script python. | ||
Ligne 61: | Ligne 61: | ||
</ | </ | ||
+ | Cette ligne permet de créer **un objet Python qui représente le capteur DHT22** connecté à la broche **GPIO 4** du Raspberry Pi. | ||
===== Les fonctions ===== | ===== Les fonctions ===== | ||
Ligne 69: | Ligne 70: | ||
< | < | ||
- | def calculer_point_de_rosee(temp, hum): | + | def calculer_point_de_rosee(temperature, humidity): |
... | ... | ||
- | def calculer_humidex(temperature, | + | def calculer_humidex(temperature, |
--- | --- | ||
Ligne 99: | Ligne 100: | ||
### | ### | ||
### | ### | ||
- | Le mot-clé **return** sert à **renvoyer | + | Le mot-clé **return** sert à **renvoyer |
### | ### | ||
Ligne 111: | Ligne 112: | ||
### | ### | ||
- | Fonction pour calculer l’**humidex**, | + | Fonction pour calculer l’**humidex**, |
### | ### | ||
Ligne 129: | Ligne 130: | ||
< | < | ||
- | humidity, temperature = Adafruit_DHT.read_retry(DHT_SENSOR, | + | humidity |
+ | temperature = dhtDevice.temperature | ||
</ | </ | ||
### | ### | ||
on utilise deux **variables**, | on utilise deux **variables**, | ||
- | La fonction | + | La fonction interroge le capteur et renvoie deux valeurs : l’humidité et la température mesurées. On les **dépose directement dans deux variables**, |
### | ### | ||
Ligne 237: | Ligne 239: | ||
time.sleep(20) | time.sleep(20) | ||
</ | </ | ||
+ | |||
+ | ---- | ||
+ | Suite vers [[jardin_bonus_openweather|Bonus : Utilisation de l'API d' |
jardin_script_python_pi5.1750859274.txt.gz · Dernière modification : de admin