comment faire

Voila j’ai un souci ma pompe n’arrete pas de s’allumer et s’éteindre souvent je ne sais pas comment remidier au problème.
Sachant que je voudrais une constante d’humidité a 70%
Merci de bien vouloir m’aider.
Voici mon code:

 // Programme terrarium 
#include <DHT.h>
#define DHTPIN 8 // capteur humidité 
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
int led= 13; //led fonctionnement   
int relais = 7; // pompe a brumifier


#include <LiquidCrystal.h>
const int RS=12; 
const int E=11; 
const int D4=5; 
const int D5=4; 
const int D6=3; 
const int D7=2; 
LiquidCrystal lcd(RS,E,D4,D5,D6,D7);// Initialisation du LCD
const int intTimePause =100;

void setup ()
{
  lcd.begin(16,1) ; // config écran
  delay(100);
  lcd.clear() ; // initialisé ecran
  delay(100);
  lcd.print("Hello Oscar");
  delay(10000);
  lcd.home();
  lcd.print("Fonction ok");
  delay(10000);
  lcd.clear();
  delay(10);
  pinMode(relais, OUTPUT) ; // config sorti pompe
  pinMode(led, OUTPUT);
  Serial.begin(9600) ; 
  Serial.println(" bonjour christopher ") ;  
}


void loop() {
  
  float h = dht.readHumidity();
  float t = dht.readTemperature();

 if (isnan (h))
 {
  lcd.print("erreur capteur!");
  delay(10000);
  lcd.clear();
  digitalWrite(relais, HIGH);
    return; 
 }
    lcd.setCursor(0,0);
    lcd.print(" humi:");
    lcd.print(h);
    lcd.print("%" );
    digitalWrite(relais, HIGH);
    digitalWrite(led, HIGH);  
    
  if (h<70)
  {
    digitalWrite(relais, LOW);
    digitalWrite(led, LOW);
  }
}

Sorry, I can’t read French. But Google thinks you said…

Here I have a problem my pump does not stop to turn on and off often I do not know how remidier the problem.
Knowing that I would like a constant humidity at 70 %
Thank you kindly help me .
Here is my code

I think your problem is in these lines:

   digitalWrite(relais, HIGH);
    digitalWrite(led, HIGH);  
    
  if (h<70)
  {
    digitalWrite(relais, LOW);
    digitalWrite(led, LOW);
  }

You are turning the relay on every time through the loop. Instead, I think you want:

if (h > 72)
{
    digitalWrite(relais, HIGH);
    digitalWrite(led, HIGH);  
}
else if (h < 70)
{
    digitalWrite(relais, LOW);
    digitalWrite(led, LOW);
}

I made the threshold (72) for turning the relay on (and presumably pump) slightly higher than the threshold to turn it off (70) so that noise on your humidity measurement doesn’t switch the relay on and off rapidly.

Good luck,
Paul.

[shudder] I see magic numbers...*

Hopefully a moderator will see this and move it to the French section of the forum.

*Paul, that's poor advice to give someone only just starting out. Start them on the right track with named constants.

MERCI

Agreed Morgan.

Magic numbers are a really bad idea. Djlive, you might want to check out the "Unnamed numerical constants" section in this article: https://en.wikipedia.org/wiki/Magic_number_(programming) ou en français: https://fr.wikipedia.org/wiki/Nombre_magique_(programmation)