Principe de fonctionnement
Selon le type de signal qui est envoyé sur le fil pilote d’un radiateur, il est possible d’accéder très simplement à 4 modes de fonctionnement.
Ces quatre modes de fonctionnements sont associés au hachage du signal 50Hz de la phase.

Ce hachage sera opéré selon le schéma ci dessous à l’aide de triacs commandés par l’ESP et de diodes filtrant l’alternance positive ou négative.
Avertissement
Cette réalisation nécessite de manipuler du courant 220V. Soyez prudent et prenez toutes les dispositions nécessaires pour travailler en sécurité !
Matériel nécessaire
- Un ESP 8266 qui sera programmé via l’IDE arduino
- 2 diodes 1N4007
- 2 triacs opto-isolés MOC3041-M
- 2 résistances de 470 Ohms
- Une alimentation 3.3V pour alimenter l’ESP
- Une sonde de température et humidité DHT11 (optionnel)
Schéma du circuit électrique
Le circuit de hachage du signal est assez simple

- IN1 sera connecté à la broche GPIO14 de l’ESP
- IN2 sera connecté à la broche GPIO12 de l’ESP
Selon l’état des broches 14 et 12 il sera donc possible de commander le radiateur comme ceci :
GPIO14 | GPIO12 | Consigne |
0 | 0 | Confort |
1 | 0 | Eteint |
0 | 1 | Hors gel (7°C) |
1 | 1 | Mode nuit (-3.5°C) |
Code arduino
#include <DHT.h>
#define DHTPIN 13
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
#include <ESP8266WiFi.h>
const char* ssid = "";//type your ssid
const char* password = "";//type your password
int ledPin1 = 16;
int ledPin2 = 14;
WiFiServer server(80);//Service Port
void setup() {
Serial.begin(115200);
delay(10);
pinMode(ledPin1, OUTPUT);
digitalWrite(ledPin1, HIGH);
pinMode(ledPin2, OUTPUT);
digitalWrite(ledPin2, LOW);
// Connect to WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
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.print("Use this URL to connect: ");
Serial.print("http://");
Serial.print(WiFi.localIP());
Serial.println("/");
dht.begin();
}
void loop() {
// Check if a client has connected
WiFiClient client = server.available();
if (!client) {
return;
}
// Wait until the client sends some data
Serial.println("new client");
while(!client.available()){
delay(1);
}
// Read the first line of the request
String request = client.readStringUntil('\r');
Serial.println(request);
client.flush();
// Match the request
int value = 0; //OFF
//OFF
if (request.indexOf("/STATUS=0") != -1) {
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, LOW);
value = 0;
}
//HORS GEL
if (request.indexOf("/STATUS=1") != -1){
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, HIGH);
value = 1;
}
//ECO
if (request.indexOf("/STATUS=2") != -1){
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, HIGH);
value = 2;
}
//CONFORT
if (request.indexOf("/STATUS=3") != -1){
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, LOW);
value = 3;
}
//Set ledPin according to the request
//digitalWrite(ledPin, value);
// Return the response
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println(""); // do not forget this one
client.println("<!DOCTYPE HTML>");
client.println("<html>");
//client.print("Radiateur actuellement en mode : ");
client.print("<p style=\"font-size: 72px;\">Temperature : ");
client.print(dht.readTemperature());
client.println("°C");
//client.println("<br>");
if(value == 0) {
//client.print("Eteint");
client.println("<br><br>");
client.println("<button onclick=\"window.location.href='/STATUS=0'\" style=\"height: 200px; width: 800px; background-color:#4CAF50; color: white;font-size: 72px;\">Eteint</button><br>");
client.println("<br>");
client.println("<button onclick=\"window.location.href='/STATUS=1'\" style=\"height: 200px; width: 800px; background-color:#008CBA; color: white;font-size: 72px;\">Hors Gel</button><br>");
client.println("<br>");
client.println("<button onclick=\"window.location.href='/STATUS=2'\" style=\"height: 200px; width: 800px; background-color:#008CBA; color: white;font-size: 72px;\">Economie</button><br>");
client.println("<br>");
client.println("<button onclick=\"window.location.href='/STATUS=3'\" style=\"height: 200px; width: 800px; background-color:#008CBA; color: white;font-size: 72px;\">Confort</button><br>");
client.println("</html>");
}
if (value == 1) {
//client.print("Hors Gel");
client.println("<br><br>");
client.println("<button onclick=\"window.location.href='/STATUS=0'\" style=\"height: 200px; width: 800px; background-color:#008CBA; color: white;font-size: 72px;\">Eteint</button><br>");
client.println("<br>");
client.println("<button onclick=\"window.location.href='/STATUS=1'\" style=\"height: 200px; width: 800px; background-color:#4CAF50; color: white;font-size: 72px;\">Hors Gel</button><br>");
client.println("<br>");
client.println("<button onclick=\"window.location.href='/STATUS=2'\" style=\"height: 200px; width: 800px; background-color:#008CBA; color: white;font-size: 72px;\">Economie</button><br>");
client.println("<br>");
client.println("<button onclick=\"window.location.href='/STATUS=3'\" style=\"height: 200px; width: 800px; background-color:#008CBA; color: white;font-size: 72px;\">Confort</button><br>");
client.println("</html>");
}
if (value == 2) {
//client.print("Economique");
client.println("<br><br>");
client.println("<button onclick=\"window.location.href='/STATUS=0'\" style=\"height: 200px; width: 800px; background-color:#008CBA; color: white;font-size: 72px;\">Eteint</button><br>");
client.println("<br>");
client.println("<button onclick=\"window.location.href='/STATUS=1'\" style=\"height: 200px; width: 800px; background-color:#008CBA; color: white;font-size: 72px;\">Hors Gel</button><br>");
client.println("<br>");
client.println("<button onclick=\"window.location.href='/STATUS=2'\" style=\"height: 200px; width: 800px; background-color:#4CAF50; color: white;font-size: 72px;\">Economie</button><br>");
client.println("<br>");
client.println("<button onclick=\"window.location.href='/STATUS=3'\" style=\"height: 200px; width: 800px; background-color:#008CBA; color: white;font-size: 72px;\">Confort</button><br>");
client.println("</html>");
}
if (value == 3) {
//client.print("Confort");
client.println("<br><br>");
client.println("<button onclick=\"window.location.href='/STATUS=0'\" style=\"height: 200px; width: 800px; background-color:#008CBA; color: white;font-size: 72px;\">Eteint</button><br>");
client.println("<br>");
client.println("<button onclick=\"window.location.href='/STATUS=1'\" style=\"height: 200px; width: 800px; background-color:#008CBA; color: white;font-size: 72px;\">Hors Gel</button><br>");
client.println("<br>");
client.println("<button onclick=\"window.location.href='/STATUS=2'\" style=\"height: 200px; width: 800px; background-color:#008CBA; color: white;font-size: 72px;\">Economie</button><br>");
client.println("<br>");
client.println("<button onclick=\"window.location.href='/STATUS=3'\" style=\"height: 200px; width: 800px; background-color:#4CAF50; color: white;font-size: 72px;\">Confort</button><br>");
client.println("</html>");
}
//client.println("<br><br>");
//client.println("<a href=\"/STATUS=0\">Eteindre</a><br>");
//client.println("Click <a href=\"/STATUS=1\">here</a> Hors Gel<br>");
//client.println("Click <a href=\"/STATUS=2\">here</a> Economie<br>");
//client.println("Click <a href=\"/STATUS=3\">here</a> Confort<br>");
//client.println("</html>");
delay(1);
Serial.println("Client disconnected");
Serial.println("");
}
La librairie DHT.h est disponible ici
En ouvrant le moniteur série, vous accèderez à l’IP attribuée par le serveur DHCP à l’ESP
Vous pouvez alors vous connecter au mini serveur web de l’ESP en saisissant l’IP dans votre navigateur.
Pour accéder à l’ESP de partout, il faut configurer votre box FAI et définir un DNS dynamique et créer des règles de routages NAT sur le port 80.