Local Server RTC problem

Hi everyone,

My blynk project has RTC widget but i cant get correct time (espicially hour)… My local server runs in Rasp pi3 and its localisitaon setting correct (GMT+3, Europe, İstanbul). My RP3 time is correct.

I chose same GMT+3 in RTC widget but my code always give me wrong hour data. It is always minus 1. Correct time (for example) 17:00 my blynk widget give to me 16:00 …

When I rise up GMT+4 then its plus 2…when correct time (for example) 17:00, it gives me 19:00 :joy:
We couldnt meet in the middle point…unfortunatelly…

here is the code;

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <TimeLib.h>
#include <WidgetRTC.h>

#define blue    "#04C0F8"
#define red "#D3435C"
#define white   "#FFFFFF"

String CorrectedTime;
float RoomTemp;                                     
float Humidity;                                          
boolean RelayPosition;                                
int set;                                            
int WakeUpTime;                                     
int EcoTime;                                     
int ComingHome;                                       
int WeekendWakeUpTime;                            
const int Relay = 5;
char auth[] = "f6d57acf8f7a44d29e74a93189d950d1";
char ssid[] = "SUPERONLINE_WiFi_0161";
char pass[] = "xxxxxxx";

SimpleTimer timer;                                    
WidgetRTC rtc;                                        

#include <SPI.h>                                      
#include <nRF24L01p.h>                                


void Updates()                                  
{
  Blynk.virtualWrite(V4, Relay);                
  Blynk.virtualWrite(V2, set);                      
}

void TimeFunction()                                
{
  int HourNumber = hour();

  if (HourNumber == 24) {
HourNumber = 0;
  }
  String ShowHour =   String(HourNumber, DEC);
  int HourLenght = ShowHour.length();
  if (HourLenght == 1) {
ShowHour = "0" + ShowHour;
  }
  String ShowMinute = String(minute(), DEC);
  int MinuteLength = ShowMinute.length();
  if (MinuteLength == 1) {
ShowMinute = "0" + ShowMinute;
  }
  String ShowSecond = String(second(), DEC);
  int SecondLength = ShowSecond.length();
  if (SecondLength == 1) {
ShowSecond = "0" + ShowSecond;
  }
  String ShowDay = String(day(), DEC);
  int DayLength = ShowDay.length();
  if (DayLength == 1) {
ShowDay = "0" + ShowDay;
  }
  String ShowMonth = String(month(), DEC);
  int MonthLength = ShowMonth.length();
  if (MonthLength == 1) {
ShowMonth = "0" + ShowMonth;
  }
  String Weekday;
  int DayCorrection = -1;
  if (weekday() == 1)
  {
DayCorrection =  6;                                     // For Sunday. Time library is day 1 and Blynk is day 7
  }
  if ((weekday() + DayCorrection) == 1)
  {
Weekday = "MONDAY";
  }
  else if ((weekday() + DayCorrection) == 2)
  {
Weekday = "TUESDAY";
  }
  else if ((weekday() + DayCorrection) == 3)
  {
Weekday = "WEDNESDAY";
  }
  else if ((weekday() + DayCorrection) == 4)
  {
Weekday = "THURSDAY";
  }
  else if ((weekday() + DayCorrection) == 5)
  {
Weekday = "FRIDAY";
  }
  else if ((weekday() + DayCorrection) == 6)
  {
Weekday = "SATURDAY";
  }
  else
  {
Weekday = "SUNDAY";
  }
  CorrectedTime = ShowHour + ":" + ShowMinute + ":" + ShowSecond + "  " + ShowDay + "." + ShowMonth + "." + year() + "  " + Weekday;
  Blynk.virtualWrite(V21, CorrectedTime);
  Blynk.virtualWrite(V24, hour());
}

nRF24L01p receiver(D8, D4);                          // CSN = D8, CE = D4
boolean ManuelMode;                                  // Start with "auto" mode
int eco     = 19;                                    // eco time from 08:00 to 18:00 
int normal  = 23;                                    // normal time from 18:00 to 24:00 
int night    = 19;                                   // night time from 24:00 to 06:00 

