Page 1 sur 1
Wifi
Publié : 27 avr. 2020, 21:18
par VBill
Bonjour
Ayant plusieurs wifi à la maison (wifi + wifi étendu par un répéteur) j'aurais voulu que l'ESP teste les 2 et prenne le plus "puissant" mais là je n'y arrive pas
Si quelqu'un à une idée pour tester les rssi des wifi avant de se connecter ...
En attendant j'ai pondu ça : dites moi se que vous en pensez et des amélioration à apporter
Code : Tout sélectionner
#include <ESP8266WiFi.h>
//NodeMcu V3 D0/GPIO16 D1/GPIO5 D2/GPIO4 D3/GPIO0 D4/GPIO2 D5/GPIO14 D6/GPIO12 D7/GPIO13 D8/GPIO15 RX/GPIO3 TX/GPIO1 S2/GPIO9 S3/GPIO10
//ESP-01 GPIO0 GPIO2 RX/GPIO3 TX/GPIO1 Flash=GPIO0>Gnd CHPD>Vcc
//ESP-12E 4/GPIO16 5/GPIO14 6/GPIO12 7/GPIO13 9/GPIO11 10/GPIO7 11/GPIO9 12/GPIO10 13/GPIO8 14/GPIO6 16/GPIO15 17/GPIO2 18/GPIO0 19/GPIO4 20/GPIO5 21/GPIO3 22/GPIO1
//Wemos D1 mini Pin D0/GPIO16 D1/GPIO5 D2/GPIO4 D3/GPIO0 D4/GPIO2 D5/GPIO14 D6/GPIO12 D7/GPIO13 D8/GPIO15 RX/GPIO3 TX/GPIO1
//Variables
const char* ssid1 = ""; //SSID du Wifi 1
const char* password1 = "";//Mot de passe du Wifi 1
const char* ssid2 = ""; //SSID du Wifi 2
const char* password2 = "";//Mot de passe du Wifi 2
const char* NameLan = "";//Nom sur le réseau
String ssid = String(ssid1);//Ne pas toucher
int wificonect = 1;//Ne pas toucher
int tentative = 10;//Nombre de cycle de connection
void setup() {
//Liaison série
Serial.begin(115200);//Set Vitesse liaison serie
//Wifi
WiFi.mode(WIFI_STA);
WiFi.hostname(NameLan);
WiFi.begin(ssid1, password1);
Serial.println();
Serial.println("Connection " + ssid);
while (WiFi.status() != WL_CONNECTED) {
Serial.println("Connection au wifi " + ssid + " tentative " + wificonect + "/" + tentative);
delay(1000);
wificonect = wificonect + 1;
if (wificonect > tentative) {
break;
}
}
if (WiFi.status() != WL_CONNECTED) {
WiFi.begin(ssid2, password2);
ssid = String(ssid2);
Serial.println();
Serial.println("Connection " + ssid);
wificonect = 1;
while (WiFi.status() != WL_CONNECTED) {
Serial.println("Connection au wifi " + ssid + " tentative " + wificonect + "/" + tentative);
delay(1000);
wificonect = wificonect + 1;
if (wificonect > tentative) {
ESP.restart();
}
}
}
Serial.println("");
Serial.println("Connecté sur le réseau Wifi :" + ssid);
Serial.println("Adresse IP : " + WiFi.localIP());
Serial.println("Nom sur le réseau : " + String(NameLan));
}
void loop() {
if (WiFi.status() != WL_CONNECTED){
Serial.println("Déconnecté du Wifi " + ssid);
delay(1000);
ESP.restart();
}
//Programme
delay(5000);
}
Re: Wifi
Publié : 28 avr. 2020, 10:58
par VBill
Bonjour
Correction de quelques erreur et ajout de l'OTA
Attention il faut Python 2.7 pour que ça fonctionne (Perso Python 2.7.16 sous windows)
Le code :
Code : Tout sélectionner
#include <ESP8266WiFi.h>
#include <ArduinoOTA.h>
//NodeMcu V3 D0/GPIO16 D1/GPIO5 D2/GPIO4 D3/GPIO0 D4/GPIO2 D5/GPIO14 D6/GPIO12 D7/GPIO13 D8/GPIO15 RX/GPIO3 TX/GPIO1 S2/GPIO9 S3/GPIO10
//ESP-01 GPIO0 GPIO2 RX/GPIO3 TX/GPIO1 Flash=GPIO0>Gnd CHPD>Vcc
//ESP-12E 4/GPIO16 5/GPIO14 6/GPIO12 7/GPIO13 9/GPIO11 10/GPIO7 11/GPIO9 12/GPIO10 13/GPIO8 14/GPIO6 16/GPIO15 17/GPIO2 18/GPIO0 19/GPIO4 20/GPIO5 21/GPIO3 22/GPIO1
//Wemos D1 mini Pin D0/GPIO16 D1/GPIO5 D2/GPIO4 D3/GPIO0 D4/GPIO2 D5/GPIO14 D6/GPIO12 D7/GPIO13 D8/GPIO15 RX/GPIO3 TX/GPIO1
//Variables
const char* ssid1 = "";//SSID du Wifi 1 Obligatoire
const char* password1 = "";//Mot de passe du Wifi 1 Obligatoire
const char* ssid2 = "";//SSID du Wifi 2 Obligatoire
const char* password2 = "";//Mot de passe du Wifi 2 Obligatoire
const char* NameLan = "";//Nom sur le réseau Obligatoire
const char* OTApassword = "";//Mot de passe OTA Obligatoire
String ssid = String(ssid1);//Ne pas toucher
int wificonnect = 1;//Ne pas toucher
int tentative = 10;//Nombre de cycle de connexion
void setup() {
//Liaison série
Serial.begin(115200);//Set Vitesse liaison serie
//Wifi
WiFi.mode(WIFI_STA);
WiFi.hostname(NameLan);
WiFi.begin(ssid1, password1);
Serial.println();
Serial.println("Connexion " + ssid);
while (WiFi.status() != WL_CONNECTED) {
Serial.println("Connexion au wifi " + ssid + " tentative " + wificonnect + "/" + tentative);
delay(1000);
wificonnect = wificonnect + 1;
if (wificonnect > tentative) {
break;
}
}
if (WiFi.status() != WL_CONNECTED) {
WiFi.begin(ssid2, password2);
ssid = String(ssid2);
Serial.println();
Serial.println("Connexion " + ssid);
wificonnect = 1;
while (WiFi.status() != WL_CONNECTED) {
Serial.println("Connexion au wifi " + ssid + " tentative " + wificonnect + "/" + tentative);
delay(1000);
wificonnect = wificonnect + 1;
if (wificonnect > tentative) {
ESP.restart();
}
}
}
delay(1000);
Serial.println();
Serial.print("*Connecté sur le réseau Wifi : ");
Serial.println(ssid);
Serial.print("*Adresse IP : ");
Serial.println(WiFi.localIP());
Serial.print("*Nom sur le réseau : ");
Serial.println(NameLan);
//OTA
ArduinoOTA.setPort(8266);
ArduinoOTA.setHostname(NameLan);
ArduinoOTA.setPassword(OTApassword);
ArduinoOTA.onStart([]() {
Serial.println("Mise à jour OTA");
});
ArduinoOTA.onEnd([]() {
Serial.println("\nFin OTA");
});
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
Serial.printf("% : %u%%\r", (progress / (total / 100)));
});
ArduinoOTA.onError([](ota_error_t error) {
Serial.printf("Erreur[%u]: ", error);
if (error == OTA_AUTH_ERROR) Serial.println("Erreur d'authentification");
else if (error == OTA_BEGIN_ERROR) Serial.println("Erreur d'initialisation");
else if (error == OTA_CONNECT_ERROR) Serial.println("Erreur de connection");
else if (error == OTA_RECEIVE_ERROR) Serial.println("Erreur de transfert");
else if (error == OTA_END_ERROR) Serial.println("Echec");
});
ArduinoOTA.begin();
}
void loop() {
ArduinoOTA.handle();
if (WiFi.status() != WL_CONNECTED){
Serial.println("Déconnecté du Wifi " + ssid);
delay(1000);
ESP.restart();
}
//Programme
delay(5000);
}
Re: Wifi
Publié : 28 avr. 2020, 15:24
par VBill
Ajout d'une interface web simple uniquement des états pas de boutons
Code : Tout sélectionner
//Bibliothèque Wifi et OTA
#include <ESP8266WiFi.h>
#include <ArduinoOTA.h>
//Bibliothèque WebServer
#include <ESP8266WebServer.h>
//Bibliothèque client
#include <ESP8266HTTPClient.h>
//Définition du Web Serveur
ESP8266WebServer server ( 80 );
//Définition du client
HTTPClient domoticz_client;
//NodeMcu V3 D0/GPIO16 D1/GPIO5 D2/GPIO4 D3/GPIO0 D4/GPIO2 D5/GPIO14 D6/GPIO12 D7/GPIO13 D8/GPIO15 RX/GPIO3 TX/GPIO1 S2/GPIO9 S3/GPIO10
//ESP-01 GPIO0 GPIO2 RX/GPIO3 TX/GPIO1 Flash=GPIO0>Gnd CHPD>Vcc
//ESP-12E 4/GPIO16 5/GPIO14 6/GPIO12 7/GPIO13 9/GPIO11 10/GPIO7 11/GPIO9 12/GPIO10 13/GPIO8 14/GPIO6 16/GPIO15 17/GPIO2 18/GPIO0 19/GPIO4 20/GPIO5 21/GPIO3 22/GPIO1
//Wemos D1 mini Pin D0/GPIO16 D1/GPIO5 D2/GPIO4 D3/GPIO0 D4/GPIO2 D5/GPIO14 D6/GPIO12 D7/GPIO13 D8/GPIO15 RX/GPIO3 TX/GPIO1
//Variables Wifi et OTA
const char* ssid1 = "";//SSID du Wifi 1
const char* password1 = "";//Mot de passe du Wifi 1
const char* ssid2 = "";//SSID du Wifi 2
const char* password2 = "";//Mot de passe du Wifi 2
const char* NameLan = "";//Nom sur le réseau
const char* OTApassword = "";//Mot de passe OTA
String ssid = String(ssid1);//Ne pas toucher
String IP;//Ne pas toucher
int wificonnect = 1;//Ne pas toucher
int tentative = 10;//Nombre de cycle de connexion
//Variables programme
//Variable Web
String page;
void setup() {
//Liaison série
Serial.begin(115200);//Set Vitesse liaison série
//Wifi
WiFi.mode(WIFI_STA);
WiFi.hostname(NameLan);
WiFi.begin(ssid1, password1);
Serial.println();
Serial.println("Connexion " + ssid);
while (WiFi.status() != WL_CONNECTED) {
Serial.println("Connexion au wifi " + ssid + " tentative " + wificonnect + "/" + tentative);
delay(1000);
wificonnect = wificonnect + 1;
if (wificonnect > tentative) {
break;
}
}
if (WiFi.status() != WL_CONNECTED) {
WiFi.begin(ssid2, password2);
ssid = String(ssid2);
Serial.println();
Serial.println("Connexion " + ssid);
wificonnect = 1;
while (WiFi.status() != WL_CONNECTED) {
Serial.println("Connexion au wifi " + ssid + " tentative " + wificonnect + "/" + tentative);
delay(1000);
wificonnect = wificonnect + 1;
if (wificonnect > tentative) {
ESP.restart();
}
}
}
IP = String(WiFi.localIP()[0]) + "." + String(WiFi.localIP()[1]) + "." + String(WiFi.localIP()[2]) + "." + String(WiFi.localIP()[3]);
Serial.println();
Serial.print("*Connecté sur le réseau Wifi : ");
Serial.println(ssid);
Serial.print("*Adresse IP : ");
Serial.println(IP);
Serial.print("*Nom sur le réseau : ");
Serial.println(NameLan);
//OTA
ArduinoOTA.setPort(8266);
ArduinoOTA.setHostname(NameLan);
ArduinoOTA.setPassword(OTApassword);
ArduinoOTA.onStart([]() {
Serial.println("Mise à jour OTA");
});
ArduinoOTA.onEnd([]() {
Serial.println("\nFin OTA");
});
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
Serial.printf("% : %u%%\r", (progress / (total / 100)));
});
ArduinoOTA.onError([](ota_error_t error) {
Serial.printf("Erreur[%u]: ", error);
if (error == OTA_AUTH_ERROR) Serial.println("Erreur d'authentification");
else if (error == OTA_BEGIN_ERROR) Serial.println("Erreur d'initialisation");
else if (error == OTA_CONNECT_ERROR) Serial.println("Erreur de connection");
else if (error == OTA_RECEIVE_ERROR) Serial.println("Erreur de transfert");
else if (error == OTA_END_ERROR) Serial.println("Echec");
});
ArduinoOTA.begin();
//Serveur Web
server.on("/", HTTP_GET, []() {
server.sendHeader("Connection", "close");
server.send(200, "text/html", page);
});
server.begin();
//Définition des Pin
}
void loop() {
//OTA
ArduinoOTA.handle();
//Serveur Web
server.handleClient();
page = "<html lang=fr-FR><head><meta http-equiv='refresh' content='5' />";
page += "<title>Etat EJP et Chauffage</title>";
page += "<style> body { background-color: #fffff; font-family: Arial, Helvetica, Sans-Serif; Color: #000088; }</style>";
page += "</head><body><h1>Titre</h1>";//Titre général
page += "<h3>Wifi</h3>";//Titre 1
page += "<ul>";//
page += "<li>Connecte sur : ";//Texte 1
page += ssid;//Variable 1
page += "</li>";
page += "<li>IP : ";////Texte 2
page += IP;//Variable 2
page += "</li>";
page += "</ul>";
page += "<h3>Exemple</h3>";//Titre 2
page += "<ul>";
page += "<li>Exemple texte : ";//Texte 3
page += Votrevar1;//Variable 3
page += "</li>";
page += "<li>Exemple texte : ";//Texte 4
page += Votrevar2;//Variable 3
page += "</li>";
page += "</ul>";// et ainsi de suite ....
page += "</body></html>";
//Wifi
if (WiFi.status() != WL_CONNECTED){
Serial.println("Déconnecté du Wifi " + ssid);
delay(1000);
ESP.restart();
}
//Programme
delay (1000);
}
Re: Wifi
Publié : 30 avr. 2020, 18:14
par VBill
Un exemple avec couleur et tabulations
Code : Tout sélectionner
//Serveur Web
server.handleClient();
page = "<html lang=fr-FR><head><meta http-equiv='refresh' content='5' />";
page += "<title>Chaudiere</title>";
page += "<style> body { background-color: #DDDDDD; font-family: Arial, Helvetica, Sans-Serif; Color: #000088; }</style>";
page += "</head><body><h1 align=center style='text-align:center'><span style='font-family:\"Arial\",sans-serif;mso-fareast-font-family:\"Times New Roman\";color:#666060'>Chaudiere<o:p></o:p></span></h1>";
page += "<h2 align=center style='text-align:center'><span style='font-family:\"Arial\",sans-serif;mso-fareast-font-family:\"Times New Roman\";color:#F00060'>" + Date + "<o:p></o:p></span></h2>";
page += "<h2 align=center style='text-align:center'><span style='font-family:\"Arial\",sans-serif;mso-fareast-font-family:\"Times New Roman\";color:#F00060'>" + Temps + "<o:p></o:p></span></h2>";
page += "</span><span style='font-family:\"Arial\",sans-serif;mso-fareast-font-family:\"Times New Roman\";color:#0000FF'><o:p></o:p></span></p>";
page += "<h3><span style='font-family:\"Arial\",sans-serif;mso-fareast-font-family:\"Times New Roman\";color:#0000FF'>Wifi<o:p></o:p></span></h3>";
page += "<ul>";//
page += "<li>Connecte sur : ";
page += "<span style='font-family:\"Arial\",sans-serif;padding:0 0 0 60px;mso-fareast-font-family:\"Times New Roman\";color:#FF8800'>" + ssid + "<o:p></o:p></span>";
page += "</li>";
page += "<li>Adresse IP : ";
page += "<span style='font-family:\"Arial\",sans-serif;padding:0 0 0 77px;mso-fareast-font-family:\"Times New Roman\";color:#FF8800'>" + IP + "<o:p></o:p></span>";
page += "</li>";
page += "<li>Noms reseau : ";
page += "<span style='font-family:\"Arial\",sans-serif;padding:0 0 0 60px;mso-fareast-font-family:\"Times New Roman\";color:#FF8800'>" + Noms + "<o:p></o:p></span>";
page += "</li>";
page += "</ul>";
page += "<h3><span style='font-family:\"Arial\",sans-serif;mso-fareast-font-family:\"Times New Roman\";color:#0000FF'>Entree<o:p></o:p></span></h3>";
page += "<ul>";
page += "<li>Ventilateur : ";
page += "<span style='font-family:\"Arial\",sans-serif;padding:0 0 0 81px;mso-fareast-font-family:\"Times New Roman\";color:#00CC00'>" + String(!digitalRead(16)) + "<o:p></o:p></span>";
page += "</li>";
page += "<li>Allumage : ";
page += "<span style='font-family:\"Arial\",sans-serif;padding:0 0 0 90px;mso-fareast-font-family:\"Times New Roman\";color:#00CC00'>" + String(!digitalRead(5)) + "<o:p></o:p></span>";
page += "</li>";
page += "<li>Vis : ";
page += "<span style='font-family:\"Arial\",sans-serif;padding:0 0 0 135px;mso-fareast-font-family:\"Times New Roman\";color:#00CC00'>" + String(!digitalRead(4)) + "<o:p></o:p></span>";
page += "</li>";
page += "<li>Circulateur : ";
page += "<span style='font-family:\"Arial\",sans-serif;padding:0 0 0 80px;mso-fareast-font-family:\"Times New Roman\";color:#00CC00'>" + String(digitalRead(14)) + "<o:p></o:p></span>";
page += "</li>";
page += "</ul>";
page += "<h3><span style='font-family:\"Arial\",sans-serif;mso-fareast-font-family:\"Times New Roman\";color:#0000FF'>Capteurs DS18B20<o:p></o:p></span></h3>";
page += "<ul>";
page += "<li>Nombre de capteurs : ";
page += "<span style='font-family:\"Arial\",sans-serif;padding:0 0 0 14px;mso-fareast-font-family:\"Times New Roman\";color:#950020'>" + String(NBreCapteurs) + "<o:p></o:p></span>";
page += "</li>";
page += "</ul>";
page += "<h3><span style='font-family:\"Arial\",sans-serif;mso-fareast-font-family:\"Times New Roman\";color:#0000FF'>Temperature<o:p></o:p></span></h3>";
page += "<ul>";
page += "<li>Cuve chaudiere : ";
page += "<span style='font-family:\"Arial\",sans-serif;padding:0 0 0 48px;mso-fareast-font-family:\"Times New Roman\";color:#FF0000'>" + Tempcapteur[0] + "<o:p></o:p></span>";
page += "</li>";
page += "<li>Retour eau : ";
page += "<span style='font-family:\"Arial\",sans-serif;padding:0 0 0 81px;mso-fareast-font-family:\"Times New Roman\";color:#FF0000'>" + Tempcapteur[1] + "<o:p></o:p></span>";
page += "</li>";
page += "<li>Depart eau : ";
page += "<span style='font-family:\"Arial\",sans-serif;padding:0 0 0 81px;mso-fareast-font-family:\"Times New Roman\";color:#FF0000'>" + Tempcapteur[2] + "<o:p></o:p></span>";
page += "</li>";
page += "</ul>";
page += "</body></html>";
Re: Wifi
Publié : 30 avr. 2020, 18:21
par VBill
Et pour ceux que ça intéresse la partie NTP
Code : Tout sélectionner
//Bibliothèque NTP et Time
#include <TimeLib.h>
#include <NtpClientLib.h>
//Variables NTP
int Heure;
int Minute;
int Seconde;
int JourS;
int Jour;
int Mois;
int Annee;
String JourSem[] = {"JourSemaine", "Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi"};
String MoisL[] = {"Mois", "Janvier", "Fevrier", "Mars", "Avril", "Mai", "Juin", "Juillet", "Aout", "Septembre", "Octobre", "Novembre", "Decembre"};
String Temps;
String Date;
void setup() {
//NTP
NTP.begin("fr.pool.ntp.org", 1, true);//Serveur NTP, Fuseau, gestion heure été
NTP.setInterval(3600);//Fréquence de synchronisation en seconde
}
void loop() {
//NTP
Heure = int(hour());
Minute = int(minute());
Seconde = int(second());
JourS = int(weekday());
Jour = int(day());
Mois = int(month());
Annee = int(year());
if (Heure < 10 ) {
Temps = "0" + String(Heure) + ":";
} else {
Temps = String(Heure) + ":";
}
if (Minute < 10 ) {
Temps = Temps + "0" + String(Minute) + ":";
} else {
Temps = Temps + String(Minute) + ":";
}
if (Seconde < 10 ) {
Temps = Temps + "0" + String(Seconde);
} else {
Temps = Temps + String(Seconde);
}
Date = JourSem[JourS] + " " + String(Jour) + " " + MoisL[Mois] + " " + String(Annee);
Delay(1000);
}
Re: Wifi
Publié : 01 mai 2020, 11:22
par VBill
VBill a écrit : 30 avr. 2020, 18:14
Un exemple avec couleur et tabulations
Code : Tout sélectionner
//Serveur Web
server.handleClient();
page = "<html lang=fr-FR><head><meta http-equiv='refresh' content='5' />";
page += "<title>Chaudiere</title>";
page += "<style> body { background-color: #DDDDDD; font-family: Arial, Helvetica, Sans-Serif; Color: #000088; }</style>";
page += "</head><body><h1 align=center style='text-align:center'><span style='font-family:\"Arial\",sans-serif;mso-fareast-font-family:\"Times New Roman\";color:#666060'>Chaudiere<o:p></o:p></span></h1>";
page += "<h2 align=center style='text-align:center'><span style='font-family:\"Arial\",sans-serif;mso-fareast-font-family:\"Times New Roman\";color:#F00060'>" + Date + "<o:p></o:p></span></h2>";
page += "<h2 align=center style='text-align:center'><span style='font-family:\"Arial\",sans-serif;mso-fareast-font-family:\"Times New Roman\";color:#F00060'>" + Temps + "<o:p></o:p></span></h2>";
page += "</span><span style='font-family:\"Arial\",sans-serif;mso-fareast-font-family:\"Times New Roman\";color:#0000FF'><o:p></o:p></span></p>";
page += "<h3><span style='font-family:\"Arial\",sans-serif;mso-fareast-font-family:\"Times New Roman\";color:#0000FF'>Wifi<o:p></o:p></span></h3>";
page += "<ul>";//
page += "<li>Connecte sur : ";
page += "<span style='font-family:\"Arial\",sans-serif;padding:0 0 0 60px;mso-fareast-font-family:\"Times New Roman\";color:#FF8800'>" + ssid + "<o:p></o:p></span>";
page += "</li>";
page += "<li>Adresse IP : ";
page += "<span style='font-family:\"Arial\",sans-serif;padding:0 0 0 77px;mso-fareast-font-family:\"Times New Roman\";color:#FF8800'>" + IP + "<o:p></o:p></span>";
page += "</li>";
page += "<li>Noms reseau : ";
page += "<span style='font-family:\"Arial\",sans-serif;padding:0 0 0 60px;mso-fareast-font-family:\"Times New Roman\";color:#FF8800'>" + Noms + "<o:p></o:p></span>";
page += "</li>";
page += "</ul>";
page += "<h3><span style='font-family:\"Arial\",sans-serif;mso-fareast-font-family:\"Times New Roman\";color:#0000FF'>Entree<o:p></o:p></span></h3>";
page += "<ul>";
page += "<li>Ventilateur : ";
page += "<span style='font-family:\"Arial\",sans-serif;padding:0 0 0 81px;mso-fareast-font-family:\"Times New Roman\";color:#00CC00'>" + String(!digitalRead(16)) + "<o:p></o:p></span>";
page += "</li>";
page += "<li>Allumage : ";
page += "<span style='font-family:\"Arial\",sans-serif;padding:0 0 0 90px;mso-fareast-font-family:\"Times New Roman\";color:#00CC00'>" + String(!digitalRead(5)) + "<o:p></o:p></span>";
page += "</li>";
page += "<li>Vis : ";
page += "<span style='font-family:\"Arial\",sans-serif;padding:0 0 0 135px;mso-fareast-font-family:\"Times New Roman\";color:#00CC00'>" + String(!digitalRead(4)) + "<o:p></o:p></span>";
page += "</li>";
page += "<li>Circulateur : ";
page += "<span style='font-family:\"Arial\",sans-serif;padding:0 0 0 80px;mso-fareast-font-family:\"Times New Roman\";color:#00CC00'>" + String(digitalRead(14)) + "<o:p></o:p></span>";
page += "</li>";
page += "</ul>";
page += "<h3><span style='font-family:\"Arial\",sans-serif;mso-fareast-font-family:\"Times New Roman\";color:#0000FF'>Capteurs DS18B20<o:p></o:p></span></h3>";
page += "<ul>";
page += "<li>Nombre de capteurs : ";
page += "<span style='font-family:\"Arial\",sans-serif;padding:0 0 0 14px;mso-fareast-font-family:\"Times New Roman\";color:#950020'>" + String(NBreCapteurs) + "<o:p></o:p></span>";
page += "</li>";
page += "</ul>";
page += "<h3><span style='font-family:\"Arial\",sans-serif;mso-fareast-font-family:\"Times New Roman\";color:#0000FF'>Temperature<o:p></o:p></span></h3>";
page += "<ul>";
page += "<li>Cuve chaudiere : ";
page += "<span style='font-family:\"Arial\",sans-serif;padding:0 0 0 48px;mso-fareast-font-family:\"Times New Roman\";color:#FF0000'>" + Tempcapteur[0] + "<o:p></o:p></span>";
page += "</li>";
page += "<li>Retour eau : ";
page += "<span style='font-family:\"Arial\",sans-serif;padding:0 0 0 81px;mso-fareast-font-family:\"Times New Roman\";color:#FF0000'>" + Tempcapteur[1] + "<o:p></o:p></span>";
page += "</li>";
page += "<li>Depart eau : ";
page += "<span style='font-family:\"Arial\",sans-serif;padding:0 0 0 81px;mso-fareast-font-family:\"Times New Roman\";color:#FF0000'>" + Tempcapteur[2] + "<o:p></o:p></span>";
page += "</li>";
page += "</ul>";
page += "</body></html>";
La même page mais optimisé au max :
Code : Tout sélectionner
server.handleClient();
page = "<head><meta http-equiv='refresh' content='5'><style>body{background-color:#DDDDDD;font-family:Arial;Color:#000088}</style></head>";
page += "<h1 style=\"text-align:center\" align=\"center\"><span style=\"color:#666060;\">Chaudière</span></h1>";
page += "<h2 style=\"text-align:center\" align=\"center\"><span style=\"color:#f00060;\">" + Date + "</span></h2>";
page += "<h2 style=\"text-align:center\" align=\"center\"><span style=\"color:#f00060;\">" + Temps + "</span></h2>";
page += "<h3><span style=\"color:#0000ff\">Wifi</span></h3>";
page += "<ul><li>Connecté sur : <span style=\"padding:0 0 0 60px;color:#ff8800\">" + ssid + "</span></li>";
page += "<li>Adresse IP : <span style=\"padding:0 0 0 77px;color:#ff8800\">" + IP + "</span></li>";
page += "<li>Noms réseau : <span style=\"padding:0 0 0 60px;color:#ff8800\">" + Noms + "</span></li>";
page += "<li>Version : <span style=\"padding:0 0 0 102px;color:#ff8800\">" + Version + "</span></li></ul>";
page += "<h3><span style=\"color:#0000ff\">Entree</span></h3>";
page += "<ul><li>Ventilateur : <span style=\"padding:0 0 0 81px;color:#00CC00\">" + String(!digitalRead(16)) + "</span></li>";
page += "<li>Allumage : <span style=\"padding:0 0 0 90px;color:#00CC00\">" + String(!digitalRead(5)) + "</span></li>";
page += "<li>Vis : <span style=\"padding:0 0 0 135px;color:#00CC00\">" + String(!digitalRead(4)) + "</span></li>";
page += "<li>Circulateur : <span style=\"padding:0 0 0 80px;color:#00CC00\">" + String(digitalRead(14)) + "</span></li></ul>";
page += "<h3><span style=\"color:#0000ff\">Capteurs DS18B20</span></h3>";
page += "<ul><li>Nombre de capteurs : <span style=\"padding:0 0 0 13px;color:#950020\">" + String(NBreCapteurs) + "</span></li></ul>";
page += "<h3><span style=\"color:#0000ff\">Temperature</span></h3>";
page += "<ul><li>Cuve chaudière : <span style=\"padding:0 0 0 48px;color:#FF0000\">" + Tempcapteur[0] + "</span></li>";
page += "<li>Retour eau : <span style=\"padding:0 0 0 81px;color:#FF0000\">" + Tempcapteur[1] + "</span></li>";
page += "<li>Depart eau : <span style=\"padding:0 0 0 81px;color:#FF0000\">" + Tempcapteur[2] + "</span></li></ul>";
Re: Wifi
Publié : 01 mai 2020, 14:45
par Neutrino
Juste un message pour t'encourager !
Même si tu réinventes la roue (ESPeasy, Tasmota, Espurna...) c'est toujours sympa de comprendre ce qu'on fait

