Send a data on a specific time from NodeMCU to Node-Red via MQTT using RTC

loop()? You mean code in the loop() function, don't need it. All the code setup is done in setup().

The loop function above is how to use loop() under freeRTOS.