# Send data at specific interval of time

**URL:** <https://discourse.nodered.org/t/send-data-at-specific-interval-of-time/35574>\
**Category:** Developing Nodes\
**Created:** [9 November 2020 04:48 UTC](https://discourse.nodered.org/t/send-data-at-specific-interval-of-time/35574 "2020-11-09T04:48:30Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![maa1](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@maa1](https://discourse.nodered.org/u/maa1)\
**Post date:** [9 November 2020 04:48 UTC](https://discourse.nodered.org/t/send-data-at-specific-interval-of-time/35574/1 "2020-11-09T04:48:30Z")

</div>

Hello,

I'm pulling the data from my device at a 1-second interval and I want to send it to the database at a specific time interval of the day i.e. of 15 minutes.

Please help me.

---

<div class="post-metadata">

**Author:** ![JGKK](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jgkk/32/18515_2.png) [@JGKK](https://discourse.nodered.org/u/JGKK)\
**Post date:** [9 November 2020 06:10 UTC](https://discourse.nodered.org/t/send-data-at-specific-interval-of-time/35574/2 "2020-11-09T06:10:12Z")

</div>

Hello,  
So every 15 minutes you want to send data somewhere. Do you want to send a collection of all the data you received in that time slot or do you want to send something like an average of all the data received within the last 15 minutes?  
Either way you could start by looking at the guide on how to work with context storage:

> **[Working with context : Node-RED](https://nodered.org/docs/user-guide/context)**

as this will be essential to save the values one way or another.

Johannes

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [9 November 2020 07:17 UTC](https://discourse.nodered.org/t/send-data-at-specific-interval-of-time/35574/3 "2020-11-09T07:17:51Z")

</div>

Then you can look at node-red-contrib-cron-plus for generating the trigger.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [9 November 2020 09:07 UTC](https://discourse.nodered.org/t/send-data-at-specific-interval-of-time/35574/4 "2020-11-09T09:07:21Z")

</div>

though the default inject node can also mange to handle every 15 minutes...

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [9 November 2020 10:10 UTC](https://discourse.nodered.org/t/send-data-at-specific-interval-of-time/35574/5 "2020-11-09T10:10:32Z")

</div>

> [@dceejay](#):
>
> the default inject node can also mange to handle every 15 minutes

There is an ongoing issue with that node (unless it has been sorted) that if the system time changes after node red has started that it loses sync as it does not notice that the clock has changed. This can easily happen on boot on something like a pi with wifi if node red starts up before the wifi gets going, so the first time sync happens after the inject node has started up. There was discussion of it [here](https://discourse.nodered.org/t/inject-node-runs-late-sometimes/30365), but I don't know whether an issue got raised.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [9 November 2020 10:20 UTC](https://discourse.nodered.org/t/send-data-at-specific-interval-of-time/35574/6 "2020-11-09T10:20:29Z")

</div>

but a 15 min interval is still a 15 min interval... what ever the actual time is.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [9 November 2020 10:27 UTC](https://discourse.nodered.org/t/send-data-at-specific-interval-of-time/35574/7 "2020-11-09T10:27:42Z")

</div>

I assumed from the wording of @maa1's first post that the intervals were wanted on the hour and every 15 mins, rather than just at 15 minute intervals. It is that aspect of the inject node that can get out of sync. I may have misinterpreted the question though.

---

<div class="post-metadata">

**Author:** ![maa1](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@maa1](https://discourse.nodered.org/u/maa1)\
**Post date:** [10 November 2020 01:42 UTC](https://discourse.nodered.org/t/send-data-at-specific-interval-of-time/35574/8 "2020-11-10T01:42:04Z")

</div>

@Colin You have correctly understood the question/ requirement.

@dceejay, @JGKK  
I'll put an example for better understanding  
I'm pulling data at the 1-second interval and I want to send the 1st data to database at 10:00 AM then at 10:15 AM likewise at 15-minute interval throughout the day and every day. In this scenario even if the pi gets rebooted or flow is redeployed, etc. still data will be sent at the specified interval only.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [10 November 2020 08:59 UTC](https://discourse.nodered.org/t/send-data-at-specific-interval-of-time/35574/9 "2020-11-10T08:59:47Z")

</div>

You can solve the problem like this. Make sure the sample messages and the messages from the cron-plus node have different topics (I have assumed "sample" and "trigger" in the example. Feed them into a Join node configured as in the flow and then each time the trigger arrives it will pass on a message with the sample value in `msg.payload.sample`.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/1/81d2190d1051635d3c97d60a985d634b76ead860.png)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/a/fa3c149b9386ea5db1280c3c48a80def488ca53a.png)

```auto
[{"id":"954d8e6e.03c33","type":"comment","z":"bdd7be38.d3b55","name":"1 second samples in here with topic \"sample\"","info":"","x":180,"y":4440,"wires":[]},{"id":"f7ae8f89.81d6e","type":"comment","z":"bdd7be38.d3b55","name":"15 minute trigger from cron-plus in here with topic \"trigger\"","info":"","x":220,"y":4580,"wires":[]},{"id":"76d77fd4.74299","type":"inject","z":"bdd7be38.d3b55","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"sample","payload":"","payloadType":"date","x":390,"y":4480,"wires":[["ab235bf3.695a08"]]},{"id":"f2171825.e16618","type":"inject","z":"bdd7be38.d3b55","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"trigger","payload":"true","payloadType":"bool","x":360,"y":4540,"wires":[["ab235bf3.695a08"]]},{"id":"ab235bf3.695a08","type":"join","z":"bdd7be38.d3b55","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":550,"y":4520,"wires":[["39c9d8e2.61897"]]},{"id":"39c9d8e2.61897","type":"switch","z":"bdd7be38.d3b55","name":"topic == trigger?","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"trigger","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":700,"y":4520,"wires":[["2ebd3cfe.b32bcc"]]},{"id":"2ebd3cfe.b32bcc","type":"debug","z":"bdd7be38.d3b55","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":750,"y":4600,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [24 November 2020 08:59 UTC](https://discourse.nodered.org/t/send-data-at-specific-interval-of-time/35574/10 "2020-11-24T08:59:59Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
