Time input with blynk 1.23.1 (203)

English text below

Excusez, je ne parle pas anglais !
ma demande est la compréhension de time input pour réaliser un interrupteur horaire. à heure de début => led allumée et heure de fin => led éteinte.
Pour cela, j’ai la dernière version de Blynk soit la 1.23.1 (203) est ce que c’est Blynk 2.0 ? j’en sais rien ? ? ? ? mais je viens tout juste de la télécharger.

pour l’application de mon portable, j’ai configurer “time input” comme cela :
V4 , data type:integer ; min 0 ; max 1 ; default 0 ; nom V4 ; Alias V4 ; units none ; activiter les données d’historique sur off ; tout le reste sur off.
sur parametre : datastream V4(V4) interger, 0/1, id=7 ; parametres time format HH:mm ; Allow start/stop input sur ON le reste sur OFF

dans mon programme arduino : (programme partiel, j’ai supprimé des parties inutiles à blynk
mon but est d’avoir 0 dans la variable “plage_confort” hors temps timer et d’avoir 1 dans la variable “plage_confort” si nous sommes dans la plage horaire du timer

je suis complétement perdu avec cette nouvelle version de blynk
merci de votre aide.

Sorry, I don’t speak English!
My request is to understand how to enter time to make a time switch. at start time => led on and end time => led off.
For this, I have the latest version of Blynk, 1.23.1 (203), is it Blynk 2.0? I don’t know anything about it? ? ? ? but I just downloaded it.

for my laptop application, I configured “time input” like this:
V4, data type: integer; min 0 ; maximum 1; default 0; name V4; Alias ​​V4; units none; turn history data off; everything else on off.
on parameter: datastream V4(V4) integer, 0/1, id=7; time format parameters HH:mm; Allow start/stop input to be ON, the rest to be OFF

in my arduino program: (partial program, I deleted unnecessary parts in blynk
my goal is to have 0 in the “comfort_beach” variable outside the timer time and to have 1 in the “comfort_beach” variable if we are in the timer time range

I’m completely lost with this new version of blynk
thank you for your help.


#define BLYNK_TEMPLATE_ID "TMwn"
#define BLYNK_TEMPLATE_NAME "lea"
#define BLYNK_AUTH_TOKEN "_NkQhB8GAE-U"

#define BLYNK_PRINT Serial   
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char ssid[] = "Livebox";  //Enter your WIFI Name
char pass[] = "???????";  //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> 

const uint16_t kIrLed = D3;  //              ***  LED emetrice sur D3 ***
IRsend irsend(kIrLed);  // Set the GPIO to be used to sending the message.


// ************************** boutons / Variables 
int inter_confort;
byte plage_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

  WidgetLED led1(1); //virtual led
  WidgetLED led2(7); //virtual led

// ************************** codes clim en memoire flash  *************************

const uint16_t a16[227] PROGMEM  = {3091, 1590, 32 488, 1097, 485, 333, 488};


// *****************************************  SETUP   ************************************************
void setup() {
  Serial.begin(115200);
  
  bool status;
  status = bme.begin(0x76);

  irsend.begin();
#if ESP8266
  Serial.begin(115200, SERIAL_8N1, SERIAL_TX_ONLY);
#else  // ESP8266
  Serial.begin(115200, SERIAL_8N1);
#endif  // ESP8266

 Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);

}
// **************** variable retour android  BLYNK***************

  
 
  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-1;                              // 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() {
toto:
  Blynk.run(); // Initialise Blynk
  Blynk.syncVirtual(V0, V2, V3, V4);
Serial.print("v3 inter confort = ");Serial.println(inter_confort);
Serial.print("v4 plage horaire = ");Serial.println(plage_confort);
Serial.print("v2 consig temp = ");Serial.println(consigne_t);
Serial.print("v0 clim marche = ");Serial.println(clim_marche);
 delay(5000);  

goto toto;
  

}

Yes.

This should be a String data type.

When you installed the Blynk library it also installed some Blynk examples. If you look in these Blynk examples at Widgets>TimeInput>AdvancedTimeInput then you’ll see an example which explains how to set-up your datastream and mobile dashboard widget for the code example.

