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.
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.
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:
as this will be essential to save the values one way or another.
Johannes
Then you can look at node-red-contrib-cron-plus for generating the trigger.
though 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, but I don't know whether an issue got raised.
but a 15 min interval is still a 15 min interval... what ever the actual time is.
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.
@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.
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
.
[{"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":[]}]
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.