le problème est le suivant après avoir televerser le programme dans la carte celle ci ne réagit pas ,pour établir une connexion wifi avec ma livebox je dois débrancher la diode (branché sur le port d3 et gnd)et redémarré électriquement la carte afin que celle ci se connecte puis rebranché la diode et la tous fonctionne correctement mais a la première coupure de courant je doit recommencer la manœuvre afin que tous rentre dans l'ordre
je met ici le code que j'ai assemblé en prenant plusieurs code de projet différent aussi certaine chose sont peut être inutile
je remercie d'avance les personnes qui m'aideront a comprendre mon erreur
#include <IRremoteESP8266.h>
#include <IRremoteInt.h>
#include <ESP8266WiFi.h>
#include <Dhcp.h>
#include <Dns.h>
#include <string.h>
#include <SPI.h>
const char* ssid = "Livebox-....";
const char* password = "...............................";
// Create an instance of the server
// specify the port to listen on as an argument
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
byte gateway[] = { 90,.., ..., ... }; // internet access via router
WiFiServer server(80);
WiFiServer serveurHTTP(7000);
int khz = 38; //NB Change this default value as neccessary to the correct modulation frequency
// CHAUD - ON
unsigned OFF[201] = {4432, 4332, 604, 1576, 608, 488,
604, 1572, 608, 1572, 608, 488, 604, 488,
604, 1576, 604, 492, 580, 508, 608, 1572,
608, 488, 604, 488, 604, 1576, 604, 1576,
604, 488, 608, 1576, 580, 512, 604, 488,
604, 1576, 604, 1576, 604, 1576, 604, 1576,
604, 1576, 604, 1576, 580, 1600, 604, 1576,
604, 488, 604, 488, 608, 488, 604, 488, 604,
488, 604, 492, 580, 508, 608, 1572, 608, 488,
604, 488, 604, 1576, 604, 1576, 604, 488,
604, 492, 580, 1596, 608, 484, 608, 1572, 608,
1572, 608, 488, 604, 488, 604, 1576, 604,
1572, 584, 5172, 4412, 4328, 580, 1600, 604,
488, 608, 1572, 608, 1572, 608, 488, 604, 488,
604, 1572, 608, 488, 580, 512, 604, 1576, 604,
488, 604, 488, 604, 1576, 604, 1576, 604, 488,
604, 1576, 580, 512, 604, 488, 608, 1572, 604,
1576, 604, 1576, 604, 1576, 604, 1576, 604, 1576,
580, 1600, 604, 1576, 604, 488, 604, 488, 604, 488,
608, 488, 604, 488, 604, 488, 580, 512, 604, 1576,
604, 488, 604, 488, 608, 1572, 604, 1576, 604, 488,
608, 488, 580, 1596, 608, 488, 604, 1572, 608, 1576,
604, 488, 604, 488, 604, 1576, 604, 1576, 580, 64788, 140,
};
// FROID -ON
unsigned COOL[199] = { 4436, 4324, 580, 1600, 580, 512, 608, 1576, 604, 1576, 604, 488,
608, 488, 604, 1576, 580, 516, 604, 488, 604, 1576, 580, 512, 608, 488, 604, 1576, 604,
1576, 608, 488, 604, 1576, 584, 508, 608, 1572, 608, 1576, 580, 1600, 608, 1576, 604, 488,
608, 1572, 608, 1576, 584, 1596, 608, 488, 604, 488, 608, 488, 580, 512, 608, 1572, 608,
484, 608, 488, 584, 1596, 608, 1572, 608, 1576, 580, 516, 604, 488, 604, 488, 608, 488,
604, 488, 584, 508, 584, 508, 584, 512, 604, 1576, 604, 1576, 608, 1576, 604, 1576, 608,
1576, 580, 5180, 4384, 4360, 584, 1596, 608, 488, 604, 1576, 608, 1572, 584, 512, 604,
488, 608, 1572, 584, 516, 604, 484, 608, 1576, 604, 488, 608, 488, 604, 1576, 580, 1600,
608, 488, 604, 1580, 580, 512, 604, 1576, 608, 1576, 580, 1600, 580, 1600, 608, 488, 608,
1572, 608, 1576, 584, 1596, 584, 512, 604, 488, 608, 488, 604, 488, 608, 1572, 584, 512,
604, 488, 608, 1572, 608, 1576, 604, 1576, 580, 516, 604, 488, 604, 488, 608, 488, 604, 492,
604, 488, 604, 488, 608, 484, 608, 1576, 580, 1600, 608, 1576, 604, 1576, 580, 1604, 580,
};
IRsend irsend(0);
String readString; //string
boolean COOLON = false; // flag status Cooling
boolean DRYON = false; // flag status Drying
void setup(void){
irsend.begin();
Serial.begin(115200);
WiFi.begin(ssid, password);
serveurHTTP.begin();
Serial.println("");
// Connect to WiFi network
Serial.println();
Serial.print("Connecting to ludo ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
// Start the server
server.begin();
Serial.println("Server started");
// Print the IP address
Serial.println(WiFi.localIP());
}
void loop() {
// Check if a client has connected
WiFiClient client = server.available();
if (client) {
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
readString.concat(c); //memorizzo ogni carattere della stringa
//if HTTP request has ended
if (c == '\n' && currentLineIsBlank) {
Serial.print(readString);
if (readString.indexOf("L=0") > 0) {
if (COOLON || DRYON) { // if is ON, switch it OFF
//Serial.println("AC -> OFF");
irsend.sendRaw(OFF, sizeof(OFF) / sizeof(int), khz);
COOLON = false;
DRYON = false;
}
}
else if (readString.indexOf("L=1") > 0) { // lettura del valore se il AC si deve accendere
if (!DRYON) { //se non è acceso
//Serial.println("CHAUD ON");
irsend.sendRaw(OFF, sizeof(OFF) / sizeof(int), khz);
DRYON = true;
COOLON = false;
}
}
else if (readString.indexOf("L=2") > 0) {
if (!COOLON) { //se è acceso
//Serial.println("FROID ON");
irsend.sendRaw(COOL, sizeof(COOL) / sizeof(int), khz);
COOLON = true;
DRYON = false;
}
}
// COSTRUZIONE PAGINA HTML
client.println("HTTP/192.168.1.14");
client.println("Content-Type: text/html");
client.println();
// inizializzo pagina (da togliere se uso ajax)
client.print("<html><head><title>CONTROLE CLIMATISATION</title><meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' ></head><body>");
//iniza il body
client.println("<div style='width:960px; height:1136px;'>");
client.println("<h1>COMMANDE</h1>");
//scrivo il AC status
client.print("<font size='5'>Status: ");
if (COOLON) {
client.println("<span style='color:green; font-weight:bold;'>FROID</span></font>");
}
else {
client.println("<span style='color:grey; font-weight:bold;'>CHAUD</span></font>");
}
client.print("<h2><a href='/?L=0'> ON </a> | <a href='/?L=2'> OFF </a></h2>");
//semnătura
client.println("<hr />");
client.print("<h4>CLIMATISATION HIVER V1.0</h4>");
client.println("<hr />");
// chiudo il div
client.println("</div>");
// chiudo pagina da togliere se uso ajax
client.println("</body></html>");
// pulisco la stringa per la successiva lettura
readString = "";
//fermo il client
client.stop();
} //if c == /n
} // if client available
} // while client connesso
} // FINE if client
} // fine loop
// The client will actually be disconnected
// when the function returns and 'client' object is detroyed