Pete.

Merci de votre aide, j’ai bien avancé mais je pensais que blynk gérait une sortie lorsqu’on était dans le créneau horaire (apparemment non ! )
il faut donc que je charge le temps dans mon arduino, puis réaliser des tests pour positionner ma variable.

En attendant : voici le programme que j’ai qui fonctionne qui permet de recevoir l’heure de début et heure de fin

Thank you for your help, I made good progress but I thought that blynk managed an exit when we were in the time slot (apparently not!)
I therefore have to load the time into my arduino, then carry out tests to position my variable.

In the meantime: here is the program I have that works which allows me to receive the start time and end time


#define BLYNK_TEMPLATE_ID "TMVwn"
#define BLYNK_TEMPLATE_NAME "lea"
#define BLYNK_AUTH_TOKEN "po3p-U"

#define BLYNK_PRINT Serial    
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char ssid[] = "Liveboxs";  //Enter your WIFI Name
char pass[] = "6146A1DF";  //Enter your WIFI Password
int hd;
int mnd;
int hf;
int mnf;


BLYNK_WRITE(V4) {
  TimeInputParam t(param);

  // Process start time

  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 );
}

 

void setup()
{
  // Debug console
  Serial.begin(115200);
  Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
     int startAt = 0; // depart heure : minutes
     int stopAt =  0; // arret heure : minutes
     char tz[] = "Europe/Paris";
     Blynk.virtualWrite(V4, startAt, stopAt, tz );
}

void loop()
{
  Blynk.run();
}

No, if you use Automations instead of the Time Input widget then you get an output from the Blynk server at the start and stop times, but Automations don’t work offline.

Pete.

OK, mais si l’application dont être activée constamment, cela n’ira pas avec mon montage (seul esp reste 100% alimenté)
sinon, comment utiliser les automatisations ?

OK, but if the application is constantly activated, it will not work with my assembly (only esp remains 100% powered)
if not, how to use automations?

Voici le programme pour récupérer l’heure sur esp8266, reste a réunir les 2 programmes

Here is the program to retrieve the time on esp8266, all that remains is to combine the 2 programs


#include <NTPClient.h>
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <SPI.h>

// Declarations WIFI

    const char* ssid = "Livebo"; // Nom du réseau Wi-Fi
    const char* password = "DF"; // Mot De Passe du réseau 

// Variables de travail
//unsigned long epoch = 0;
//int nujour = 0; //numero jour de la semaine avec 0 pour dimanche
//String jour = "mon jour"; // dimanche, lundi, etc.
//String heure = "mon heure ..";
int h;
int mn;


//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);

void setup(){
  // Demarrage liaison serie
  Serial.begin(115200);
 
  // Connection au reseau WIFI
  WiFi.begin(ssid, password);
  while ( WiFi.status() != WL_CONNECTED ) {
    delay ( 500 );
    Serial.print ( "." );
  }
  // Demarrage client NTP
  timeClient.begin();
}

void loop() {
  // Recup heure puis affichage
  timeClient.update();
//  epoch = timeClient.getEpochTime(); // Heure Unix
//  nujour = timeClient.getDay();    // jour de la semaine
//  heure = timeClient.getFormattedTime(); // heure
  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;
    }
*/  
  // Envoi des donnees recuperees sur la liaison serie
//  Serial.print("Temps UNIX : ");
//  Serial.print(epoch);
//  Serial.print(" - jour : ");
//  Serial.print(jour);
  Serial.print(" - heure : ");
  Serial.print(h);
  Serial.print("  : ");
  Serial.println(mn);
  
  delay(1000); // tempo de 1 sec
}


Read the Blynk Documentation.

Please DO NOT use this code.
It is VERY badly written and breaks the Blynk rules about having a clean void loop.

Once again, read the Blynk documentation about the Blynk RTC function.

Pete.

Merci de votre réponse, mais avec blynk je ne trouve pas ? ? ? aucune piste après 3h de recherche.
mon programme n’est peut-être pas conventionnel, mais je le comprends, donc si je n’ai pas d’exemple, je continue sur ma lancée. surtout que pour l’instant cela fonctionne bien.