void RF()
{
  while (receiver.available())                       // if any temp data comes
  {
receiver.read();                                 // receive them 
receiver.rxPL(RoomTemp);
receiver.rxPL(Humidity);

Blynk.virtualWrite(V1, RoomTemp);                // then send them to app                
Blynk.virtualWrite(V0, Humidity);                       

if (set > RoomTemp)                              // if room temp lower than set value..
{
  digitalWrite(Relay, HIGH);                      // turn on the heater
  RelayPosition = 1023;
  Blynk.setProperty(V4, "label", "ON");
}
else
{
  digitalWrite(Relay, LOW);
  RelayPosition = 0;
  Blynk.setProperty(V4, "label", "OFF");
}
  }
}

void WeeklySchedule()                                     // Weekly program
{
  RF();                                                   // first listen to transmitter (nRF)
  if (!ManuelMode)                                        // if manuel mode off
  {
int DayCorrection = -1;                               // correct the day
if (weekday() == 1)               
{
  DayCorrection =  6;                                 // For SUNDAY, Time library is day 1 and Blynk is day 7
}
if ((weekday() + DayCorrection) <= 5)                  // if it is workday
{
  if (hour() < WakeUpTime)                             // when the time between 24:00 - 06:00 
  {
    set = night;                                       // set the temp to night
    Blynk.virtualWrite(V3, "Night");
  }
  else if (hour() < EcoTime)                            // when the time between 06:00 - 08:00
  {
    set = normal;                                       // set the temp to normal
    Blynk.virtualWrite(V3, "Normal");
  }
  else if (hour() < ComingHome - 1)                     // when the time between 08:00 - 18:00
  {
    set = eco;                                          // set the temp to eco
    Blynk.virtualWrite(V3, "Eco");

  }
  else                                                  // when the time between 18:00 - 24:00 
  {
    set = normal;
    Blynk.virtualWrite(V3, "Normal");
  }
}
else if ((weekday() + DayCorrection) > 5)               // if weekend
{
  if (hour() <= WeekendWakeUpTime - 1)                  // when the time between 24:00 - 07:00 
  {
    set = night;                                         // set the temp to night
    Blynk.virtualWrite(V3, "Weekend Night");
  }
  else                                                  // when the time between  07:00 - 24:00 
  {
    set = normal;                                       // set the temp to normal
    Blynk.virtualWrite(V3, "Weekend Normal");
  }
}
  }
  else                                                    // if manuel mode on...
  {
RF();                                                 // run for the manuel set temp
  }
}
BLYNK_WRITE(V10)                                        
{
  int pindegeri = param.asInt();                        
  if (pindegeri > 18)                                   // if set temp higher then 18 celcius by the silder manually
  {
set = pindegeri;
ManuelMode = true;                                 // Manuel Mode will be on
Blynk.setProperty(V5, "color", red);
Blynk.virtualWrite(V5, "MANUEL");
Blynk.setProperty(V10, "label", "MANUEL");
Blynk.virtualWrite(V2, set);
  }
  else                                                    // if set temp equal the 18 celcius heater runs in auto mode with pre def set temp values in void_setup 
  {
ManuelMode = false;                                  
Blynk.setProperty(V5, "color", blue);
Blynk.virtualWrite(V5, "AUTO");
Blynk.setProperty(V10, "label", "AUTO");
  }
}



BLYNK_WRITE(V11)
{
  int pinValue = param.asInt();
  if (param.asInt() < EcoTime)
  {
WakeUpTime = pinValue;
Blynk.virtualWrite(V15, WakeUpTime);
Blynk.virtualWrite(V9, String("night ends on: ") + WakeUpTime);
  }
  else
  {
WakeUpTime = EcoTime - 2;
Blynk.virtualWrite(V15, WakeUpTime);
Blynk.virtualWrite(V9, String("night ends on: ") + WakeUpTime);
  }
}

BLYNK_WRITE(V12)
{
  int pinValue = param.asInt();
  if (param.asInt() < ComingHome)
  {
EcoTime = pinValue;
Blynk.virtualWrite(V16, EcoTime);
Blynk.virtualWrite(V9, String("Eco time starts on: ") + EcoTime);
  }
  else
  {
EcoTime = WakeUpTime + 2;
Blynk.virtualWrite(V16, EcoTime);
Blynk.virtualWrite(V9, String("Eco time starts on: ") + EcoTime);
  }
}

BLYNK_WRITE(V13)
{
  ComingHome = param.asInt();
  Blynk.virtualWrite(V17, ComingHome);
  Blynk.virtualWrite(V9, String("Coming Home on: ") + ComingHome);
}

