Unable to connect to ESP8266

Hello All, almost one week now that I'm trying to send data from my ESP to a web browser,without sucess, so I need your help to understand why please.

So, I have a groove ESP8285 (ESP8266 but without big pins to connect on), so I can't flash my ESP (microship pin are to small for me to solder wires on) to use ESP8266 library and make programmation easy. So i can only use native AT commands to do all.
essai

So, I'm trying to send simple html text from my ESP, connected to an Arduino UNO (with an I2C lcd to show data received and transmitted).

When I connect the ESP direct to the computer with an USB/TTL converter, and I use AT commands with arduino Serial Monitor (cipmux, cipsendex, cipclose...) everything works fine. I'm able to send html text <h3>HELLO here</h3> from my ESP to a webrowser query.

But when I'm trying to code my arduino Uno, to be able to do the same job, it doesn't work, each time I try to connect to the ESP with my webrowser, the webbrowser can't acces to the ESP (of course, I used the right IP adress).

So I'm sure that my programmation code is incorrect.
Am I coding badly the "html" protocol before sending data ?
Am I sending wrong characters to set up well the ESP ? Invisible char needed ? (/n, /0 ??)

fctdonnesEntrante(){...} is for recording serial data when a client is trying to reach the ESP
reponseHttp(){...} is for sending HTTP response from the ESP to the client (webrowser)
cmd_send(){...} is for sending AT command to the ESP
printLcdHaut(){...} is for showing data coming from the arduino to the ESP
printLcdBas(){...} is for showing ESP response to any query

Need you help please to see what's wrong in my code...

#include <rgb_lcd.h>
rgb_lcd lcd;

const char cmdStart[] = "POST /arduino.php HTTP/1.1\r\n Host: myhost.com\r\nContent-Type: application/x-www-form-urlencoded\r\nConnection:Close\r\nContent-Length: ";
const char message[] = "<h3>HELLO here</h3>";
const char ok[2] = "CMDE TRANSMISE OK";
const char cmdEnd1[8] = "\r\n\r\n";
const char cmdEnd2 = '\0';
const char cmdEnd3 [2]= {'\r','\n'};
const char rst[6] = "AT+RST";
const char cwmode[11] = "AT+CWMODE=1";//mode station, reponse OK
const char cipmux[11] = "AT+CIPMUX=1";//mode TCP, reponse OK
const char cipserver[19] = "AT+CIPSERVER=1,8080";//ouverture du port 8080 en mode serveur, reponse OK
char cipsendex[19] = "AT+CIPSENDEX= ,2000";//preparation ร  lenvoi du message html
char donneesEntrante[500]={'\0'};
const char erreurConnexion[16] = "ERREUR CONNEXION";
const char erreurCanalFtp[16] = "ERREUR CANAL FTP";
const char cipclose0[13] = "AT+CIPCLOSE=0";
const char cipclose1[13] = "AT+CIPCLOSE=1";
const char cipclose2[13] = "AT+CIPCLOSE=2";

void setup() {
  Serial.begin(115200);
  lcd.begin(16, 2);

//INITIALISATION DE LA CARTE WIFI :

LOOP1 :

cmd_send(rst); // envoi reset
cmd_send(cmdEnd3); ///r/n
if (Serial.find("WIFI GOT IP")){
  printLcdBas(ok);
  videBuffer();
  delay(2000);}
//else {goto LOOP1;}

cmd_send(cwmode); // envoi mode station
cmd_send(cmdEnd3); ///r/n
if (Serial.find("OK")){
  printLcdBas(ok);
  videBuffer();
  delay(2000);}
//else { goto LOOP1;}  
  
cmd_send(cipmux); // envoi mode station
cmd_send(cmdEnd3); ///r/n
if (Serial.find("OK")){
  printLcdBas(ok);
  videBuffer();
  delay(2000);}
//else { goto LOOP1;} 
  
cmd_send(cipserver); // envoi mode station
cmd_send(cmdEnd3); ///r/n
if (Serial.find("OK")){
  printLcdBas(ok);
  videBuffer();
  delay(2000);}
//else { goto LOOP1;} 

}// fin du setup


//ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง
//ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง   LOOP   ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง

void loop() {
  
  if (Serial.available() > 0) {fctdonneesEntrante();}

}

//ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง
//ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง   ENREGISTREMENT et AFFICHAGE DONNEES ENTRANTE   ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง

void fctdonneesEntrante() {
 static int i =0;

  while(Serial.available()>0) {
  donneesEntrante[i]=Serial.read();
  i++;
  }
printLcdBas(donneesEntrante);
videBuffer();
reponseHttp();
donneesEntrante[500]={'\0'};

}

//ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง
//ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง   REPONSE HTTP ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง

void reponseHttp() {

    if(donneesEntrante[0]!='0' && donneesEntrante[0]!='1' && donneesEntrante[0]!='2'){ 
    printLcdBas(erreurConnexion);
    cmd_send(cipclose0);
    cmd_send(cmdEnd3); ///r/n
    cmd_send(cipclose1);
    cmd_send(cmdEnd3); ///r/n
    cmd_send(cipclose2);
    cmd_send(cmdEnd3); ///r/n
    }

    else{
    cipsendex[13] = donneesEntrante[0];
     cmd_send(cipsendex);
     cmd_send(cmdEnd3); ///r/n
     while(Serial.read() != '>'){};
     cmd_send(cmdStart);
     cmd_send(cmdEnd3); ///r/n
     cmd_send(message);
     cmd_send(cmdEnd3); ///r/n
     cmd_send(cmdEnd1);
     cmd_send(cmdEnd3); ///r/n
     cmd_send(cmdEnd2);
     cmd_send(cmdEnd3); ///r/n
     if(donneesEntrante[0]=='0') cmd_send(cipclose0);
     else if(donneesEntrante[0]=='1'){ 
     cmd_send(cipclose1);
     cmd_send(cmdEnd3);} ///r/n
     else if(donneesEntrante[0]=='2') {
      cmd_send(cipclose2);
     cmd_send(cmdEnd3);} ///r/n
     else {
     printLcdBas(erreurCanalFtp);
     cmd_send(cmdEnd3);} ///r/n
     
    }

}// fin fonction

//ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง
//ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง   CMDE SEND   ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง

void cmd_send(char donnees[]) {

for(int i=0;i<(strlen(donnees)-1);i++) Serial.print(donnees[i]);
printLcdHaut(donnees);
  
}


//ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง
//ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง   VIDE BUFFER   ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง

void videBuffer() {

  while (Serial.available() > 0) {Serial.read();}
  
}

//ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง
//ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง   PRINT LCD EN HAUT   ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง
void printLcdHaut(char txt[]) {
  static int a = strlen(txt);
  if (a>16) a=16;
  
  lcd.setCursor(0,0);
  lcd.print("               ");
  lcd.setCursor(0,0);
  for(int i=0;i<a;i++) lcd.print(txt[i]);
}

//ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง
//ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง   PRINT LCD EN BAS   ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง
void printLcdBas(char txt[]) {
  static int a = strlen(txt);
  if (a>16) a=16;
  
  lcd.setCursor(0,1);
  lcd.print("               ");
  lcd.setCursor(0,1);
  for(int i=0;i<a;i++) lcd.print(txt[i]);
}

have you had a look at WiFiESP which uses AT commands

What do you mean, doesn't it have the connector on it ? please show us the exact picture of your board.
If you have access to the UART (which you obviously do) all you need is access to GPIO 0, which i am confident, is what the 'boot' switch is for.

And after press and hold down 'boot' and press and release 'reset' and then release 'boot' You can program the ESP directly, probably by selecting 'Generic ESP8285' as a board.

Shame on me, I never heard about this library, I'll have a look at it...

essai
Here is what my pins look like on the other side of the groove UART wifi ESP8285, so I can only access to RX, TX, 0 et 5V.

I already try this method with selecting ESP8285, but it doesn't work...

I'm still very interested by someone who shows me and explain where are my mistakes in my program...

Which is all you need. Basically if you can communicate over the UART, you can upload new firmware.

Doesn't work is not very specific. Did you manage to compile a sketch using the ESP8266 core ? (which version)
Did you get an error message when trying to upload ?

Well about that, i don't normally support this method, but i can give you some pointers.
You are using hwSerial for communication and this good.
I would include the '\n\r' part of the command in the cmd_send() function, rather than sending it separately. You need to complete every line with it, and like that you won't forget.

