I also give you the program
// #define BLYNK_DEBUG
#define BLYNK_PRINT Serial //
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <TimeLib.h>
#include <WidgetRTC.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
//WidgetLED led1(V30);//
WidgetLCD lcd(V8);
char auth[] = "xxxxx"; // Put your Auth Token here. (see Step 3 above)
char ssid[] = "xxxxx";
char pass[] = "xxxxxxxx";
SimpleTimer timer;
int roomTemperature;
WidgetRTC rtc;
char Date[16];
char Time[16];
int manual=1;
int lundimatin=0;
int lundiAM=0;
int mardimatin=0;
int mardiAM=0;
int mercredimatin=0;
int mercrediAM=0;
int jeudimatin=0;
int jeudiAM=0;
int vendredimatin=0;
int vendrediAM=0;
int samedimatin=0;
int samediAM=0;
int dimanchematin=0;
int dimancheAM=0;
int eco=0;
long startsecondswd; // weekday start time in seconds
long stopsecondswd; // weekday stop time in seconds
long nowseconds; // time now in seconds
void setup()
{
WiFi.mode(WIFI_STA);
Serial.begin(9600); // See the connection status in Serial Monitor
// Blynk.begin(auth, "xxxx", "xxxxx"); //insert here your SSID and password
Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,35), 8442);
while (Blynk.connect() == false) {
// Wait until connected
}
sensors.begin(); // Starts the DS18B20 sensor(s).
sensors.setResolution(10); // More on resolution: http://www.homautomation.org/2015/11/17/ds18b20-how-to-change-resolution-9101112-bits/
// Notice how there is very little in the loop()? Blynk works best that way.
rtc.begin();
pinMode(5, OUTPUT);
digitalWrite(5, HIGH);
Blynk.virtualWrite(V49, 1);
//lcd.clear();
lcd.print(3,0,"mode auto");
Blynk.setProperty(V8, "color", "#04C0F8");
Blynk.virtualWrite(V9, 0);
Blynk.setProperty(V9, "color", "#000000");//couleur noire
Blynk.setProperty(V9, "offLabel", ".");
Blynk.setProperty(V9, "label", ".");
Blynk.setProperty(V9, "onLabel", "BOUTON INACTIF EN MODE AUTO");
delay(10);
timer.setInterval(100000L, sendWifi);
timer.setInterval(60000L, syncRelay);
timer.setInterval(4000L, syncRelay1);
timer.setInterval(1000,showCurrentTime);
timer.setInterval(10000L, sendTemps); // Temperature sensor read interval. 2000 (ms) = 2 seconds.
}
BLYNK_WRITE(V49) //bouton auto/manu
{
if (param.asInt()==1)
{
manual=1;
lcd.print(3,0,"mode auto");
Blynk.setProperty(V8, "color", "#04C0F8");
Blynk.virtualWrite(V9, 0);
Blynk.setProperty(V9, "color", "#000000");//couleur noire
Blynk.setProperty(V9, "offLabel", ".");
Blynk.setProperty(V9, "label", ".");
Blynk.setProperty(V9, "onLabel", "BOUTON INACTIF EN MODE AUTO");
}
else
{
manual=0;
lcd.print(3,0,"mode manu");
Blynk.setProperty(V8, "color", "#D3435C");
Blynk.virtualWrite(V9, 0);
Blynk.setProperty(V9, "color", "#FF0000");//couleur rouge vif
Blynk.setProperty(V9, "offLabel", "Appuyer ICI pour allumer le poêle");
Blynk.setProperty(V9, "label", "bouton manu");
Blynk.setProperty(V9, "onLabel", "Appuyer ICI pour éteindre le poêle");
}
}
BLYNK_WRITE(V9)//bouton marche forcée en mode manu
{
int marcheforcee = param.asInt();
if( manual == 0)
{
if(marcheforcee==1)
{
digitalWrite(5, LOW);
lcd.print(0,1,"poêle en marche");
}
else
{
digitalWrite(5, HIGH);
lcd.print(0,1,"poêle à l'arrêt");
}
}
else
{
}
}
BLYNK_WRITE(V12)//température éco
{
if (param.asInt()==1)
{
eco=1;
}
else
{
eco=0;
}
}
BLYNK_WRITE(V10)//tempérarure confort
{
int tempconfort = param.asInt();
if( manual == 1)
{
lcd.print(3,0,"mode auto");
Blynk.virtualWrite(V9, 0);
if(((tempconfort == 1) && ((lundimatin == 1) || (lundiAM == 1) ||(mardimatin == 1 ) || (mardiAM == 1 ) || (mercredimatin == 1 ) || (mercrediAM == 1 ) || (jeudimatin == 1 ) || (jeudiAM == 1 ) || (vendredimatin == 1 ) || (vendrediAM == 1 ) || (samedimatin == 1 ) || (samediAM == 1 ) || (dimanchematin == 1 ) || (dimancheAM == 1 ))) || (eco == 1 ))
{
//lcd.print(3,0,"mode auto");
lcd.print(0,1,"poêle en marche");
digitalWrite(5, LOW);
//Blynk.virtualWrite(V9, 0);
Blynk.virtualWrite(V14, 1);
}
else{
//lcd.print(3,0,"mode auto");
lcd.print(0,1,"poêle à l'arrêt");
digitalWrite(5, HIGH);
//Blynk.virtualWrite(V9, 0);
Blynk.virtualWrite(V14, 0);
}
}
else{
}
}
BLYNK_WRITE(V50)//programmation lundi matin
{
if (manual==1)
{
sprintf(Date, "%02d/%02d/%04d", day(), month(), year());
sprintf(Time, "%02d:%02d:%02d", hour(), minute(), second());
TimeInputParam t(param);
Serial.println(Time);
Serial.println(Date);
int dayadjustment = -1;
if(weekday() == 1){
dayadjustment = 6; // needed for Sunday, Time library is day 1 and Blynk is day 7
}
if(t.isWeekdaySelected(weekday() + dayadjustment)){ //Time library starts week on Sunday, Blynk on Monday
nowseconds = ((hour() * 3600) + (minute() * 60) + second());
startsecondswd = (t.getStartHour() * 3600) + (t.getStartMinute() * 60);
Serial.println(startsecondswd); // used for debugging
if(nowseconds >= startsecondswd){
if(nowseconds <= startsecondswd + 90){ // 90s on 60s timer ensures 1 trigger command is sent
Blynk.virtualWrite(V51, 1);
// code here to switch the relay ON
}
}
else
{
}
stopsecondswd = (t.getStopHour() * 3600) + (t.getStopMinute() * 60);
Serial.println(stopsecondswd); // used for debugging
if(nowseconds >= stopsecondswd){
Blynk.virtualWrite(V51, 0);
if(nowseconds <= stopsecondswd + 90){ // 90s on 60s timer ensures 1 trigger command is sent
Blynk.virtualWrite(V51, 0);
// code here to switch the relay OFF
}
}
else{
if(nowseconds >= startsecondswd){
Blynk.virtualWrite(V51, 1);
}
}
}
else
{
// nothing to do today, check again in 30 SECONDS time
}
}
}
BLYNK_WRITE(V52)//programmation lundi AM
{
if (manual==1)
{
sprintf(Date, "%02d/%02d/%04d", day(), month(), year());
sprintf(Time, "%02d:%02d:%02d", hour(), minute(), second());
TimeInputParam t(param);
Serial.println(Time);
Serial.println(Date);
int dayadjustment = -1;
if(weekday() == 1){
dayadjustment = 6; // needed for Sunday, Time library is day 1 and Blynk is day 7
}
if(t.isWeekdaySelected(weekday() + dayadjustment)){ //Time library starts week on Sunday, Blynk on Monday
nowseconds = ((hour() * 3600) + (minute() * 60) + second());
startsecondswd = (t.getStartHour() * 3600) + (t.getStartMinute() * 60);
Serial.println(startsecondswd); // used for debugging
if(nowseconds >= startsecondswd){
if(nowseconds <= startsecondswd + 90){ // 90s on 60s timer ensures 1 trigger command is sent
Blynk.virtualWrite(V53, 1);
// code here to switch the relay ON
}
}
else
{
}
stopsecondswd = (t.getStopHour() * 3600) + (t.getStopMinute() * 60);
Serial.println(stopsecondswd); // used for debugging
if(nowseconds >= stopsecondswd){
Blynk.virtualWrite(V53, 0);
if(nowseconds <= stopsecondswd + 90){ // 90s on 60s timer ensures 1 trigger command is sent
Blynk.virtualWrite(V53, 0);
// code here to switch the relay OFF
}
}
else{
if(nowseconds >= startsecondswd){
Blynk.virtualWrite(V53, 1);
}
}
}
else
{
// nothing to do today, check again in 30 SECONDS time
}
}
}
BLYNK_WRITE(V54)//programmation mardi matin
{
if (manual==1)
{
sprintf(Date, "%02d/%02d/%04d", day(), month(), year());
sprintf(Time, "%02d:%02d:%02d", hour(), minute(), second());
TimeInputParam t(param);
Serial.println(Time);
Serial.println(Date);
int dayadjustment = -1;
if(weekday() == 1){
dayadjustment = 6; // needed for Sunday, Time library is day 1 and Blynk is day 7
}
if(t.isWeekdaySelected(weekday() + dayadjustment)){ //Time library starts week on Sunday, Blynk on Monday
nowseconds = ((hour() * 3600) + (minute() * 60) + second());
startsecondswd = (t.getStartHour() * 3600) + (t.getStartMinute() * 60);
Serial.println(startsecondswd); // used for debugging
if(nowseconds >= startsecondswd){
if(nowseconds <= startsecondswd + 90){ // 90s on 60s timer ensures 1 trigger command is sent
Blynk.virtualWrite(V55, 1);
// code here to switch the relay ON
}
}
else
{
}
stopsecondswd = (t.getStopHour() * 3600) + (t.getStopMinute() * 60);
Serial.println(stopsecondswd); // used for debugging
if(nowseconds >= stopsecondswd){
Blynk.virtualWrite(V55, 0);
if(nowseconds <= stopsecondswd + 90){ // 90s on 60s timer ensures 1 trigger command is sent
Blynk.virtualWrite(V55, 0);
// code here to switch the relay OFF
}
}
else{
if(nowseconds >= startsecondswd){
Blynk.virtualWrite(V55, 1);
}
}
}
else
{
// nothing to do today, check again in 30 SECONDS time
}
}
}
BLYNK_WRITE(V56)//programmation mardi AM
{
if (manual==1)
{
sprintf(Date, "%02d/%02d/%04d", day(), month(), year());
sprintf(Time, "%02d:%02d:%02d", hour(), minute(), second());
TimeInputParam t(param);
Serial.println(Time);
Serial.println(Date);
int dayadjustment = -1;
if(weekday() == 1){
dayadjustment = 6; // needed for Sunday, Time library is day 1 and Blynk is day 7
}
if(t.isWeekdaySelected(weekday() + dayadjustment)){ //Time library starts week on Sunday, Blynk on Monday
nowseconds = ((hour() * 3600) + (minute() * 60) + second());
startsecondswd = (t.getStartHour() * 3600) + (t.getStartMinute() * 60);
Serial.println(startsecondswd); // used for debugging
if(nowseconds >= startsecondswd){
if(nowseconds <= startsecondswd + 90){ // 90s on 60s timer ensures 1 trigger command is sent
Blynk.virtualWrite(V57, 1);
// code here to switch the relay ON
}
}
else
{
}
stopsecondswd = (t.getStopHour() * 3600) + (t.getStopMinute() * 60);
Serial.println(stopsecondswd); // used for debugging
if(nowseconds >= stopsecondswd){
Blynk.virtualWrite(V57, 0);
if(nowseconds <= stopsecondswd + 90){ // 90s on 60s timer ensures 1 trigger command is sent
Blynk.virtualWrite(V57, 0);
// code here to switch the relay OFF
}
}
else{
if(nowseconds >= startsecondswd){
Blynk.virtualWrite(V57, 1);
}
}
}
else
{
// nothing to do today, check again in 30 SECONDS time
}
}
}
BLYNK_WRITE(V58)//programmation mercredi matin
{
if (manual==1)
{
sprintf(Date, "%02d/%02d/%04d", day(), month(), year());
sprintf(Time, "%02d:%02d:%02d", hour(), minute(), second());
TimeInputParam t(param);
Serial.println(Time);
Serial.println(Date);
int dayadjustment = -1;
if(weekday() == 1){
dayadjustment = 6; // needed for Sunday, Time library is day 1 and Blynk is day 7
}
if(t.isWeekdaySelected(weekday() + dayadjustment)){ //Time library starts week on Sunday, Blynk on Monday
nowseconds = ((hour() * 3600) + (minute() * 60) + second());
startsecondswd = (t.getStartHour() * 3600) + (t.getStartMinute() * 60);
Serial.println(startsecondswd); // used for debugging
if(nowseconds >= startsecondswd){
if(nowseconds <= startsecondswd + 90){ // 90s on 60s timer ensures 1 trigger command is sent
Blynk.virtualWrite(V59, 1);
// code here to switch the relay ON
}
}
else
{
}
stopsecondswd = (t.getStopHour() * 3600) + (t.getStopMinute() * 60);
Serial.println(stopsecondswd); // used for debugging
if(nowseconds >= stopsecondswd){
Blynk.virtualWrite(V59, 0);
if(nowseconds <= stopsecondswd + 90){ // 90s on 60s timer ensures 1 trigger command is sent
Blynk.virtualWrite(V59, 0);
// code here to switch the relay OFF
}
}
else{
if(nowseconds >= startsecondswd){
Blynk.virtualWrite(V59, 1);
}
}
}
else
{
// nothing to do today, check again in 30 SECONDS time
}
}
}
BLYNK_WRITE(V60)//programmation mercredi AM
{
if (manual==1)
{
sprintf(Date, "%02d/%02d/%04d", day(), month(), year());
sprintf(Time, "%02d:%02d:%02d", hour(), minute(), second());
TimeInputParam t(param);
Serial.println(Time);
Serial.println(Date);
int dayadjustment = -1;
if(weekday() == 1){
dayadjustment = 6; // needed for Sunday, Time library is day 1 and Blynk is day 7
}
if(t.isWeekdaySelected(weekday() + dayadjustment)){ //Time library starts week on Sunday, Blynk on Monday
nowseconds = ((hour() * 3600) + (minute() * 60) + second());
startsecondswd = (t.getStartHour() * 3600) + (t.getStartMinute() * 60);
Serial.println(startsecondswd); // used for debugging
if(nowseconds >= startsecondswd){
if(nowseconds <= startsecondswd + 90){ // 90s on 60s timer ensures 1 trigger command is sent
Blynk.virtualWrite(V61, 1);
// code here to switch the relay ON
}
}
else
{
}
stopsecondswd = (t.getStopHour() * 3600) + (t.getStopMinute() * 60);
Serial.println(stopsecondswd); // used for debugging
if(nowseconds >= stopsecondswd){
Blynk.virtualWrite(V61, 0);
if(nowseconds <= stopsecondswd + 90){ // 90s on 60s timer ensures 1 trigger command is sent
Blynk.virtualWrite(V61, 0);
// code here to switch the relay OFF
}
}
else{
if(nowseconds >= startsecondswd){
Blynk.virtualWrite(V61, 1);
}
}
}
else
{
// nothing to do today, check again in 30 SECONDS time
}
}
}
BLYNK_WRITE(V62)//programmation jeudi matin
{
if (manual==1)
{
sprintf(Date, "%02d/%02d/%04d", day(), month(), year());
sprintf(Time, "%02d:%02d:%02d", hour(), minute(), second());
TimeInputParam t(param);
Serial.println(Time);
Serial.println(Date);
int dayadjustment = -1;
if(weekday() == 1){
dayadjustment = 6; // needed for Sunday, Time library is day 1 and Blynk is day 7
}
if(t.isWeekdaySelected(weekday() + dayadjustment)){ //Time library starts week on Sunday, Blynk on Monday
nowseconds = ((hour() * 3600) + (minute() * 60) + second());
startsecondswd = (t.getStartHour() * 3600) + (t.getStartMinute() * 60);
Serial.println(startsecondswd); // used for debugging
if(nowseconds >= startsecondswd){
if(nowseconds <= startsecondswd + 90){ // 90s on 60s timer ensures 1 trigger command is sent
Blynk.virtualWrite(V63, 1);
// code here to switch the relay ON
}
}
else
{
}
stopsecondswd = (t.getStopHour() * 3600) + (t.getStopMinute() * 60);
Serial.println(stopsecondswd); // used for debugging
if(nowseconds >= stopsecondswd){
Blynk.virtualWrite(V63, 0);
if(nowseconds <= stopsecondswd + 90){ // 90s on 60s timer ensures 1 trigger command is sent
Blynk.virtualWrite(V63, 0);
// code here to switch the relay OFF
}
}
else{
if(nowseconds >= startsecondswd){
Blynk.virtualWrite(V63, 1);
}
}
}
else
{
// nothing to do today, check again in 30 SECONDS time
}
}
}
BLYNK_WRITE(V64)//programmation jeudi AM
{
if (manual==1)
{
sprintf(Date, "%02d/%02d/%04d", day(), month(), year());
sprintf(Time, "%02d:%02d:%02d", hour(), minute(), second());
TimeInputParam t(param);
Serial.println(Time);
Serial.println(Date);
int dayadjustment = -1;
if(weekday() == 1){
dayadjustment = 6; // needed for Sunday, Time library is day 1 and Blynk is day 7
}
if(t.isWeekdaySelected(weekday() + dayadjustment)){ //Time library starts week on Sunday, Blynk on Monday
nowseconds = ((hour() * 3600) + (minute() * 60) + second());
startsecondswd = (t.getStartHour() * 3600) + (t.getStartMinute() * 60);
Serial.println(startsecondswd); // used for debugging
if(nowseconds >= startsecondswd){
if(nowseconds <= startsecondswd + 90){ // 90s on 60s timer ensures 1 trigger command is sent
Blynk.virtualWrite(V65, 1);
// code here to switch the relay ON
}
}
else
{
}
stopsecondswd = (t.getStopHour() * 3600) + (t.getStopMinute() * 60);
Serial.println(stopsecondswd); // used for debugging
if(nowseconds >= stopsecondswd){
Blynk.virtualWrite(V65, 0);
if(nowseconds <= stopsecondswd + 90){ // 90s on 60s timer ensures 1 trigger command is sent
Blynk.virtualWrite(V65, 0);
// code here to switch the relay OFF
}
}
else{
if(nowseconds >= startsecondswd){
Blynk.virtualWrite(V65, 1);
}
}
}
else
{
// nothing to do today, check again in 30 SECONDS time
}
}
}
BLYNK_WRITE(V66)//programmation vendredi matin
{
if (manual==1)
{
sprintf(Date, "%02d/%02d/%04d", day(), month(), year());
sprintf(Time, "%02d:%02d:%02d", hour(), minute(), second());
TimeInputParam t(param);
Serial.println(Time);
Serial.println(Date);
int dayadjustment = -1;
if(weekday() == 1){
dayadjustment = 6; // needed for Sunday, Time library is day 1 and Blynk is day 7
}
if(t.isWeekdaySelected(weekday() + dayadjustment)){ //Time library starts week on Sunday, Blynk on Monday
nowseconds = ((hour() * 3600) + (minute() * 60) + second());
startsecondswd = (t.getStartHour() * 3600) + (t.getStartMinute() * 60);
Serial.println(startsecondswd); // used for debugging
if(nowseconds >= startsecondswd){
if(nowseconds <= startsecondswd + 90){ // 90s on 60s timer ensures 1 trigger command is sent
Blynk.virtualWrite(V67, 1);
// code here to switch the relay ON
}
}
else
{
}
stopsecondswd = (t.getStopHour() * 3600) + (t.getStopMinute() * 60);
Serial.println(stopsecondswd); // used for debugging
if(nowseconds >= stopsecondswd){
Blynk.virtualWrite(V67, 0);
if(nowseconds <= stopsecondswd + 90){ // 90s on 60s timer ensures 1 trigger command is sent
Blynk.virtualWrite(V67, 0);
// code here to switch the relay OFF
}
}
else{
if(nowseconds >= startsecondswd){
Blynk.virtualWrite(V67, 1);
}
}
}
else
{
// nothing to do today, check again in 30 SECONDS time
}
}
}
BLYNK_WRITE(V68)//programmation vendredi AM
{
if (manual==1)
{
sprintf(Date, "%02d/%02d/%04d", day(), month(), year());
sprintf(Time, "%02d:%02d:%02d", hour(), minute(), second());
TimeInputParam t(param);
Serial.println(Time);
Serial.println(Date);
int dayadjustment = -1;
if(weekday() == 1){
dayadjustment = 6; // needed for Sunday, Time library is day 1 and Blynk is day 7
}
if(t.isWeekdaySelected(weekday() + dayadjustment)){ //Time library starts week on Sunday, Blynk on Monday
nowseconds = ((hour() * 3600) + (minute() * 60) + second());
startsecondswd = (t.getStartHour() * 3600) + (t.getStartMinute() * 60);
Serial.println(startsecondswd); // used for debugging
if(nowseconds >= startsecondswd){
if(nowseconds <= startsecondswd + 90){ // 90s on 60s timer ensures 1 trigger command is sent
Blynk.virtualWrite(V69, 1);
// code here to switch the relay ON
}
}
else
{
}
stopsecondswd = (t.getStopHour() * 3600) + (t.getStopMinute() * 60);
Serial.println(stopsecondswd); // used for debugging
if(nowseconds >= stopsecondswd){
Blynk.virtualWrite(V69, 0);
if(nowseconds <= stopsecondswd + 90){ // 90s on 60s timer ensures 1 trigger command is sent
Blynk.virtualWrite(V69, 0);
// code here to switch the relay OFF
}
}
else{
if(nowseconds >= startsecondswd){
Blynk.virtualWrite(V69, 1);
}
}
}
else
{
// nothing to do today, check again in 30 SECONDS time
}
}
}
BLYNK_WRITE(V70)//programmation samedi matin
{
if (manual==1)
{
sprintf(Date, "%02d/%02d/%04d", day(), month(), year());
sprintf(Time, "%02d:%02d:%02d", hour(), minute(), second());
TimeInputParam t(param);
Serial.println(Time);
Serial.println(Date);
int dayadjustment = -1;
if(weekday() == 1){
dayadjustment = 6; // needed for Sunday, Time library is day 1 and Blynk is day 7
}
if(t.isWeekdaySelected(weekday() + dayadjustment)){ //Time library starts week on Sunday, Blynk on Monday
nowseconds = ((hour() * 3600) + (minute() * 60) + second());
startsecondswd = (t.getStartHour() * 3600) + (t.getStartMinute() * 60);
Serial.println(startsecondswd); // used for debugging
if(nowseconds >= startsecondswd){
if(nowseconds <= startsecondswd + 90){ // 90s on 60s timer ensures 1 trigger command is sent
Blynk.virtualWrite(V71, 1);
// code here to switch the relay ON
}
}
else
{
}
stopsecondswd = (t.getStopHour() * 3600) + (t.getStopMinute() * 60);
Serial.println(stopsecondswd); // used for debugging
if(nowseconds >= stopsecondswd){
Blynk.virtualWrite(V71, 0);
if(nowseconds <= stopsecondswd + 90){ // 90s on 60s timer ensures 1 trigger command is sent
Blynk.virtualWrite(V71, 0);
// code here to switch the relay OFF
}
}
else{
if(nowseconds >= startsecondswd){
Blynk.virtualWrite(V71, 1);
}
}
}
else
{
// nothing to do today, check again in 30 SECONDS time
}
}
}
BLYNK_WRITE(V72)//programmation samedi AM
{
if (manual==1)
{
sprintf(Date, "%02d/%02d/%04d", day(), month(), year());
sprintf(Time, "%02d:%02d:%02d", hour(), minute(), second());
TimeInputParam t(param);
Serial.println(Time);
Serial.println(Date);
int dayadjustment = -1;
if(weekday() == 1){
dayadjustment = 6; // needed for Sunday, Time library is day 1 and Blynk is day 7
}
if(t.isWeekdaySelected(weekday() + dayadjustment)){ //Time library starts week on Sunday, Blynk on Monday
nowseconds = ((hour() * 3600) + (minute() * 60) + second());
startsecondswd = (t.getStartHour() * 3600) + (t.getStartMinute() * 60);
Serial.println(startsecondswd); // used for debugging
if(nowseconds >= startsecondswd){
if(nowseconds <= startsecondswd + 90){ // 90s on 60s timer ensures 1 trigger command is sent
Blynk.virtualWrite(V73, 1);
// code here to switch the relay ON
}
}
else
{
}
stopsecondswd = (t.getStopHour() * 3600) + (t.getStopMinute() * 60);
Serial.println(stopsecondswd); // used for debugging
if(nowseconds >= stopsecondswd){
Blynk.virtualWrite(V73, 0);
if(nowseconds <= stopsecondswd + 90){ // 90s on 60s timer ensures 1 trigger command is sent
Blynk.virtualWrite(V73, 0);
// code here to switch the relay OFF
}
}
else{
if(nowseconds >= startsecondswd){
Blynk.virtualWrite(V73, 1);
}
}
}
else
{
// nothing to do today, check again in 30 SECONDS time
}
}
}
BLYNK_WRITE(V74)//programmation dimanche matin
{
if (manual==1)
{
sprintf(Date, "%02d/%02d/%04d", day(), month(), year());
sprintf(Time, "%02d:%02d:%02d", hour(), minute(), second());
TimeInputParam t(param);
Serial.println(Time);
Serial.println(Date);
int dayadjustment = -1;
if(weekday() == 1){
dayadjustment = 6; // needed for Sunday, Time library is day 1 and Blynk is day 7
}
if(t.isWeekdaySelected(weekday() + dayadjustment)){ //Time library starts week on Sunday, Blynk on Monday
nowseconds = ((hour() * 3600) + (minute() * 60) + second());
startsecondswd = (t.getStartHour() * 3600) + (t.getStartMinute() * 60);
Serial.println(startsecondswd); // used for debugging
if(nowseconds >= startsecondswd){
if(nowseconds <= startsecondswd + 90){ // 90s on 60s timer ensures 1 trigger command is sent
Blynk.virtualWrite(V75, 1);
// code here to switch the relay ON
}
}
else
{
}
stopsecondswd = (t.getStopHour() * 3600) + (t.getStopMinute() * 60);
Serial.println(stopsecondswd); // used for debugging
if(nowseconds >= stopsecondswd){
Blynk.virtualWrite(V75, 0);
if(nowseconds <= stopsecondswd + 90){ // 90s on 60s timer ensures 1 trigger command is sent
Blynk.virtualWrite(V75, 0);
// code here to switch the relay OFF
}
}
else{
if(nowseconds >= startsecondswd){
Blynk.virtualWrite(V75, 1);
}
}
}
else
{
// nothing to do today, check again in 30 SECONDS time
}
}
}
BLYNK_WRITE(V76)//programmation dimanche AM
{
if (manual==1)
{
sprintf(Date, "%02d/%02d/%04d", day(), month(), year());
sprintf(Time, "%02d:%02d:%02d", hour(), minute(), second());
TimeInputParam t(param);
Serial.println(Time);
Serial.println(Date);
int dayadjustment = -1;
if(weekday() == 1){
dayadjustment = 6; // needed for Sunday, Time library is day 1 and Blynk is day 7
}
if(t.isWeekdaySelected(weekday() + dayadjustment)){ //Time library starts week on Sunday, Blynk on Monday
nowseconds = ((hour() * 3600) + (minute() * 60) + second());
startsecondswd = (t.getStartHour() * 3600) + (t.getStartMinute() * 60);
Serial.println(startsecondswd); // used for debugging
if(nowseconds >= startsecondswd){
if(nowseconds <= startsecondswd + 90){ // 90s on 60s timer ensures 1 trigger command is sent
Blynk.virtualWrite(V77, 1);
// code here to switch the relay ON
}
}
else
{
}
stopsecondswd = (t.getStopHour() * 3600) + (t.getStopMinute() * 60);
Serial.println(stopsecondswd); // used for debugging
if(nowseconds >= stopsecondswd){
Blynk.virtualWrite(V77, 0);
if(nowseconds <= stopsecondswd + 90){ // 90s on 60s timer ensures 1 trigger command is sent
Blynk.virtualWrite(V77, 0);
// code here to switch the relay OFF
}
}
else{
if(nowseconds >= startsecondswd){
Blynk.virtualWrite(V77, 1);
}
}
}
else
{
// nothing to do today, check again in 30 SECONDS time
}
}
}
BLYNK_WRITE(V51) //prog lundi matin
{
lundimatin = param.asInt();
}
BLYNK_WRITE(V53)//prog lundi AM
{
lundiAM = param.asInt();
}
BLYNK_WRITE(V55)//prog mardi matin
{
mardimatin = param.asInt();
}
BLYNK_WRITE(V57)//prog mardi AM
{
mardiAM = param.asInt();
}
BLYNK_WRITE(V59)//prog mercredi matin
{
mercredimatin = param.asInt();
}
BLYNK_WRITE(V61)//prog mercredi AM
{
mercrediAM = param.asInt();
}
BLYNK_WRITE(V63)//prog jeudi matin
{
jeudimatin = param.asInt();
}
BLYNK_WRITE(V65)//prog jeudi AM
{
jeudiAM = param.asInt();
}
BLYNK_WRITE(V67)//prog vendredi matin
{
vendredimatin = param.asInt();
}
BLYNK_WRITE(V69)//prog vendredi AM
{
vendrediAM = param.asInt();
}
BLYNK_WRITE(V71)//prog samedi matin
{
samedimatin = param.asInt();
}
BLYNK_WRITE(V73)//prog samedi AM
{
samediAM = param.asInt();
}
BLYNK_WRITE(V75)//prog dimanche matin
{
dimanchematin = param.asInt();
}
BLYNK_WRITE(V77)//prog dimanche AM
{
dimancheAM = param.asInt();
}
void syncRelay1()//synchronisation des entrées dans blynk
{
//Blynk.syncAll();/ne pas synchroniser v49 sinon le module se deconnecte en permanence
Blynk.syncVirtual(V9,V10,V12,V51,V53,V55,V57,V59,V61,V63,V65,V67,V69,V71,V73,V75,V77);
Serial.println("sync relay1");
}
void syncRelay()
{
//Blynk.syncAll();//ne pas synchroniser v49 sinon le module se deconnecte en permanence
Blynk.syncVirtual(V50,V52,V54,V56,V58,V60,V62,V64,V66,V68,V70,V72,V74,V76);
Serial.println("sync relay");
}
void showCurrentTime()
{
String CurrentDate = String(day()) + '-' + monthShortStr(month()) + '-' + year();
String CurrentTime = String(hour()) + ':' + minute() + ':' + second();
String formattedDate = CurrentDate + String(" | ") + CurrentTime;
Blynk.virtualWrite(V11,formattedDate);
}
void sendWifi()
{
Blynk.virtualWrite(1, map(WiFi.RSSI(), -105, -40, 0, 100) );
}
// Notice how there are no delays in the function below? Blynk works best that way.
void sendTemps()
{
sensors.requestTemperatures(); // Polls the sensors.
roomTemperature = sensors.getTempCByIndex(0); // Stores temperature. Change to getTempCByIndex(0) for celcius.
Blynk.virtualWrite(2, roomTemperature); // Send temperature to Blynk app virtual pin 2.
}
void loop()
{
Blynk.run();
timer.run();
}
thank you