Partage
  • Partager sur Facebook
  • Partager sur Twitter

mon relais ne veut pas éteindre mon chauffage

    8 août 2020 à 19:44:31

    Bonjour,

    J'ai connecté un relais à ma carte arduino et à mon chauffage.

    Après quelques petits test, mon chauffage, mon relais et mon de marchaient. 

    le code : 

    void loop(){
       digitalWrite(CHAUFFAGE, HIGH);
       digitalWrite(VENTILO, LOW); 
       delay(4000);
       digitalWrite(CHAUFFAGE, LOW);       
       digitalWrite(VENTILO, HIGH);
       delay(4000);
    }

    MAIS quand je modifie cette partie de code et que je l'ajoute a mon autre script cela ne marche plus :'(

    le nouveau code :(pour info "T" c'est la température que va prendre mon capteur de température)

    float VoutArray[] =  { 0.0011498,  0.0033908,   0.011498, 0.041803,0.15199,     0.53367, 1.3689,   1.9068,  2.3};
    float  LuxArray[] =  { 1.0108,     3.1201,  9.8051,   27.43,   69.545,   232.67,  645.11,   73.52,  1000};
    
    //capteur de luminosité
      long tref = 0;
      long prevMillis = 0;
      String mode = "";
      int lum = 0;
      #define capteur_lum = A0;
      #define DELAY 1000;                      
    
    
    //bluetooth
      #include <SoftwareSerial.h>
      #define RxD 6
      #define TxD 7
      #define PINBUTTON 9
      #define DEBUG_ENABLED 1
      SoftwareSerial blueToothSerial(RxD,TxD);
      
    // chauffage
       #define CHAUFFAGE  13
    
    // ventilo
      #define VENTILO 12
      
    // capteur d'h et de T
      #include <dht11.h>
      #define DHT11PIN 2 
      int H = 0;
      int T = 0;
      dht11 DHT11;
      
    void setup() {
        // put your setup code here, to run once:
        Serial.begin(9600);
    
        //ventilo
        pinMode ( VENTILO ,  OUTPUT );
        pinMode ( CHAUFFAGE ,  OUTPUT );
    
        //bluetooth
          pinMode(RxD, INPUT);
          pinMode(TxD, OUTPUT);
          setupBlueToothConnection();
          //wait 1s and flush the serial buffer
          delay(1000);
          Serial.flush();
          blueToothSerial.flush();
    
        //Envoyer des infos au tel
          blueToothSerial.begin(9600);
    
    
    }
    
    void loop() {
    
        // put your main code here, to run repeatedly:
        millis();
    
    
        if (millis() > ( tref + 3000)) {
          
          int lum = readLuminance(A0);
          H = (float)DHT11.humidity;
          T = (float)DHT11.temperature; 
           
          if (lum > 700) {                  
            Serial.println("Allumé");
            Serial.println(lum);
            DHT11.read(DHT11PIN);
            Serial.print("Humdiité :");
            Serial.println(H);
            Serial.print("Température :");
            Serial.println(T);
            Serial.println("----------------------");
            //on envoit l'info au tel
            blueToothSerial.print("2");
            blueToothSerial.print(T);
            blueToothSerial.print(H);
          }
          else {
            Serial.println("Eteint");
            Serial.println(lum);
            DHT11.read(DHT11PIN);
            Serial.print("Humdiité :");
            Serial.println(H);
            Serial.print("Température :");
            Serial.println(T);
            Serial.println("----------------------");
            //on envoit l'info au tel
            blueToothSerial.print("1");
            blueToothSerial.print(T);
            blueToothSerial.print(H);
            }
      
        if (T<30) {                         // <---------------------------------C'est ici
          digitalWrite(CHAUFFAGE, HIGH);
          digitalWrite(VENTILO, LOW); 
         }
        else {
        digitalWrite(CHAUFFAGE, LOW);
         digitalWrite(VENTILO, HIGH);
    
        }
          
          
            tref = millis();    
        }
    
    
    }
    
    //Capteur de Luminosité 
        float readAPDS9002Vout(uint8_t analogpin)
        {
            // MeasuredVout = ADC Value * (Vcc / 1023) * (3 / Vcc)
            // Vout samples are with reference to 3V Vcc
            // The above expression is simplified by cancelling out Vcc
            float MeasuredVout = analogRead(A0) * (3.0 / 1023.0);
            //Above 2.3V , the sensor value is saturated
            
            return MeasuredVout;
         
        }
         
        float readLuminance(uint8_t analogpin)
        {
         
            // MeasuredVout = ADC Value * (Vcc / 1023) * (3 / Vcc)
            // Vout samples are with reference to 3V Vcc
            // The above expression is simplified by cancelling out Vcc
            float MeasuredVout = analogRead(A0) * (3.0 / 1023.0);
            float Luminance = FmultiMap(MeasuredVout, VoutArray, LuxArray, 9);
         
            return Luminance;
     } 
    
    float FmultiMap(float val, float * _in, float * _out, uint8_t size)
        {
            // take care the value is within range
            // val = constrain(val, _in[0], _in[size-1]);
            if (val <= _in[0]) return _out[0];
            if (val >= _in[size-1]) return _out[size-1];
         
            // search right interval
            uint8_t pos = 1;  // _in[0] allready tested
            while(val > _in[pos]) pos++;
         
            // this will handle all exact "points" in the _in array
            if (val == _in[pos]) return _out[pos];
         
            // interpolate in the right segment for the rest
            return (val - _in[pos-1]) * (_out[pos] - _out[pos-1]) / (_in[pos] - _in[pos-1]) + _out[pos-1];
        }
    
    
    
    
    //bluetooth
        void setupBlueToothConnection(){
        
          
            blueToothSerial.begin(9600);  
          
          blueToothSerial.print("AT");
          delay(400); 
          
          blueToothSerial.print("AT+DEFAULT");             // Restore all setup value to factory setup
          delay(2000); 
          
          blueToothSerial.print("AT+NAMESeeedMaster");    // set the bluetooth name as "SeeedMaster" ,the length of bluetooth name must less than 12 characters.
          delay(400);
          
          blueToothSerial.print("AT+ROLES");             // set the bluetooth work in slave mode
          delay(400); 
          
          
          blueToothSerial.print("AT+AUTH1");            
            delay(400);    
        
          blueToothSerial.print("AT+PIN9734");            
            delay(400);   
        
           blueToothSerial.print("AT+ADDR");            
            delay(400);
          
          blueToothSerial.print("AT+CLEAR");             // Clear connected device mac address
            delay(400);   
          
            blueToothSerial.flush();
          
          
        } 

    Ce qu'il se passe c'est que le chauffage s'allume mais ne se coupe plus...

    Merci de l'attention que vous allez passer sur ce post !!

    -
    Edité par IteWaseMi 8 août 2020 à 19:48:49

    • Partager sur Facebook
    • Partager sur Twitter
      9 août 2020 à 16:08:01

      Bien que ce code puisse être perfectible, je ne vois pas pourquoi il ne fonctionnerait pas.

      Peut-être un mauvais câblage ? Comment as tu raccordé ton capteur DHT11 à l'arduino ?

      Ou bien un problème de lib ? Pourrais tu nous donner le lien de téléchargement de ta lib DHT11 ? (je n'ai pas l'impression qu'il s'agisse de la lib Adafruit officielle)

      • Partager sur Facebook
      • Partager sur Twitter
        9 août 2020 à 17:34:01

        j'ai connecte mon chauffage a mon relais, mon relais est correctement connecté a la carte arduino. Mon capteur DHT11 est connecté a la broche D2 de ma base shield.

        Malheureusement je ne trouve plus la lib que j'ai téléchargé, mais le capteur de température marche a la perfection, je ne vois pas en quoi il pourrait poser problème.

        • Partager sur Facebook
        • Partager sur Twitter
          9 août 2020 à 21:07:40

          Si tout marche à la perfection et que tout est bien câblé, il n'y a pas de raison que ton relais reste piloté en permanence.

          Tu as pris soin de mettre pleins de Serial.print pour afficher les données de tes capteurs, c'est le moment d'en profiter : que vois tu s'afficher dans la console Arduino sur ton PC ?

          Sinon, remarque à part qui n'a rien à voir avec ton DTH11 : je me permet de mettre en doute ta variable LuxArray.

          Je trouve assez étrange que ton tableau augmente de 1.0108 jusqu'à 645.11 puis redescent à 73.52 pour ensuite retourner à 1000.

          N'y aurait-il pas une virgule mal placée ?

          -
          Edité par lorrio 9 août 2020 à 21:16:09

          • Partager sur Facebook
          • Partager sur Twitter
            15 août 2020 à 19:40:56

            Je suis actuellement en vacance, je te répondrais plus tard (dans 2 semaines).

            Par contre merci, je n'avais pas vu mais il y a une petite erreur 😁

            • Partager sur Facebook
            • Partager sur Twitter

            mon relais ne veut pas éteindre mon chauffage

            × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
            × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
            • Editeur
            • Markdown