I want to use the inject node to send to value every 5 seconds but i'm not sure to to do it.
Send what value where?
I assume you mean you want to log the temp and RFID value every 5 seconds?
yes, and then insert it into my database.
So the answer is to store the values in context then in a separate flow, fire the inject to gather the context values and send to database every 5 secs.
The question becomes - why? what if the values stay the same for 8 hours? You would be logging 5760 unnecessary rows of data.
I see thank you. I'm not necessarily gonna use it for anything just trying to how to use database in node red
How often are the values coming in from MQTT?
It just keeps coming rapidly. I tried using the delay function in my Arduino code but that doesn't work since it will also delay my callback function.
Does the values change everytime or do you get many repeat values?
An RBE node will take care of repeated values.
Also, if the arudino coding was done by you, then you could check for value change before publishing.
I used the DHT sensor to measure the temperature and the RFID would just be the same value. So the temperature shouldn't be a repeating value
Add a Delay node configured to Rate Limit mode in the wire to the database (or to the Function). Configure it as below to only pass one message every 5 seconds and to Drop Intermediate Messages.
That should work, I'll give it a try. Thanks