Bonjour, depuis ce matin je n'arrive pas a envoyer depuis l'arduino et l'esp8266 une page HTML.
Je voudrais savoir ou est l'erreur dans mon code :
Code:#include <SoftwareSerial.h> SoftwareSerial esp8266(10,11); #define DEBUG true String NomduReseauWifi = "Wifi"; String MotDePasse = "*********"; int connectionId; String Command_CipSend; void setup() { esp8266.begin(9600); delay(2000); Serial.begin(9600); wifi_init(); } void loop() { if(esp8266.available()) { if(esp8266.find("+IPD,")) { delay(1000); int connectionId = esp8266.read()-48; String HTMLCode = "<HTML>" "<HEAD><TITLE>Baptiste Mini8266 Server</TITLE>" "<BODY><H1>Welcome to Pete's ESP8266 \"hacking\" project</H1>" "<form action=\"\" method=\"post\">" "<fieldset>" "<legend>Red LED State</legend>" "<input type=\"radio\" name=\"RedLEDState\" value=\"RED_ON\"> ON" "<input type=\"radio\" name=\"RedLEDState\" value=\"RED_OFF\" checked=\"checked\"> OFF<br>" "</fieldset>" "<fieldset>" "<legend>Green LED State</legend>" "<input type=\"radio\" name=\"GreenLEDState\" value=\"GREEN_ON\"> ON" "<input type=\"radio\" name=\"GreenLEDState\" value=\"GREEN_OFF\" checked=\"checked\"> OFF<br>" "</fieldset>" "<fieldset>" "<legend>Blue LED State</legend>" "<input type=\"radio\" name=\"BlueLEDState\" value=\"BLUE_ON\"> ON" "<input type=\"radio\" name=\"BlueLEDState\" value=\"BLUE_OFF\" checked=\"checked\"> OFF<br>" "</fieldset>" "<input type=\"submit\" value=\"Submit\">" "</form>" "<BR><BR>" "<HR>" "<H2>Server Stats</H2>" "</BODY> </HTML>"; Envoi_DATA(HTMLCode, connectionId); Close_Connect(connectionId); } } } //////////////////////////////////////////////////////////////////////////////////////// String Com_ESP8266(String command, const int timeout, boolean debug) { esp8266.print(command); String response = ""; long int time = millis(); while( (time+timeout) > millis()) { while(esp8266.available()) { char c = esp8266.read(); response+=c; } } if(debug) { Serial.println(response); Serial.println("-----------------------------------"); } return response; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////// void wifi_init() { Serial.println("**********************************************************"); Serial.println("**************** DEBUT DE L'INITIALISATION ***************"); Serial.println("**********************************************************"); //Com_ESP8266("AT+RST\r\n",1000,DEBUG); // Reset du module Com_ESP8266("AT+CIOBAUD=9600\r\n",1000,DEBUG); // On force la connexion a 9600 bds Com_ESP8266("AT+CWMODE=3\r\n",1000,DEBUG); // Configure le module en tant que serveur et client Com_ESP8266("AT+CWJAP=\""+ NomduReseauWifi + "\",\"" + MotDePasse +"\"\r\n",10000,DEBUG); // On se connecte au wifi Com_ESP8266("AT+CIFSR\r\n",1000,DEBUG); // Affiche l'adresse IP, Mac ... Com_ESP8266("AT+CIPMUX=1\r\n",1000,DEBUG); // On initialise en tant que serveur multi-client Com_ESP8266("AT+CIPSERVER=1,80\r\n",1000,DEBUG); // Ouvre le serveur sur le Port 80 Serial.println("**********************************************************"); Serial.println("***************** INITIALISATION TERMINEE ****************"); Serial.println("**********************************************************"); } void Envoi_DATA(String Data, int connectionId) { Command_CipSend = "AT+CIPSEND=" + String(connectionId) + "," + String(Data.length()+2) + "\r\n"; //Serial.println("Co ID : " + String(connectionId) ); //Serial.println("Length : " + String(Data.length()+2) ); //Serial.println("Data : " + String(Data) ); //Serial.println("Cmd : " + String(Command_CipSend) ); Com_ESP8266(String(Command_CipSend),1000,DEBUG); Com_ESP8266(String(Data),1000,DEBUG); } void Close_Connect(int connectionId) { String closeCommand = "AT+CIPCLOSE=" + String(connectionId) + "\r\n"; Com_ESP8266(closeCommand,3000,DEBUG); }
-----