Thank you for your answer, but with blynk I can’t find it? ? ? no leads after 3 hours of searching.
my program may not be conventional, but I understand it, so if I don’t have an example, I continue on my path. especially since for the moment it works well.

I’m not sure what exactly it is that you can’t find.

As I’ve suggested that you research two things - automations and RTC - I assume that it’s one of these that you can’t find?

Automations…

RTC…

Pete.

Merci, j’ai essayé avec Time RTC, cela fonctionne mais le temps de retour est en UNIX, pour “retrouver” les heures et minutes actuelles, je me suis confronté à un mur . . . j’ai donc abandonné. Pour les automatisations : cela pourrait le faire, mais il est impératif que l’application blynk soit en fonctionnement ( ce qui ne sera pas forcément le cas pour moi ) c’est pourquoi je ne prends pas cette solution.

Thank you, I tried with Time RTC, it works but the return time is in UNIX, to “find” the current hours and minutes, I ran into a wall. . . so I gave up. For automations: this could do it, but it is imperative that the blynk application is running (which will not necessarily be the case for me) which is why I do not take this solution.

I’m guessing you didn’t hit the “Next” button at the bottom of the RTC documentation to read about how the ezTime.h library can be used to adjust for timezone an DST, and give you a local datetime output?

From there it’s fairly easy to calculate the current local time in elapsed seconds since midnight and compare this to start/stop offset times obtained from the Time Input widget.
If you’re never planning to have a timer span the midnight period from one day to another then the code is quite simple from there. If you want times that span midnight then it gets a little more complex, but it’s still do-able by identifying that the stops time offset value is smaller than the start time offset value and adding some logic to ignore the stop time until midnight has been observed.

Pete.

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                                 
                                       
  }
}

Encore une petite question svp :
La température je l’affiche avec une gauge en V6 interger => cela fonctionne
mais je voudrai rajouter en plus un graphique qui me montre la température, j’ai donc rajouté “simpleChart” et datastream : Double V6 (V6) ==> (la même entrès que ma gauge) mais là il me dit “no data”

avez vous une idèe
d’où vient le problème ?
merci

One more quick question please:
I display the temperature with a V6 interger gauge => it works
but I would also like to add a graph which shows me the temperature, so I added “simpleChart” and datastream: Double V6 (V6) ==> (the same entry as my gauge) but there it tells me “no data”

do you have any idea where the problem is coming from?
THANKS

Not only is your code “not very nice”, it won’t work reliably as it…

You need to read this and restructure your code…

When you restructure your code you should NOT use Blynk.syncVirtual anywhere other than in a function called BLYNK_CONNECTED()