Continue à nous tenir au courant

Re: Wifi
Publié : 02 mai 2020, 17:07
par VBill
Neutrino a écrit : 01 mai 2020, 14:45
Juste un message pour t'encourager !
Même si tu réinventes la roue (ESPeasy, Tasmota, Espurna...) c'est toujours sympa de comprendre ce qu'on fait

Continue à nous tenir au courant
Tu as tout compris ...
Jusqu’à maintenant j’utilisai bêtement Tasmota et ESPeasy.
Le premier est "joli" mais on arrive rapidement aux limites, on ne peut pas tout faire avec et n'est pas forcement le plus stable (ajouter un DS18B20 sur un Sonoff 4CH R2 et vous perdrez régulièrement le capteur), le deuxième est beaucoup plus adaptable mais pas joli. Attention je ne crache pas dessus, j'ai beaucoup de Sonoff et d'ESP passés sur Tasmota et quelque ESP sous ESPeasy, ils fonts très bien leurs job. Non le but en ces heures de confinement est d'aller un peu plus loin et effectivement de comprendre comment ça marche (même si la programmation à mon niveau ressemble plus à du lego), le but c'est d'apprendre ...
J'ai une boite Elegoo avec un quarantaine de capteurs divers et variés, là je joue avec un "codeur" EC11 ... j'ai déjà fais mu-muse avec le capteur de luminosité (Ana) le DTH11 et le transistor à effet hall , reste le capteur de pluie ça sent bon la station météo ....