// // ######################## // # CHALET SANS RESEAU # // ######################## // # Guy Magli 18.12.2020 # // ######################## // # Conception, cablages # // # mises a jour, # // # contact... # // # www.magli.fr # // ######################## // // Afin d'eviter les problemes d'affichage et d'impression les signes diacritiques // ont ete retires des commentaires et des chaines de caracteres. // // ! ======================== ! // ! LIBRAIRIES ET PARAMETRES ! // ! ======================== ! // #include #include #include // Capteur temperature, pression, humidite. #include // Broches 20 et 21. // // ! ================================================= ! // ! VARIABLES GLOBALES, CONSTANTES ET INITIALISATIONS ! // ! ================================================= ! // // : ----------------------------------------------------------------------- : // : Accessoire de mesure de la temperature, de la pression et de l'humidite : // : ----------------------------------------------------------------------- : // Adafruit_BME280 bme; int iTemperatureAllumageGyrophare = 0; // on allume le gyrophare, // 0 degre int iTemperatureAllumageChauffage = 0; // on allume le chauffage, // 0 degre int iTemperatureExtinctionGyrophare = 2; // on eteint le gyrophare, // 2 degres int iTemperatureExtinctionChauffage = 2; // et on eteint le chauffage. // 2 degres int iGyrophare = 8; // Broches du relais du gyrophare int iChauffage = 9; // et du chauffage. bool bGyrophareAllume = false; // Le gyrophare est eteint. bool bChauffageAllume = false; // Le chauffage est eteint. String cPluriel = ""; // Pour un eventuel accord du nombre. int t; // Pour les boucles diverses. // // ! ===== ! // ! SETUP ! // ! ===== ! // void setup() { // // Pour la communication via la console. // Serial.begin(9600); delay(2000); Serial.println(" "); Serial.println(": -------------------------------------- :"); Serial.println(": BOITIER DE MAINTIEN HORS GEL DU CHALET :"); Serial.println(": -------------------------------------- :"); Serial.println(" "); // // Extinction du gyrophare au demarrage. // pinMode(iGyrophare, OUTPUT); digitalWrite(iGyrophare, LOW); bGyrophareAllume = false; Serial.println("<= Extinction du gyrophare."); Serial.println(" "); // // Extinction du chauffage au demarrage. // pinMode(iChauffage, OUTPUT); digitalWrite(iChauffage, LOW); bChauffageAllume = false; Serial.println("<= Extinction du chauffage."); Serial.println(" "); // Test du thermometre. if (bme.begin()) { Serial.println("-> Le thermometre fonctionne correctement."); Serial.println(" "); } else { Serial.println("-> Le thermometre NE fonctionne PAS correctement."); Serial.println(" "); // // Extinction du gyrophare par mesure de securite si le thermometre ne fonctionne pas. // digitalWrite(iGyrophare, LOW); bGyrophareAllume = false; Serial.println("<= Maintien de l'extinction du gyrophare par mesure de securite."); Serial.println(" "); // // Extinction du chauffage par mesure de securite. // digitalWrite(iChauffage, LOW); bChauffageAllume = false; Serial.println("<= Maintien de l'extinction du chauffage par mesure de securite."); Serial.println(" "); } Serial.print("La temperature actuelle est de "); Serial.print(bme.readTemperature()); Serial.println(" degre.s."); Serial.println(" "); Serial.print("Actuellement, le gyrophare est "); if (bGyrophareAllume == true) { Serial.println("en marche."); Serial.println(" "); } else { Serial.println("arrete."); Serial.println(" "); } Serial.print("Actuellement, le chauffage est "); if (bChauffageAllume == true) { Serial.println("en marche."); Serial.println(" "); } else { Serial.println("arrete."); Serial.println(" "); } } // // ! ==== ! // ! LOOP ! // ! ==== ! // void loop() { // // Mesure des temperatures en continu // if (bme.begin()) { Serial.println("-> Le thermometre fonctionne correctement."); Serial.println(" "); Serial.print("La temperature actuelle est de "); Serial.print(bme.readTemperature()); Serial.println(" degre.s."); Serial.println(" "); Serial.print("Actuellement, le chauffage est "); if (bChauffageAllume == true) { Serial.println("en marche."); Serial.println(" "); } else { Serial.println("arrete."); Serial.println(" "); } Serial.print("Actuellement, le gyrophare est "); if (bGyrophareAllume == true) { Serial.println("en marche."); Serial.println(" "); } else { Serial.println("arrete."); Serial.println(" "); } // Allumage du gyrophare si la temperature descend sous un seuil. if ((bme.readTemperature() <= iTemperatureAllumageGyrophare) && (bGyrophareAllume == false)) { digitalWrite(iGyrophare, HIGH); bGyrophareAllume = true; Serial.print("=> Allumage du gyrophare a "); Serial.print(bme.readTemperature()); Serial.print(" degre.s sur "); Serial.println(iTemperatureAllumageGyrophare); Serial.println(" "); } // Allumage du chauffage si la temperature descend sous un seuil. if ((bme.readTemperature() <= iTemperatureAllumageChauffage) && (bChauffageAllume == false)) { delay(3000); digitalWrite(iChauffage, HIGH); bChauffageAllume = true; Serial.print("=> Allumage du chauffage a "); Serial.print(bme.readTemperature()); Serial.print(" degre.s sur "); Serial.println(iTemperatureAllumageChauffage); Serial.println(" "); } // Extinction du gyrophare lorsque la temperature remonte au dessus d'un seuil. if ((bme.readTemperature() >= iTemperatureExtinctionGyrophare) && (bGyrophareAllume == true)) { digitalWrite(iGyrophare, LOW); bGyrophareAllume = false; Serial.print("<= Extinction du gyrophare a "); Serial.print(bme.readTemperature()); Serial.print(" degre.s sur "); Serial.println(iTemperatureExtinctionGyrophare); Serial.println(" "); } // Extinction du chauffage lorsque la temperature remonte au dessus d'un seuil. if ((bme.readTemperature() >= iTemperatureExtinctionChauffage) && (bChauffageAllume == true)) { digitalWrite(iChauffage, LOW); bChauffageAllume = false; Serial.print("<= Extinction du chauffage a "); Serial.print(bme.readTemperature()); Serial.print(" degre.s sur "); Serial.println(iTemperatureExtinctionChauffage); Serial.println(" "); } } else { Serial.println("-> Le thermometre NE fonctionne PAS correctement."); Serial.println(" "); // // Extinction du gyrophare par mesure de securite. // digitalWrite(iGyrophare, LOW); bGyrophareAllume = false; Serial.println("<= Extinction du gyrophare par mesure de securite."); Serial.println(" "); // // Extinction du chauffage par mesure de securite. // digitalWrite(iChauffage, LOW); bChauffageAllume = false; Serial.println("<= Extinction du chauffage par mesure de securite."); Serial.println(" "); } Serial.println("(60 secondes d'attente)"); for (t = 0; t < 60; t++) //Inutile de surcharger le reseau ! { delay(1000); Serial.print(">"); } Serial.println(" "); }