Specific Time Interval Data Input Into Database

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

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. 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.

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

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.

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

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

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

    { 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.

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