You should also do some research to understand how the ESP8266 keeps track of time internally, once it has been “told” what the current time is by obtaining that time from an external source (which should be the Blynk server using the RTC functionality, but in your case is a Network Time Protocol server. You only need to synchronise the time with the NTP server on startup, then probably once every day or even once every week - depending on how accurate to the second you need your timing to be.

Advice to anyone reading this post- do not use this code in your own projects, this code is awful,

This is because you haven’t enabled the “Enable data history” option in your datastream.

Pete.

PeteKnight je tiens vraiment à vous remercier de tout ce que vous faites. Et je prends notes de vos remarques qui sont 100% justifié. En ce moment je n’ai pas le temps de revoir mon code, mais je vous promets de mis remettre cet été, lorsqu’on aura plus besoin de chauffage.
Encore un GRANG MERCI !

PeteKnight I really want to thank you for everything you do. And I take note of your remarks which are 100% justified. At the moment I don’t have time to review my code, but I promise to put it back this summer, when we no longer need heating.
Another BIG THANK YOU!

Don’t be surprised if your device doesn’t work reliably in the meantime.

Pete.

Je reviens vers vous, car en effet “vous avez encore raison !” et ce n’est pas le manque de me l’avoir dit ! ! ! ( j’ai la tête dure ! )
Blink ne fonctionne plus après 5 à 6 heures de fonctionnement.
Ce qui est curieux, blink m’indique qu’il est connecté, mais plus aucune information ne passe entre blink et mon esp.
j’ai même realiser un petit programme de test (sans horloge) juste un inter et un voyant et cela ne fonctionne pas, pourtant blynk m’indique bien lorsqu’il est connecté ou pas à ma carte.
Question: d’après vous, est ce que c’est le serveur blinck qui me bloque ? ( à cause de mon horloge ) et combien de temps va t il me bloquer car avec mon programme de test je n’ai plus mon horloge et cela ne fonctionne pas.
merci.

I’m coming back to you, because indeed “you’re right again!” and it’s not the lack of having told me! ! ! (I have a hard head!)
Blink no longer works after 5 to 6 hours of operation.
What is curious, blink tells me that it is connected, but no more information passes between blink and my esp.
I even created a small test program (without a clock) just an switch and a light and it doesn’t work, yet blynk tells me when it is connected or not to my card.
Question: In your opinion, is it the blinck server that is blocking me? (because of my clock) and how long will it block me because with my test program I no longer have my clock and it does not work.
THANKS.

#define BLYNK_TEMPLATE_ID "eI"
#define BLYNK_TEMPLATE_NAME "c"
#define BLYNK_AUTH_TOKEN "Fg"



#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[] = "61";  //Enter your WIFI Password
int inter_confort;
  WidgetLED led1(1); //virtual led
  WidgetLED led2(7); //virtual led
    BLYNK_WRITE(V3)  //1 si confort 0 reduit 
  { inter_confort = param.asInt(); }

  void setup() {
  Serial.begin(115200);
 Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
 }

void loop() {
 Blynk.run(); // Initialise Blynk
 Blynk.virtualWrite(V1, 255);Serial.println("led 1 : on");
 delay(1000);
  Blynk.virtualWrite(V1, 0);Serial.println("led 1 : off");
  if(inter_confort == 1 ) {Serial.println("inter : on");} else {Serial.println("inter : off");}
 delay(1000);
}

What type of Blynk subscription do you have?
If it’s a free subscription with up to 10 devices then you’ve probably hit the monthly message limit for your account.

Pete.

oui, abonnement gratuit;

comment compte t il le nombre de messages ?
c’est l’envoie de ma température ?
et quelle est cette limite

yes, free subscription;

how does it count the number of messages?
is it sending my temperature?
and what is this limit

j’ai trouvé cela :
Bonjour.
Vous pouvez envoyer 100 événements par appareil et par jour et pas plus d’un événement par seconde et par appareil. Les limites ne sont pas définitives et seront ajustées en fonction des usages et des plans.

I found this:
Good morning.
You can send 100 events per device per day and no more than one event per second per device. The limits are not final and will be adjusted according to uses and plans.

It’s good ?

100 par jour = 4 par heure !
si j’ai température plus hydrometrie cela me donne 1 envois max pour 3 minutes.
c’est cela ?
(c’est peu ! ! !)

100 per day = 4 per hour!
if I have a temperature plus hydrometry this gives me 1 sending max for 3 minutes.
is that it?
(it’s not much!!!)

If I understand correctly, my Blynk application will be blocked for 24 hours because I have exceeded 100 data / day
is that it?

There’s are two types of Free subscription. The old version which allowed (I think) two devices, and the current version which allows 10 devices.

If you have the current 10 device version then you are limited to a total of 30,000 messages per month.

A message is data sent from your device to the Blynk server using Blynk.virtualWrite, Blynk.setProperty or Blynk.syncVirtual, or from the server to your device when a widget value changes (a widget button is pushed etc), or in response to a Blynk.syncVirtual command.

Messages are also exchanged at start-up, when the device is authenticated to the server.
All of these messages count towards the 30,000 monthly message limit.

This obviously equates to around 1,000 messages per day, or 40 messages per hour.

I don’t have a “new” free account with the 10 devices and 30,000 message limit, but I understand that the web console shows the message count in the top bar.

If you have the older type of Free account then the 30,000 message limit does not apply, so your issue is caused by something else.

Pete.