Hello Everybody,
How do to pass date and time between tasks? I am using Arduino IDE 2.3.5 and ESP32S2. Below ai part of the programming:
// Create an handle for the queue
QueueHandle_t tarikhQueue = NULL;
QueueHandle_t haribulanQueue = NULL;
void readRTC(void *pvParameters)
{
String Haribulan;
char tarikh[10];
while(true)
{DateTime now = myRTC.now();
Haribulan = String(now.day()) + '/' + String(now.month()) +'/' +String(now.year());
Haribulan.toCharArray(tarikh, 10);
xQueueSend(tarikhQueue, (void *)tarikh, portMAX_DELAY);
xQueueSend(haribulanQueue, &Haribulan, portMAX_DELAY);
Serial.println(Haribulan); // i get 21/7/2026
Serial.println(tarikh); // I get 21/7/2026
}
}
void display(void *pvParameters){
String Haribulan;
char tarikh[10];
while(true){
xQueueReceive(tarikhQueue, (void *)tarikh, portMAX_DELAY);
Serial.println(tarikh); // I get 1073510226
xQueueReceive(haribulanQueue, &Haribulan, portMAX_DELAY);
Serial.println(Haribulan); // I get 1073510226
}
void setup() {
tarikhQueue = xQueueCreate(QUEUE_SIZE, sizeof(char)*10);
haribulanQueue = xQueueCreate(QUEUE_SIZE, sizeof(String));
xTaskCreatePinnedToCore(
display,
"display",
4096,
NULL,
1,
NULL,
ARDUINO_RUNNING_CORE
);
xTaskCreatePinnedToCore(
readRTC,
"readRTC",
4096,
NULL,
1,
NULL,
ARDUINO_RUNNING_CORE
);
}
The date is correct for sending the queue i.e. 21/7/2026 but after recieving it, I did not get the the date, I get 1073510226. Any suggestion?