Multi devices eventor

I guess it depends on your reasons for doing it.
Mechanical thermostats that use bi-metallic strips have built-in hysteresis because of the way they work and their lag in responding to changes. There is very little to go wrong, so are very reliable. We have one in our house that is over 25 years old and still works perfectly.

Obviously it can’t be used to turn the heating on/off remotely or set the temperature remotely.

Any system is only as good as it’s weakest part (which for a smart system includes the code it’s running) and the more components you have the greater the risk of failure.

Pete.

I understand, I still want to try, since my goal is to learn, and I also see the advantage that in the event of a long power cut, a programmer based on esp8266 will reset itself on the PSTN time.

Can the RTC time be based on the server? in this way there is a power cut and a disconnection from the internet the program will restore the RTC time

Which library do you recommend for me to do this? (in 24 hour format)

You can use a hardware RTC with built-in battery backup.

Yes, but with local server how are you going to ensure that this is correct?

TimeLib

Pete.

Because it’s either always on or internet based I believe

I’m thinking of doing something like this:

If time = 07.00 → relay on
delay 18 hours
relay off

does it work well?

void setup1
{
  if (hour = 7)
     digitalWrite (15, LOW);
     delay(28000000)
     digitalWrite(15, HIGH);
}

    void setup2
    {
      if (hour = 7)
         digitalWrite (15, LOW);
         delay(43200000)
         digitalWrite(15, HIGH);
    }

delay(28000000) : the best is to put a delay or to call 15:00?

Only always on in a power cut if you have a UPS big enough to keep it running.
If you’ve set the Pi up to synchronise to a NTP server and set the timezone correctly then it will synchronise when an internet connection becomes available, but you could do the same for your ESP device too.

No, not really.

Might be best to stick with the mechanical controller you already have.

Pete.

Never !

Does this one look good to you?

#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <TimeLib.h>
#include <WidgetRTC.h>

char auth[] = "xxx";
char ssid[] = "xxxx";
char pass[] = "xxx";

BlynkTimer timer;

WidgetRTC rtc;


BLYNK_CONNECTED() {
  // Synchronize time on connection
  
}

int OnHours = 7;
int OffHours = 25;


void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass, IPAddress(10, 3, 141, 1), 8080);
  rtc.begin();

  setSyncInterval(800);

  timer.setInterval(1000L, clockDisplay);
  timer.setInterval(1000L, cycle1);
}

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

void clockDisplay()
{

  String currentTime = String(hour()) + ":" + minute() + ":" + second();
  String currentDate = String(day()) + " / " + month() + " / " + year();
  Serial.print("Current time: ");
  Serial.print(currentTime);
  Serial.print(" ");
  Serial.print(currentDate);
  Serial.println();

  // Send time to the App
  Blynk.virtualWrite(V1, currentTime);
  // Send date to the App
  Blynk.virtualWrite(V2, currentDate);
}

void cycle1()
{

  int Hours = second();
  if (Hours == OnHours)
  {
    Serial.print("debut de cylcle ");
    digitalWrite (15, HIGH);
    Serial.println ("lampe on");
  }

  if (Hours == OffHours)
  {
    Serial.print("fin de cylcle ");
    digitalWrite (15, LOW);
    Serial.println ("lampe off");
  }


}

No, it doesn’t.

I’m really not going to engage in this conversation any further, but I’ll leave you with a few pointers regarding the glaring problems…

Overlapping timers…

25 hour days…

Hours = second() ???..

Hard-coded start/stop times…

Blocking code so that your heating won’t work independently of your Blynk local server…

Not using sprintf to sort out your time formatting…

Good luck!

Pete.

As I said before I use seconds to do my tests, I can’t see myself waiting 18 to see if it works.

I don’t want they work without server

What do you mean? I don’t understand

I will find out about the differences between the two.

Pete.

1 Like