Hi! i'm working on Node Red and ESP32, i have my mqtt node at node red that receives values constantly, and keeping that values in a data base. I want to send the mqtt message to de DB every 5 minutes. I've tried using a delay, but it just waits the first time, and didn't find anywhere if it can be restarted. I've tried using a trigger, but directly doesn't work, like if was not there. Could you help me? Thanks in advance.
(sorry for my english)
Here is my code:
[{"id":"e3ad4473.cafa78","type":"tab","label":"Flow 5","disabled":false,"info":""},{"id":"c8d41688.909c08","type":"mqtt in","z":"e3ad4473.cafa78","name":"","topic":"/local/CT/00:00h","qos":"2","datatype":"auto","broker":"a1041d14.0ae6d","x":320,"y":100,"wires":[["bc0c15cc.ae3888"]]},{"id":"ba09b518.180ab8","type":"mysql","z":"e3ad4473.cafa78","mydb":"9ef090e5.cb6f7","name":"","x":1110,"y":320,"wires":[["c706ef81.119a6"]]},{"id":"bc0c15cc.ae3888","type":"function","z":"e3ad4473.cafa78","name":"MQTT to DB","func":"var newMsg1 = { payload: msg.payload };\nvar newMsg2 = { payload: msg.payload };\nvar newMsg3 = { payload: msg.payload };\nnewMsg1.topic = \"INSERT INTO `DB_ConsumosVivienda`.`Tabla` SET `Consumo Wh` = '\"+newMsg1.payload+\"'\"; \nnewMsg3.topic = \"UPDATE `DB_ConsumosVivienda`.`Tabla` SET `Hora` = '\"+newMsg3.payload+\"'\";\nnewMsg2.topic = \"UPDATE `DB_ConsumosVivienda`.`Tabla` SET `Fecha` = '\"+newMsg2.payload+\"'\"; \nreturn [newMsg1, newMsg2, newMsg3];\n\n","outputs":3,"noerr":0,"x":630,"y":100,"wires":[["318062c5.c5907e"],[],[]]},{"id":"59aa34c0.05845c","type":"moment","z":"e3ad4473.cafa78","name":"Fecha","topic":"","input":"","inputType":"date","inTz":"Europe/Madrid","adjAmount":0,"adjType":"days","adjDir":"add","format":"DD/MM/YYYY","locale":"es_ES","output":"payload","outputType":"msg","outTz":"Europe/Madrid","x":450,"y":680,"wires":[["bc0c15cc.ae3888"]],"info":"msg.payload = newDate(); \nmoment().format(\"DD,MM,YYYY\"); \nreturn msg;"},{"id":"37b48da4.ee0792","type":"moment","z":"e3ad4473.cafa78","name":"Hora","topic":"","input":"","inputType":"date","inTz":"Europe/Madrid","adjAmount":0,"adjType":"days","adjDir":"add","format":"LT","locale":"es_ES","output":"payload","outputType":"msg","outTz":"Europe/Madrid","x":450,"y":740,"wires":[["bc0c15cc.ae3888"]],"info":"msg.payload = newDate(); \nmoment().format(\"DD,MM,YYYY\"); \nreturn msg;"},{"id":"c706ef81.119a6","type":"debug","z":"e3ad4473.cafa78","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1350,"y":320,"wires":[]},{"id":"14fe539d.0cb5dc","type":"delay","z":"e3ad4473.cafa78","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":860,"y":200,"wires":[[]]},{"id":"65d7db8e.de33d4","type":"inject","z":"e3ad4473.cafa78","name":"","topic":"","payload":"","payloadType":"date","repeat":"0.1","crontab":"","once":true,"onceDelay":0.1,"x":290,"y":720,"wires":[["59aa34c0.05845c","37b48da4.ee0792"]]},{"id":"318062c5.c5907e","type":"trigger","z":"e3ad4473.cafa78","op1":"","op2":"0","op1type":"pay","op2type":"str","duration":"-1","extend":false,"units":"min","reset":"","bytopic":"all","name":"","x":890,"y":100,"wires":[["ba09b518.180ab8"]]},{"id":"a1041d14.0ae6d","type":"mqtt-broker","z":"","name":"BrokerLocal","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"9ef090e5.cb6f7","type":"MySQLdatabase","z":"","name":"","host":"127.0.0.1","port":"3306","db":"DB_ConsumosVivienda","tz":""}]