Run flow every 5 minutes

1,223 views
Skip to first unread message

Daniel Felipe

unread,
Jan 25, 2017, 9:54:42 AM1/25/17
to Node-RED
Hi guys,

So, Im trying to use the Node Red to get data from my Arduino using MQTT and input the data in a Database.
How can I configure to run the flow every 5 minutes to get the data and input to the database?
Or is this configurable using the MQTT or arduino code?

Thanks.

Daniel

Zenofmud

unread,
Jan 25, 2017, 11:09:38 AM1/25/17
to node...@googlegroups.com
in your Arduino sketch, have the loop run every 5 minutes or what ever. Just add a delsy
# this will delay for 15 minutes
 delay(1000*60*15);

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/8554d67f-f7a3-4cdf-a125-c2aec773205d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Arnaud

unread,
Jan 26, 2017, 4:03:14 AM1/26/17
to Node-RED
Hello,

For recurrent task, I use the node-red-contrib-cron node (https://flows.nodered.org/node/node-red-contrib-cron). It works perfectly for reccurent flow every minute/5minutes/day/month, etc... like a cron on Linux !

Arnaud

Mark Setrem

unread,
Jan 26, 2017, 4:54:15 AM1/26/17
to Node-RED
If you want to do it node-red and you want to initiate a flow every 5 minutes you don't need the node Arnaud suggests.

The "Inject" node which is already included uses cron for the  "interval between times" and "at a specific time" options and has a setting for 5 minutes.  

But personally I'd do this on the arduino

Mario Bianchi

unread,
Jan 26, 2017, 8:09:43 AM1/26/17
to Node-RED
Hi Daniel,

The MQTT node "subscribes" to an MQTT source and your flow will be just be called every time there is new data there. You dont need to do anything to collect / read or poll the data.

You can try a very simple flow with one MQTT and a debug node and you will see it is executed every time there new data.

Now if for any other reason you need to rate limit the data every 5 minutes, you can use a delay node that can delay or rate limit your flows.

The other way to rate limit this is to contro this from the publishing device, what is the Arduino in your case.

Good luck !


Reply all
Reply to author
Forward
0 new messages