Reset problem using RTC

Hi. I am having an issue related to RTC and ESP32 or ESP8266, both cases.
When i use this functions:
lastResetTime = String(hour()) + “:” + minute() + “:” + second();
lastResetDate = String(year()) + “/” + month() + “/” + day();

The board resets and i have the following stack for esp exception decoder but i do not understand what it means(at the end in order to not mess my questions).it has some indication of lines of code but no my code but libraries used.

I used to work with #include <TimeLib.h> but this issue appeared. But now i am using the library #include<WidgetRTC.h> and WidgetRTC rtc;, and it worked perfectly fine but a week after the problem starts again.

Is it a wrong way to use time, what other options exists? i read about unix time but i do not understand how to make it readable for humans.

Thanks in advance.

STACK:

Panic umm_malloc.cpp:229 umm_get_ptr_context

stack>>>
ctx: cont
sp: 3ffffa20 end: 3fffffc0 offset: 0000
3ffffa20: 00000000 3ffef4e0 3ffef720 00000030

@rodrigo5182 I’ve deleted your stack dump because it is meaningless to anyone without your sketch.

You should start by telling us which version of Blynk you are using, then posting your sketch (correctly formatted with triple backticks, not block quotes).

Pete.

Hi pete. I am using BLYNK 2.0 library version 1.0.1. I cannot insert my code here because it has 3000 lines.
thanks

I’d suggest that you work with a simplified version of your sketch, and read the Blynk IoT documentation regarding RTC, as the widgetRTC function isn’t used in Blynk IoT.

Pete.

Hi pete. I´ve manage to obtain de time and date having in mind my timezone with the library ezTime.h as explained in the documentation.
I´m having a trouble with saving this data. Previously using other libraries as explained before i saved te time and date separately as Strings and using EEPROM.get(1,my_date) and EEPROM.put(1,my_date), but with the new method it saves in a wrong way and i just get garbagge when using EEPROM.get().

is there any other way to do it by still using eeprom functions?
Thanks in advance.

Why do you need to use EEPROM?

Are you using the Edgent example?

Pete.

Hi pete. I need to use that in order to save the date and time because i have to register that.
I am not using Edgent, but i do not understand why you mention this if you could explain.
Thanks pete.

What do you mean by needing to register the date/time?
What hardware are you using?

Pete.

Pete
I need to save date and time because if the device turns off i lose info about when an event happened

The devices are nodemcu esp8266 and esp32.
I have used to save strings without problem, why is this different or not working ?

Thanks

How frequently were you writing data to EEPROM?

Pete.

Pete. I write once per week.

You’ll need to provide more info about how writing my_data to EEPROM once per week helps you if the device turns off.

Pete.

Pete. If the device turns off i do not loose the information if it is stored somehow. So, i think we are loosing focus on my question. My question is : i can store Strings without problem in EEPROM, ¿why am i getting garbagge using this method?
the method is:

#include<EEPROM.h>
#define EEPROM_SIZE 400
#include <ezTime.h>
Timezone local;
BlynkTimer timer;

BLYNK_CONNECTED() {
Blynk.sendInternal("utc", "time");      // Unix timestamp (with msecs)
Blynk.sendInternal("utc", "tz_rule");   // POSIX TZ rule
}

BLYNK_WRITE(InternalPinUTC) {
String cmd = param[0].asStr();
if (cmd == "time") {
    const uint64_t utc_time = param[1].asLongLong();
    UTC.setTime(utc_time / 1000, utc_time % 1000);
    Serial.print("Unix time (UTC): "); Serial.println(utc_time);
} else if (cmd == "tz_rule") {
    String tz_rule = param[1].asStr();
    local.setPosix(tz_rule);
    Serial.print("POSIX TZ rule:   "); Serial.println(tz_rule);
}
}

void printClock() {
//Serial.println("Time: " + local.dateTime());
lastResetDate_D=local.dateTime();
EEPROM.put(205, lastResetDate_D);
EEPROM.commit();
}

void setup() {
// Init Blynk, etc...
EEPROM.begin(EEPROM_SIZE);
 EEPROM.get(205,lastResetDate_D);
timer.setInterval(10000, printClock);
}

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

I my case i do it once a week or once per day but it does not matter, it is the same as this code, but differenet period of time.
Thanks

Blynk doesn’t use EEPROM, except with the Edgent example sketch.
If your method was working with Legacy and isn’t working now then maybe you’ve fried your EEPROM memory. It has a nominal 100k read/write operation live, but this can vary enormously.

You’re far better using SPIFFS or LittleFS, as these have proper wear levelling, error checking and file allocation table functions.

Pete.

Eu não uso mais o RTC nos meus projetos Blynk. Uso a Data e a Hora da internet.
Funciona muito bem e não precisa de nenhum hardware.
Assista o video em ESP8266 Data e Hora via Servidor NTP - IeC11 - YouTube
É muito fácil!

The issue isn’t really with RTC, it’s more about the way that the data is being stored in EEPROM

Pete.