void videBuffer() {
  while (Serial.available() > 0) {
      Serial.read();
      if (!Serial.available()) delayMicroseconds(200);  // like this you also get rid of any characters that are in the 
                                                                                    //process of being sent.
   }  
}

same here, and you need to make sure you don't write beyond the size of the array

while(Serial.available()>0) {
  donneesEntrante[i]=Serial.read();
  if (!Serial.available()) delayMicroseconds(200);
  if (i < 500) i++
  }
  donneesEntrante[i]='\0';  // and add the null terminator

You tried to add the null terminator, but you just copied the initial declaration, which is wrong

donneesEntrante[500]={'\0'};

this actually assigns 'null' to the first element of the array beyond it's size. In the declaration this results in the first element being set to 'null', but now it sets the 501st element, which doesn't exist. Behavior will be unpredictable.

const char cmdStart[] = "POST /arduino.php HTTP/1.1\r\n Host: myhost.com\r\nContent-Type: application/x-www-form-urlencoded\r\nConnection:Close\r\nContent-Length: ";

If that is the URL you are going to 'post' you will most likely not get a proper answer. A URL can not contain spaces. You will be returned an error message, which will not contain the data you hope to find. I may be wrong as to whether you actually send spaces as part of the URL, looking at it again.

This is a tricky method, you scan the buffer, rather than reading it.

In short, there are loads of things that i would do differently, and you have made some clear mistakes.
The method you are trying to use is as cumbersome as it appears, hence i suggest you have another go at uploading a sketch directly to the ESP.

eh...?

const char ok[2] = "CMDE TRANSMISE OK";

Thank you very much for you help.

I change the TLL/USB converter and I'm able to upload ESP8266 program into my ESP !!! :slight_smile: Thanks to @horace and you, I'm able to well understand wifi program.

I almost finish my program, but I need one last help to understand why it doesn't work properly. Here is my program below.

The Html page works when I use the pc webbrowser, but parameters doesn't appears... (next to ยฐC and %HR...)

(I send 12.2 65,2 22 97 12 21 12 12 10 on the arduino serial monitor)
When I try to print the content of the array to the arduino monitor, I got nothing on the monitor, array seems to be empty also... (serial.prinln(tIntC[0] for example) :confused:

So, Am I wrong declared array variable at the beginning of the program ? Am I wrong save data on the array on lectureInfoArduino()?
thanks for the help

#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>

//variable des paramรจtres arduino
char tIntC [35]= ""; //DHT
String tIntS = "";
char hrIntC [35]= ""; //DHT
String hrIntS = "";

char tTerreC [35]= ""; //DS28
String tTerreS = "";

char tExtC [35]= ""; //AHT
String tExtS = "";
char hrExtC [35]= ""; //AHT
String hrExtS = "";

char heureC [35]= "";
String heureS = "";
char mnC [35]= "";
String mnS = "";
char jourC [35]= "";
String jourS = "";
char moisC [35]= "";
String moisS = "";

ESP8266WebServer server(8080);

const int led = 13;
char x = 0;// pour le serial read

void setup(void) {

  Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  WiFi.begin("xxxxxxx","xxxx");
  //Serial.println("");

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    //Serial.print(".");
  }
  //Serial.println("");
  //Serial.print("Connected to ");
  //Serial.println(ssid);
  //Serial.print("IP address: ");
  //Serial.println(WiFi.localIP());

  /*if (MDNS.begin("esp8266")) {
    Serial.println("MDNS responder started");
  }*/

  server.on("/", handleRoot);

  server.onNotFound(handleNotFound);

  server.begin();
  //Serial.println("HTTP server started");
}

//ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง
//ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง LOOP ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง

void loop(void) {
  server.handleClient();
  MDNS.update();
}

//ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง
//ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง HANDLEROOT ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง

void handleRoot() {
  
  videBuffer();
  lectureInfoArduino();
  
  
  String message;
  message += "<html><body>";
      message += "<CENTER><h1>LA METEO AU POTAGER DE MOLO</h1></CENTER>";

        message += "<br><br>";
  
      message += "<h2>DANS LA SERRE</h2>";
      message += "<h3>Temp&eacuterature: <font color=\"FF0000\">";
      message += tIntS; //DHT
      message += "</font>&degC</h3>\n";
      message += "<h3>Humidit&eacute: <font color=\"0000FF\">";
      message += hrIntS; //DHT
      message += "</font>%HR</h3>";

        message += "<br>";

      message += "<h2>AUTOUR DE LA SERRE</h2>";
      message += "<h3>Temp&eacuterature: <font color=\"FF0000\">";
      message += tExtS; //ATH
      message += "</font>&degC</h3>\n";
      message += "<h3>Humidit&eacute: <font color=\"0000FF\">";
      message += hrExtS; //ATH
      message += "</font>%HR</h3>"; 

        message += "<br>";

      message += "<h2>SOUS TERRE</h2>";
      message += "<h3>Temp&eacuterature: <font color=\"FF0000\">";
      message += tTerreS; //DS28
      message += "</font>&degC</h3>";    

        message += "<br>";

      message += "<h2>DATE ET HEURE ACQUISITION</h2>";
      message += "<h3>Heure: ";
      message += heureS; //DS28
      message += "h"; //DS28
      message += mnS; //DS28
      message += "</h3>\n";
      
      message += "<h3>Jour: ";
      message += jourS; //DS28
      message += "/"; //DS28
      message += moisS; //DS28
      message += "</h3>\n";
 

  message += "</body></html>";
  
  server.send(200, "text/html", message);
  
}

//ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง
//ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง HANDLE NOT FOUND ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง

void handleNotFound() {
  
  String message = "<h1>La page demandรฉe n'existe pas !</h1>";

  server.send(404, "text/html", message);
  
}

//ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง
//ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง LECTURE ARDUINO ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง

void lectureInfoArduino(){

int i = 0;
Serial.print("@");

    while(Serial.available() == 0) {delay(20);}

        
        do{/////////////////////////////////INTERIEUR////////////////////
              tIntC[i] = Serial.read();
              if(Serial.available()==0) delay(20);
              if(tIntC[i] = ' ') tIntC[i] = '\0';
            
        }while(tIntC[i] =! ' ');
        tIntS = String(tIntC);// conversion en String pour envoyer en http
        tIntC[i] = '\0';
        i=0;
        Serial.println(tIntC[0]); // nothing appears on serial monitor ??
        Serial.println(tIntC[1]);
        
        do{
              hrIntC[i] = Serial.read();
              if(Serial.available()==0) delay(20);
            
        }while(hrIntC[i] =! ' ');
        hrIntS = String(hrIntC);// conversion en String pour envoyer en http
        hrIntC[i] = '\0';
        i=0;

  
        do{/////////////////////////////////EXTERIEUR/////////////////
              tExtC[i] = Serial.read();
              if(Serial.available()==0) delay(20);
            
        }while(tExtC[i] =! ' ');
        tExtS = String(tExtC);// conversion en String pour envoyer en http
        hrExtC[i] = '\0';
        i=0;

        do{
              hrExtC[i] = Serial.read();
              if(Serial.available()==0) delay(20);
             
        }while(hrExtC[i] =! ' ');
        hrExtS = String(tExtC);// conversion en String pour envoyer en http
        hrExtC[i] = '\0';
        i=0;

  
        do{/////////////////////////////////SOUS TERRE/////////////////
              tTerreC[i] = Serial.read();
              if(Serial.available()==0) delay(20);
            
        }while(tTerreC[i] =! ' ');
        tTerreS = String(tTerreC);// conversion en String pour envoyer en http
        tTerreC[i] = '\0';
        i=0;

  
        do{/////////////////////////////////DATE ET HEURE/////////////////
              heureC[i] = Serial.read();
              if(Serial.available()==0) delay(20);
            
        }while(heureC[i] =! ' ');
        heureS = String(heureC);// conversion en String pour envoyer en http
        heureC[i] = '\0';
        i=0;

        do{
              mnC[i] = Serial.read();
              if(Serial.available()==0) delay(20);
             
        }while(mnC[i] =! ' ');
        mnS = String(mnC);// conversion en String pour envoyer en http
        mnC[i] = '\0';
        i=0;

        do{
              jourC[i] = Serial.read();
              if(Serial.available()==0) delay(20);
            
        }while(jourC[i] =! ' ');
        jourS = String(jourC);// conversion en String pour envoyer en http
        jourC[i] = '\0';
        i=0;

        do{
              moisC[i] = Serial.read();
              if(Serial.available()==0) delay(20);
             
        }while(moisC[i] =! ' ');
        moisS = String(moisC);// conversion en String pour envoyer en http
        moisC[i] = '\0';
        Serial.println("moisC[0]");
        

//12.2 65,2 22 97 12 21 12 12 10 

}// fin de la fonction

//ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง
//ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง VIDE BUFFER   ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง

void videBuffer(){

while(Serial.available() > 0) Serial.read();

}// fin de la fonction```

The variables are still empty. The values never get received because this function,

void lectureInfoArduino(){

is never called, which is partly a good thing, because it has this line in there

while(Serial.available() == 0) {delay(20);}

That holds up the processor until it receives serial, which would be blocking the server.handleClient() function within loop(). It really makes no sense. Remove that line ! Or even better, change it to

If (Serial.available() == 0)  return;

And then just call the function from loop()

void loop(void) {
  server.handleClient();
  MDNS.update();
  lectureInfoArduino();
}

I am not convinced of the quality of your Serial reception function. (actually i am convinced that it is not to good) It will only work if a correct and complete message is sent, (i think it will work, but there are many issues in it) and otherwise results may be unpredictable. Just in general, you don't always test that there is data in the buffer, before you call read() which is wrong !.
Actually have a look at Serial Input Basics for more reliable methods of receiving serial data.

Thank you for your response @Deva_Rishi
I called lectureInfoArduino() at the beginning of handleRoot() fonction, because I want data to be download by the esp from the arduino (uno) only when a client is connected, and not at every esp loop fonction.

So, what does the return you suggest will do ? Only exiting the lectureInfoArduino ? So if the ESP has not got data from arduino the client won't get the right value on the web page ?

Except puting the solution to put lectureInfoArduinoin the loop (I will try tonight), I still don't understand why it doesn't work on the handleRoot() fonction...

I already read the serial input basics tutorial, but I will re-read it...

Well you should adopt one of it's methods probably. (actually for sure. Rather than creating your own method as you have done, which does not take into account anything that might go wrong.)

If there is no data, it will exit the function. Now the function holds the processing stream indefinitely until data is received (by which time the browser may have timed-out and will not have an answer to the request)

The whole function has a few mistakes, not checking the available data before reading it being the biggest one.

You should read any data when it is available. If the UNO sends data you should read it and parse it into the appropriate variables, then you can include these variables in the webpage (as you've done) and they will reflect the most recent data received.
That is the proper way of doing it.
The webserver callback function should extract data from the client (either a post or get request) and act upon that if required, and it should serve the webpage back to the client.

In my case, the ESP is linked (with wire) to the arduino.
So, when there is client, the ESP send a char "@" to the arduino. When the arduino receive the right char, it send all the data to the ESP.
So if I adopt these method (ie call void lectureInfoArduino(){ modified like serial inputs basics tutorial) in the ESP loop, what's happen then if arduino don't send data immediately ? So the esp goes out to void lectureInfoArduino(){, continue the void handleRoot(){ function and send an incomplete html data to the client ?

For me, to be sure to catch all data before sending the response to client, I have to be sure that all data is reveived on the void lectureInfoArduino(){ before continuing the void handleRoot(){ ? So the only solution is to put this function in the handleroot() and not in the loop ?

Am I wrong ? Or what is wrong in my analysis ?

I'll modif my program to be sure to have data before reading it, and also use the parsing method which will simplify all my program ^^

But the Arduino is the arduino. It should send the data back, but you should accommodate for it not to send it back (in time) If that is the case, you should serve the client with a page telling you that that is what is happening.

In that case, it can send whatever data is has received last, and you can of course include a timestamp, telling you when the last time was a full set of data has been received.

Regardless of that, if your ESP does not receive data, you have to make sure that you will still have a responsive program running.

That results in the data being read from the buffer only if handleRoot() is called.
I understand that you simply want to pass the request on to the UNO, and wait back for it's response, but i would not use this chain of events. I am not saying that it can not work, but i would request the data from the UNO at regular intervals, or even just let the UNO send the data at regular intervals, and read and parse the data, and serve the page with the last data received.

I'm so happpppyyyy, yeah ! Everything works fine now with your advice, I'm able to read all temperature, humidity and others parameters of different sensors linked to my arduino UNO, via the ESP, on a webbrowser anywhere ! Even with my phone !

If someone is interested by the program, don't hesitate to send me a message.

Thanks @Deva_Rishi and @horace