# Specific Time Interval Data Input Into Database

**URL:** <https://discourse.nodered.org/t/specific-time-interval-data-input-into-database/42209>\
**Category:** General\
**Created:** [7 March 2021 17:53 UTC](https://discourse.nodered.org/t/specific-time-interval-data-input-into-database/42209 "2021-03-07T17:53:45Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ayozzet](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ayozzet/32/38386_2.png) [@ayozzet](https://discourse.nodered.org/u/ayozzet)\
**Post date:** [7 March 2021 17:53 UTC](https://discourse.nodered.org/t/specific-time-interval-data-input-into-database/42209/1 "2021-03-07T17:53:45Z")

</div>

Hi. I'm sorry because I'm too new in Node Red. I have a lot data coming through my network (MQTT) which is about 10-20 data per seconds (100ms-50ms per data). But here, I just want to get the data into database (influxDB) EXACTLY 1 data per 100ms. No matter how much data I got, I just want to get one data within 100ms cycle. How do I want to do that? I tried interval-length function but I don't really understand it.

As conclusion, I want to display the data in Grafana such like...  
2021-03-08 02:00:20.700 ---\> 500  
2021-03-08 02:00:20.800 ---\> 540  
2021-03-08 02:00:20.900 ---\> 530  
2021-03-08 02:00:21.000 ---\> 450  
2021-03-08 02:00:21.100 ---\> 510

All the data have time interval exactly 100ms

---

<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:** [7 March 2021 18:17 UTC](https://discourse.nodered.org/t/specific-time-interval-data-input-into-database/42209/2 "2021-03-07T18:17:26Z")

</div>

Welcome to the forum. You will never get them _exactly_ every 100msec but you can get them approximately every 100 by using a Delay node set to Rate Limit mode at 10 messages per second and to discard intermediate messages.

As a beginner I recommend watching this playlist: [Node-RED Essentials](https://www.youtube.com/playlist?list=PLyNBB9VCLmo1hyO-4fIZ08gqFcXBkHy-6). The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

---

<div class="post-metadata">

**Author:** ![ayozzet](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ayozzet/32/38386_2.png) [@ayozzet](https://discourse.nodered.org/u/ayozzet)\
**Post date:** [7 March 2021 18:34 UTC](https://discourse.nodered.org/t/specific-time-interval-data-input-into-database/42209/3 "2021-03-07T18:34:26Z")

</div>

Can I just delay or customize the data to put into my database in every 100ms?

---

<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:** [7 March 2021 18:53 UTC](https://discourse.nodered.org/t/specific-time-interval-data-input-into-database/42209/4 "2021-03-07T18:53:37Z")

</div>

If you use the influx batch node you can give it the timestamp, so you could lie about the actual time. But why would you want to intentionally record inaccurate timestamps?  
If you want to show it in a table, for example, you could put in a row for each of your 100ms timestamps and put in the latest sample at that time.

---

<div class="post-metadata">

**Author:** ![ayozzet](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ayozzet/32/38386_2.png) [@ayozzet](https://discourse.nodered.org/u/ayozzet)\
**Post date:** [8 March 2021 14:36 UTC](https://discourse.nodered.org/t/specific-time-interval-data-input-into-database/42209/5 "2021-03-08T14:36:40Z")

</div>

Thanks @Colin ... you are giving the best solution.. at least improve my data acquisition..

---

<div class="post-metadata">

**Author:** ![ayozzet](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ayozzet/32/38386_2.png) [@ayozzet](https://discourse.nodered.org/u/ayozzet)\
**Post date:** [8 March 2021 14:37 UTC](https://discourse.nodered.org/t/specific-time-interval-data-input-into-database/42209/6 "2021-03-08T14:37:59Z")

</div>

Is there any kind of tutorial to study about influx batch... because i think i need it..

---

<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:** [8 March 2021 16:01 UTC](https://discourse.nodered.org/t/specific-time-interval-data-input-into-database/42209/7 "2021-03-08T16:01:24Z")

</div>

> [@ayozzet](#):
>
> Is there any kind of tutorial to study about influx batch.

Not that I know of. If you read the help text carefully it is explained there, though it is a little involved. An example payload for writing one sample might be

```auto
  [
    { measurement: "myMeasurement", 
      fields: {field1: value1, field2: value2}.
      tags: {tag1: "thetag"},
      timestamp: thetimestamp}
  ]

```

If you supply the timestamp as a javascript Date object then I think that just works, if you supply it as a milliseconds timestamp then go into the Advanced Settings and set the time precision to milliseconds.  
Also set the Retention policy there if you are not using the default.

---

<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:** [22 March 2021 16:01 UTC](https://discourse.nodered.org/t/specific-time-interval-data-input-into-database/42209/8 "2021-03-22T16:01:46Z")

</div>

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