Dear J-M-L, I assure you that I tried in 115200 it was the same, the code edit is here,
#include <Wire.h>
#include <DFR_Key.h>
#include <DHT.h>
#include <LiquidCrystal_I2C.h>
const byte humidityRelay = 18;
const byte heaterRelay = 19;
const byte DHTPIN = 2;
const byte nbColumns = 16;
const byte nbLines = 2;
LiquidCrystal_I2C lcd( 0x27, nbColumns, nbLines);
int temp = 12;
int hum = 80;
int readkey;
unsigned long lastmillis;
long int hours;
long int minutes;
long int seconds;
char l2c1;
char l2c2;
char l2c3;
DHT dht (DHTPIN, DHT22); // Type de capteur DHT22 (AM2023)
DFR_Key keypad(0);
int localKey = 0;
int lcd_key = 0;
int adc_key_in = 0;
const byte btnRIGHT = 0;
const byte btnUP = 1;
const byte btnDOWN = 2;
const byte btnLEFT = 3;
const byte btnSELECT = 4;
const byte btnNONE = 5;
int read_LCD_buttons()
{
adc_key_in = analogRead(0);
if (adc_key_in > 1000) return btnNONE;
if (adc_key_in < 50) return btnRIGHT;
if (adc_key_in < 150) return btnUP;
if (adc_key_in < 300) return btnDOWN;
if (adc_key_in < 460) return btnLEFT;
if (adc_key_in < 690) return btnSELECT;
}
void setup()
{
pinMode(humidityRelay, OUTPUT);
pinMode(heaterRelay, OUTPUT);
lcd.begin(16, 2);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(F("Keith control")); // utilisé le macro F () dans tous les Print () du Lcd ou de Serial
lcd.setCursor(0, 1);
lcd.print(F("Select instr")); //
delay(2500);
Serial.begin(F(115200)); // Mettre le port série sur 115200 au lieu de 9600
dht.begin();
delay(1000);
lcd.clear();
keypad.setRate(10);
digitalWrite(humidityRelay, HIGH); // Relais Humidité actif
digitalWrite(heaterRelay, HIGH); // Relais Température actif
}
void loop()
{
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(t) || isnan(h))
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(F("Capteur N/C!!")); // utilisé le macro F ()
delay(10000);
}
else
{
lcd_key = read_LCD_buttons();
switch (lcd_key)
{
case btnLEFT:
{
temp = temp + 1;
break;
}
case btnRIGHT:
{
temp = temp - 1;
break;
}
case btnUP:
{
hum = hum + 1;
break;
}
case btnDOWN:
{
hum = hum - 1;
break;
}
case btnSELECT:
{
lcd.begin(16, 2);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(F("Hum Up/Down +-1%")); // utilisé le macro F ()
lcd.setCursor(0, 1);
lcd.print(F("Temp L/R +-1"));
lcd.print(F((char)223));
lcd.print(F("C"));
delay (5000);
break;
}
}
lcd.setCursor(0, 0);
lcd.print(F("Hum: ")); // utilisé le macro F () pour tous les lcd.print
lcd.print(F(h));
lcd.print(F("%"));
lcd.print(F("("));
lcd.print(F(hum));
lcd.print(F("%)"));
lcd.setCursor(0, 1);
lcd.print(F("Tem: "));
lcd.print(F(t));
lcd.print(F((char)223));
lcd.print(F("("));
lcd.print(F(temp));
lcd.print(F((char)223));
lcd.print(F(")"));
int H = 70 + 10;
if (h < 85) digitalWrite(humidityRelay, LOW);
else if (h >= H) digitalWrite(humidityRelay, HIGH);
int T = 12 + 2 ;
if (t < 12 )
digitalWrite(heaterRelay, LOW);
else if (t >= T)
digitalWrite(heaterRelay, HIGH);
}
}
no problem all your instructions are noted but I always received errors. I could not ask you to write the code for me, so I wrote down all your instructions piece by piece, and thank you very much.