BLYNK_WRITE(V14)
{
  WeekendWakeUpTime = param.asInt();
  Blynk.virtualWrite(V18, WeekendWakeUpTime);
  Blynk.virtualWrite(V9, String("weekend night ends: ") + WeekendWakeUpTime);
}

void setup()
{
  Blynk.virtualWrite(V3, "Starting...");
  WakeUpTime = 6;                                   
  Blynk.virtualWrite(V15, WakeUpTime);
  EcoTime = 8;                                      
  Blynk.virtualWrite(V16, EcoTime);
  ComingHome   = 18;                                
  Blynk.virtualWrite(V17, ComingHome);
  WeekendWakeUpTime = 8;                          
  Blynk.virtualWrite(V18, WeekendWakeUpTime);

  Blynk.setProperty(V5, "color", blue);
  Blynk.virtualWrite(V5, "Auto");
  Blynk.setProperty(V10, "label", "Auto");

  pinMode (Relay, OUTPUT);                           
  digitalWrite (Relay, LOW);                         
  RelayPosition = false;                              
  ManuelMode = false;                           
  Serial.begin(9600);                               
  Blynk.begin(auth, ssid, pass, IPAddress(192, 168, 1, 50));
  rtc.begin();                                      
  SPI.begin();                                     
  timer.setInterval(2000L, Updates);          
  SPI.setBitOrder(MSBFIRST);
  receiver.channel(90);
  receiver.RXaddress("Tamer");       
  receiver.init();
  timer.setInterval(3000L, WeeklySchedule);        
  timer.setInterval(5000L, TimeFunction);
}
BLYNK_WRITE(V6)                                           //Normal value change option 
{
  int pinValue = param.asInt();
  if (param.asInt() > 18)                                 
  {
normal = pinValue;                                    
Blynk.setProperty(V19, "color", red);
Blynk.virtualWrite(V19, String("Normal RoomTemp: ") + normal);
  }
  else
  {
normal = 23;                                          
Blynk.setProperty(V19, "color", red);
Blynk.virtualWrite(V19, String("Normal RoomTemp: ") + normal);
  }
}

BLYNK_WRITE(V7)                                            //eco value change option                                       
{
  int pinValue = param.asInt();
  if (param.asInt() > 18)                                 
  {
eco = pinValue;                                       
Blynk.setProperty(V19, "color", blue);
Blynk.virtualWrite(V19, String("Eco RoomTemp: ") + eco);
  }
  else
  {
eco = 19;                                            
Blynk.setProperty(V19, "color", blue);
Blynk.virtualWrite(V19, String("Eco RoomTemp: ") + eco);
  }
}
BLYNK_WRITE(V8)                                           
{
  int pinValue = param.asInt();
if (param.asInt() > 18)                                 
  {
eco = pinValue;                                       
Blynk.setProperty(V19, "color", white);
Blynk.virtualWrite(V19, String("Night RoomTemp: ") + night);
  }
  else
  {
eco = 19;                                            
Blynk.setProperty(V19, "color", white);
Blynk.virtualWrite(V19, String("Night RoomTemp: ") + night);
  }
}


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

Here is my info s…

 1. The Blynk library version you are using.  **(0.4.6)**
 2. Android or iOS and the version of the OS. **(Android 5.0)**
 3. Server type, Local or Cloud based. **(Local Server)**
 4. If local server, which version you are using. **0.28.3**
 5. How you powering the MCU. **(with USB)**
 6. Has the MCU ever connected to a Blynk server (Cloud or local). **(yes)**
 7. The IDE you areusing, including the version number. **(Arduino 1.8.0)**
 8. The settings you have in the IDE for the MCU. **(NodeMCU 1.0 (ESP-12E Module)**
 9.The Arduino core version you are using. **(1.8.0)**
10. The make and model of your phone. **(Samsung Note 3)**

here is the QR

what must i do?

1 Like

GMT + 3 gives you GMT +2
GMT + 4 gives you GMT +4

Correct?

I know Turkey has strange daylight saving time. Have you abandoned it at present?

Maybe choose a different location in the world where Android understands DST.

Yes correct…

You know Turkey’s daylight saving :grin: we dont understand too…

İ will try…

I changed to timezone from Istanbul to Baghdat and its ok now…

than please mark the topic as solved, choosing the correct category.

thanks!