Effectivement, je n’avais pas vu le bouton de changement page (quel imbécile je fais !)
je le saurai la prochaine fois.
là, j’ai réuni mes 2 programme et cela fonctionne, cela n’est pas “très beau” de mélanger deux types de programme différents (je vous l’accorde) mais mon application doit être opérationnelle le plus rapidement possible ( il s’agit de la commande d’une clim infrarouge ) et en ce moment il commence à faire froid.
Je vous remercie encore de votre patience et de votre aide que vous m’avez donné ! ! !
Je donne le programme complet de ma commande de clim AIRTON si cela peut servir à quelqu’un.
encore merci !
Indeed, I hadn’t seen the page change button (what an idiot I am!)
I’ll know next time.
there, I combined my 2 programs and it works, it is not “very nice” to mix two different types of program (I grant you that) but my application must be operational as quickly as possible (it is is the control of an infrared air conditioning) and at the moment it is starting to get cold.
Thank you again for your patience and help you gave me! ! !
I am giving the complete program for my AIRTON air conditioning control if it can be useful to anyone.
thank you again!
// Blynck identifiant : philippe_trehard@orange.fr pass : Philippe001+
// carte NodeMCU 1.0 (ESP 12E)
//***************************** ESP 8266 wiffi + BLYNK ***********
#define BLYNK_TEMPLATE_ID "Tn"
#define BLYNK_TEMPLATE_NAME "lea"
#define BLYNK_AUTH_TOKEN "poAE-U"
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
char ssid[] = "Live"; //Enter your WIFI Name
char pass[] = "6146ADF"; //Enter your WIFI Password
//***************************** pour le BME ***************************************
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#define SEALEVELPRESSURE_HPA (1013.25)
Adafruit_BME280 bme; // I2C *** SDA sur D2 et SCL sur D1 ***
//*************************** pour envoie IR ***************************************
#include <Arduino.h>
#include <IRremoteESP8266.h>
#include <IRsend.h>
//*************************** bibli pour memoire flash ******************************
#include <avr/pgmspace.h> //on n'oublie pas d'intégrer la bibliothèque de gestion de mémoire FLASH
const uint16_t kIrLed = D3; // *** LED emetrice sur D3 ***
IRsend irsend(kIrLed); // Set the GPIO to be used to sending the message.
//Creation objet WIFI UDP puis du client NTP
WiFiUDP ntpUDP;
// Avec intervalle de mise à jour de 60 sec ...
// ... et offset en secondes cad decalage horaire, pour GMT+1 mettre 3600, GMT +8 mettre 28800, etc.
// ... et le serveur NTP utilise est : europe.pool.ntp.org
NTPClient timeClient(ntpUDP, "europe.pool.ntp.org", 3600, 60000);
// ************************** boutons / Variables ***********************************
//int on_16c_chauf = 8;
int inter_confort;
byte consigne_t;
byte consigne_clim=16;
int clim_marche;
byte mem_clim_marche=0 ;
byte mem1_clim_marche=1 ;
float delta_t=0;
float t;
int reduction_t = 3; // **=> Nombre de degres en moins par rapport à t° de consigne en mode éco
float mem_t_clim_marche; // prise de la temperature lorsque clim passe a 1
float mem_t_clim_arret; // prise de la temperature lorsque clim passe a 0
byte x=0; // mesure du temps
byte y=0;
byte z=0;
byte a=0;
byte b=0;
byte confort=0; //variable confort
int h;
int mn;
int hd;
int mnd;
int hf;
int mnf;
int plage_confort=1; // 1 en réduit et 0 en confort
// Process start time
BLYNK_WRITE(V4) {
TimeInputParam t(param);
if (t.hasStartTime())
{
Serial.println(String("Start: ") +
t.getStartHour() + ":" +
t.getStartMinute() + ":" +
t.getStartSecond());
hd=t.getStartHour();
mnd=t.getStartMinute();
Serial.print("debut");
Serial.print(hd);
Serial.print(" : ");
Serial.println(mnd);
}
if (t.hasStopTime())
{
Serial.println(String("Stop: ") +
t.getStopHour() + ":" +
t.getStopMinute() + ":" +
t.getStopSecond());
hf=t.getStopHour();
mnf=t.getStopMinute();
Serial.print("fin");
Serial.print(hf);
Serial.print(" : ");
Serial.println(mnf);
}
Serial.println();
int startAt = mnd * 60 + hd * 3600; // depart heure : minutes
int stopAt = mnf * 60 + hf * 3600; // arret heure : minutes
char tz[] = "Europe/Paris";
Blynk.virtualWrite(V4, startAt, stopAt, tz );
}
WidgetLED led1(1); //virtual led
WidgetLED led2(7); //virtual led
// ************************** codes clim en memoire flash *************************
const uint16_t a16[227] PROGMEM = {3091, 1590, 498, 1089, 497, 1088, 497, 317, 501, 318, 501, 318, 501, 1089, 497, 318, 501, 318, 501, 1089, 496, 1090, 495, 318, 500, 1090, 495, 320, 499, 320, 497, 1092, 492, 1093, 490, 325, 494, 1094, 492, 1094, 490, 324, 495, 323, 492, 1097, 489, 326, 494, 324, 493, 1096, 493, 323, 495, 324, 495, 325, 494, 325, 493, 326, 494, 325, 492, 326, 492, 327, 494, 325, 494, 325, 492, 326, 494, 325, 492, 326, 492, 326, 492, 327, 492, 327, 493, 325, 492, 1097, 491, 327, 493, 326, 491, 1097, 491, 326, 492, 501, 490, 1098, 491, 326, 492, 326, 492, 328, 491, 328, 492, 327, 492, 327, 491, 328, 490, 1098, 487, 1098, 488, 1098, 489, 1097, 489, 328, 490, 328, 490, 328, 491, 328, 491, 328, 489, 329, 490, 329, 489, 329, 490, 329, 490, 329, 490, 329, 490, 329, 490, 329, 490, 328, 489, 330, 490, 328, 490, 329, 491, 328, 489, 329, 487, 331, 489, 329, 490, 329, 490, 329, 489, 330, 489, 330, 490, 329, 489, 329, 490, 329, 489, 330, 489, 330, 489, 330, 488, 331, 487, 332, 490, 329, 490, 329, 490, 330, 487, 332, 488, 331, 487, 332, 488, 331, 489, 330, 488, 330, 489, 330, 486, 332, 487, 1098, 485, 331, 487, 331, 487, 1098, 487, 331, 486, 333, 488, 1097, 485, 333, 488};
const uint16_t a17[227] PROGMEM = {3091, 1590, 498, 1089, 497, 1088, 497, 317, 501, 318, 501, 318, 501, 1089, 497, 318, 501, 318, 501, 1089, 496, 1090, 495, 318, 500, 1090, 495, 320, 499, 320, 497, 1092, 492, 1093, 490, 325, 494, 1094, 492, 1094, 490, 324, 495, 323, 492, 1097, 489, 326, 494, 324, 493, 1096, 493, 323, 495, 324, 495, 325, 494, 325, 493, 326, 494, 325, 492, 326, 492, 327, 494, 325, 494, 325, 492, 326, 494, 325, 492, 326, 492, 326, 492, 327, 492, 327, 493, 325, 492, 1097, 491, 327, 493, 326, 491, 1097, 491, 326, 492, 501, 490, 1098, 491, 326, 492, 326, 492, 328, 491, 328, 492, 327, 492, 327, 491, 328, 490, 328, 487, 1098, 488, 1098, 489, 1097, 489, 328, 490, 328, 490, 328, 491, 328, 491, 328, 489, 329, 490, 329, 489, 329, 490, 329, 490, 329, 490, 329, 490, 329, 490, 329, 490, 328, 489, 330, 490, 328, 490, 329, 491, 328, 489, 329, 487, 331, 489, 329, 490, 329, 490, 329, 489, 330, 489, 330, 490, 329, 489, 329, 490, 329, 489, 330, 489, 330, 489, 330, 488, 331, 487, 332, 490, 329, 490, 329, 490, 330, 487, 332, 488, 331, 487, 332, 488, 331, 489, 330, 488, 330, 489, 330, 486, 332, 487, 331, 485, 331, 487, 331, 487, 1098, 487, 331, 486, 333, 488, 1097, 485, 333, 488};
const uint16_t a18[227] PROGMEM = {3091, 1590, 498, 1089, 497, 1088, 497, 317, 501, 318, 501, 318, 501, 1089, 497, 318, 501, 318, 501, 1089, 496, 1090, 495, 318, 500, 1090, 495, 320, 499, 320, 497, 1092, 492, 1093, 490, 325, 494, 1094, 492, 1094, 490, 324, 495, 323, 492, 1097, 489, 326, 494, 324, 493, 1096, 493, 323, 495, 324, 495, 325, 494, 325, 493, 326, 494, 325, 492, 326, 492, 327, 494, 325, 494, 325, 492, 326, 494, 325, 492, 326, 492, 326, 492, 327, 492, 327, 493, 325, 492, 1097, 491, 327, 493, 326, 491, 1097, 491, 326, 492, 501, 490, 1098, 491, 326, 492, 326, 492, 328, 491, 328, 492, 327, 492, 327, 491, 328, 490, 1098, 487, 328, 488, 1098, 489, 1097, 489, 328, 490, 328, 490, 328, 491, 328, 491, 328, 489, 329, 490, 329, 489, 329, 490, 329, 490, 329, 490, 329, 490, 329, 490, 329, 490, 328, 489, 330, 490, 328, 490, 329, 491, 328, 489, 329, 487, 331, 489, 329, 490, 329, 490, 329, 489, 330, 489, 330, 490, 329, 489, 329, 490, 329, 489, 330, 489, 330, 489, 330, 488, 331, 487, 332, 490, 329, 490, 329, 490, 330, 487, 332, 488, 331, 487, 332, 488, 331, 489, 330, 488, 330, 489, 330, 486, 332, 487, 1098, 485, 1098, 487, 1098, 487, 331, 487, 331, 486, 333, 488, 1097, 485, 333, 488};
const uint16_t a19[227] PROGMEM = {3091, 1590, 498, 1089, 497, 1088, 497, 317, 501, 318, 501, 318, 501, 1089, 497, 318, 501, 318, 501, 1089, 496, 1090, 495, 318, 500, 1090, 495, 320, 499, 320, 497, 1092, 492, 1093, 490, 325, 494, 1094, 492, 1094, 490, 324, 495, 323, 492, 1097, 489, 326, 494, 324, 493, 1096, 493, 323, 495, 324, 495, 325, 494, 325, 493, 326, 494, 325, 492, 326, 492, 327, 494, 325, 494, 325, 492, 326, 494, 325, 492, 326, 492, 326, 492, 327, 492, 327, 493, 325, 492, 1097, 491, 327, 493, 326, 491, 1097, 491, 326, 492, 501, 490, 1098, 491, 326, 492, 326, 492, 328, 491, 328, 492, 327, 492, 327, 491, 328, 490, 328, 487, 328, 488, 1098, 489, 1097, 489, 328, 490, 328, 490, 328, 491, 328, 491, 328, 489, 329, 490, 329, 489, 329, 490, 329, 490, 329, 490, 329, 490, 329, 490, 329, 490, 328, 489, 330, 490, 328, 490, 329, 491, 328, 489, 329, 487, 331, 489, 329, 490, 329, 490, 329, 489, 330, 489, 330, 490, 329, 489, 329, 490, 329, 489, 330, 489, 330, 489, 330, 488, 331, 487, 332, 490, 329, 490, 329, 490, 330, 487, 332, 488, 331, 487, 332, 488, 331, 489, 330, 488, 330, 489, 330, 486, 332, 487, 331, 485, 1098, 487, 1098, 487, 331, 487, 331, 486, 333, 488, 1097, 485, 333, 488};
const uint16_t a20[227] PROGMEM = {3091, 1590, 498, 1089, 497, 1088, 497, 317, 501, 318, 501, 318, 501, 1089, 497, 318, 501, 318, 501, 1089, 496, 1090, 495, 318, 500, 1090, 495, 320, 499, 320, 497, 1092, 492, 1093, 490, 325, 494, 1094, 492, 1094, 490, 324, 495, 323, 492, 1097, 489, 326, 494, 324, 493, 1096, 493, 323, 495, 324, 495, 325, 494, 325, 493, 326, 494, 325, 492, 326, 492, 327, 494, 325, 494, 325, 492, 326, 494, 325, 492, 326, 492, 326, 492, 327, 492, 327, 493, 325, 492, 1097, 491, 327, 493, 326, 491, 1097, 491, 326, 492, 501, 490, 1098, 491, 326, 492, 326, 492, 328, 491, 328, 492, 327, 492, 327, 491, 328, 490, 1098, 487, 1098, 488, 328, 489, 1097, 489, 328, 490, 328, 490, 328, 491, 328, 491, 328, 489, 329, 490, 329, 489, 329, 490, 329, 490, 329, 490, 329, 490, 329, 490, 329, 490, 328, 489, 330, 490, 328, 490, 329, 491, 328, 489, 329, 487, 331, 489, 329, 490, 329, 490, 329, 489, 330, 489, 330, 490, 329, 489, 329, 490, 329, 489, 330, 489, 330, 489, 330, 488, 331, 487, 332, 490, 329, 490, 329, 490, 330, 487, 332, 488, 331, 487, 332, 488, 331, 489, 330, 488, 330, 489, 330, 486, 332, 487, 1098, 485, 331, 487, 1098, 487, 331, 487, 331, 486, 333, 488, 1097, 485, 333, 488};
const uint16_t a21[227] PROGMEM = {3091, 1590, 498, 1089, 497, 1088, 497, 317, 501, 318, 501, 318, 501, 1089, 497, 318, 501, 318, 501, 1089, 496, 1090, 495, 318, 500, 1090, 495, 320, 499, 320, 497, 1092, 492, 1093, 490, 325, 494, 1094, 492, 1094, 490, 324, 495, 323, 492, 1097, 489, 326, 494, 324, 493, 1096, 493, 323, 495, 324, 495, 325, 494, 325, 493, 326, 494, 325, 492, 326, 492, 327, 494, 325, 494, 325, 492, 326, 494, 325, 492, 326, 492, 326, 492, 327, 492, 327, 493, 325, 492, 1097, 491, 327, 493, 326, 491, 1097, 491, 326, 492, 501, 490, 1098, 491, 326, 492, 326, 492, 328, 491, 328, 492, 327, 492, 327, 491, 328, 490, 328, 487, 1098, 488, 328, 489, 1097, 489, 328, 490, 328, 490, 328, 491, 328, 491, 328, 489, 329, 490, 329, 489, 329, 490, 329, 490, 329, 490, 329, 490, 329, 490, 329, 490, 328, 489, 330, 490, 328, 490, 329, 491, 328, 489, 329, 487, 331, 489, 329, 490, 329, 490, 329, 489, 330, 489, 330, 490, 329, 489, 329, 490, 329, 489, 330, 489, 330, 489, 330, 488, 331, 487, 332, 490, 329, 490, 329, 490, 330, 487, 332, 488, 331, 487, 332, 488, 331, 489, 330, 488, 330, 489, 330, 486, 332, 487, 331, 485, 331, 487, 1098, 487, 331, 487, 331, 486, 333, 488, 1097, 485, 333, 488};
const uint16_t aoff[227] PROGMEM = {3091, 1590, 498, 1089, 497, 1088, 497, 317, 501, 318, 501, 318, 501, 1089, 497, 318, 501, 318, 501, 1089, 496, 1090, 495, 318, 500, 1090, 495, 320, 499, 320, 497, 1092, 492, 1093, 490, 325, 494, 1094, 492, 1094, 490, 324, 495, 323, 492, 1097, 489, 326, 494, 324, 493, 1096, 493, 323, 495, 324, 495, 325, 494, 325, 493, 326, 494, 325, 492, 326, 492, 327, 494, 325, 494, 325, 492, 326, 494, 325, 492, 326, 492, 326, 492, 327, 492, 327, 493, 325, 492, 327, 491, 327, 493, 326, 491, 1097, 491, 326, 492, 501, 490, 1098, 491, 326, 492, 326, 492, 328, 491, 328, 492, 327, 492, 327, 491, 328, 490, 1098, 487, 1098, 488, 1098, 489, 1097, 489, 328, 490, 328, 490, 328, 491, 328, 491, 328, 489, 329, 490, 329, 489, 329, 490, 329, 490, 329, 490, 329, 490, 329, 490, 329, 490, 328, 489, 330, 490, 328, 490, 329, 491, 328, 489, 329, 487, 331, 489, 329, 490, 329, 490, 329, 489, 330, 489, 330, 490, 329, 489, 329, 490, 329, 489, 330, 489, 330, 489, 330, 488, 331, 487, 332, 490, 329, 490, 329, 490, 330, 487, 332, 488, 331, 487, 332, 488, 331, 489, 330, 488, 330, 489, 330, 486, 332, 487, 1098, 485, 331, 487, 1098, 487, 331, 487, 331, 486, 333, 488, 1097, 485, 333, 488};
// ***************************************** SETUP ************************************************
void setup() {
Serial.begin(115200);
bool status;
status = bme.begin(0x76);
// pinMode(on_16c_chauf, INPUT); // BP en entrèe
irsend.begin();
#if ESP8266
Serial.begin(115200, SERIAL_8N1, SERIAL_TX_ONLY);
#else // ESP8266
Serial.begin(115200, SERIAL_8N1);
#endif // ESP8266
// Demarrage client NTP
timeClient.begin();
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
irsend.sendRaw(aoff, 227, 38); // stop clim
mem_clim_marche=0 ;
}
// ******************************* variable retour android ***********************************************
BLYNK_WRITE(V3) //1 si confort 0 reduit
{ inter_confort = param.asInt(); }
// BLYNK_WRITE(V4) //plage horaire 1 si confort 0 reduit
// { plage_confort = param.asInt(); }
BLYNK_WRITE(V2) //consigne temperature
{ consigne_t = param.asInt(); }
BLYNK_WRITE(V0) //climatiseur marche(1)/arret(0)
{ clim_marche = param.asInt(); }
//***************************************** S/P valeurs BME *************************************************
void donnees_capteur() {
// Serial.print("Temperature = ");
t=(bme.readTemperature());
t=t-3; // ajustement capteur sur une valeur vraie
Serial.print(t);
Serial.println(" *C");
// Serial.print("Pressure = ");
// float p=(bme.readPressure()) / 100.0F;
// Serial.print(p);
// Serial.println(" hPa");
// Serial.print("Humidity = ");
float h=(bme.readHumidity());
// Serial.print(h);
// Serial.println(" %");
Blynk.virtualWrite(V5, h); //V5 is for Humidity
Blynk.virtualWrite(V6, t); //V6 is for Temperature
// Serial.println();
delay(5000);
}
//***************************************** marche clim *************************************************
void marche_clim() {
switch ( consigne_t ){
case 16:
irsend.sendRaw(a16, 227, 38);
Serial.println("clim 16");
mem_clim_marche=1;
break;
case 17:
irsend.sendRaw(a17, 227, 38);
Serial.println("clim 17");
mem_clim_marche=1;
break;
case 18:
irsend.sendRaw(a18, 227, 38);
Serial.println("clim 18");
mem_clim_marche=1;
break;
case 19:
irsend.sendRaw(a19, 227, 38);
Serial.println("clim 19");
mem_clim_marche=1;
break;
case 20:
irsend.sendRaw(a20, 227, 38);
Serial.println("clim 20");
mem_clim_marche=1;
break;
case 21:
irsend.sendRaw(a21, 227, 38);
Serial.println("clim 21");
mem_clim_marche=1;
break;
case 22:
irsend.sendRaw(a21, 227, 38);
Serial.println("clim 21");
mem_clim_marche=1;
break;
}
}
//******************************************** Programme principal **************************************
void loop() {
Blynk.run(); // Initialise Blynk
Blynk.syncVirtual(V0, V2, V3, V4);
// epoch = timeClient.getEpochTime(); // Heure Unix
// nujour = timeClient.getDay(); // jour de la semaine
// heure = timeClient.getFormattedTime(); // heure
// Demarrage client NTP
timeClient.update();
int h = timeClient.getHours();
int mn = timeClient.getMinutes();
/* switch (nujour) { // on determine le jour
case 0:
jour = "dimanche";
break;
case 1:
jour = "lundi";
break;
case 2:
jour = "mardi";
break;
case 3:
jour = "mercredi";
break;
case 4:
jour = "jeudi";
break;
case 5:
jour = "vendredi";
break;
case 6:
jour = "samedi";
break;
}
*/
Serial.print(" heure : ");
Serial.print(h);
Serial.print(" : ");
Serial.println(mn);
if (hd==h and mnd==mn){plage_confort=0;}
if (hf==h and mnf==mn){plage_confort=1;}
Serial.print("v3 inter confort = ");Serial.println(inter_confort);
Serial.print("v4 plage horaire = ");Serial.println(plage_confort);
Serial.print("v2 iconsig temp = ");Serial.println(consigne_t);
Serial.print("v0 clim marche = ");Serial.println(clim_marche);
delay(5000);
if (mem_clim_marche==1){led1.on();} else {led1.off();} //V1 led memoire clim_marche
if (plage_confort==0 or inter_confort==0 ){led2.on();confort=1;} else {led2.off();confort=0;} //V7 led zone confort
// if (plage_confort==0 or inter_confort==0 ){confort=2;} else {confort=3;} //V7 led zone confort
delay(5000); // attente 5 secondes
x=x+1;
Blynk.run(); // Initialise Blynk
Blynk.syncVirtual(V0, V2, V3, V4); // synchronisation des données en cas de coupure wiffi v0>marche/arret v2>consigne v3>bp timer on/off v4>timer
donnees_capteur();
// ******************************** si BP marche clim est à 0 --- arret clim *******************************************************
if ( clim_marche != mem1_clim_marche ) { mem1_clim_marche = clim_marche ;
if ( clim_marche==0 ) {
irsend.sendRaw(aoff, 227, 38); mem_clim_marche=0; Serial.println("clim arret");
delay(5000); // attente 5 secondes
irsend.sendRaw(aoff, 227, 38); mem_clim_marche=0; Serial.println("clim arret"); // arret clim ( envoie 227octet sur 38 khz )
}
}
if ( clim_marche==0 && mem_clim_marche==1 ) {irsend.sendRaw(aoff, 227, 38);Serial.println("clim arret "); mem_clim_marche=0;} // arret clim
// ******************************** si BP marche clim est à 1 --- marche auto clim *******************************************************
if ( clim_marche==1 ) {
if ( confort==0) {consigne_clim = consigne_t - reduction_t ;}
if ( confort==1) {consigne_clim = consigne_t ;}
delta_t = consigne_clim - t; // consigne 15 - temps 10 = +5 => si positif trop froid (chauffer) // si negatif c'est trop chaud (arret)
Serial.print("t = ");Serial.println(t);
Serial.print("mem_clim_marche = ");Serial.println(mem_clim_marche);
Serial.print("consigne_clim = ");Serial.println(consigne_clim);
Serial.print("consigne_t = ");Serial.println(consigne_t);
Serial.print("confort = ");Serial.println(confort);
Serial.print("delta_t = ");Serial.println(delta_t);;
Serial.print("mem_t_clim_marche = ");Serial.println(mem_t_clim_marche);
Serial.print("mem_t_clim_arret = ");Serial.println(mem_t_clim_arret);
Serial.print("x = ");Serial.println(x);
Serial.println();
if ( delta_t < -1 && mem_clim_marche==1 ){mem_clim_marche=0; irsend.sendRaw(aoff, 227, 38);Serial.println("clim arret ") ;mem_t_clim_arret=t ;x=0;} // arret clim
if ( delta_t >= 0 && mem_clim_marche==0) {mem_clim_marche=1; marche_clim() ;Serial.println("clim marche ");mem_t_clim_marche=t ;x=0;} //marche clim
if ( x>60 and mem_t_clim_marche>t and mem_clim_marche==1 and a<3 ){consigne_t=consigne_t+1;Serial.print("consigne_t+ = ");Serial.println(consigne_t);marche_clim();Serial.println("clim marche ");x=0;z=0;a=a+1;b=0;
if (y=0) {mem_t_clim_marche=t;y=1;} } //marche clim
if ( x>60 and mem_t_clim_arret<t and mem_clim_marche==0 and b<3 ){irsend.sendRaw(aoff, 227, 38) ;Serial.println("clim arret ") ;x=0;y=0;b=b+1;a=0;
if (z=0) {mem_t_clim_arret=t;z=1;} } // arret clim car la temp continue montée
}
}