# Using inject node

**URL:** <https://discourse.nodered.org/t/using-inject-node/42391>\
**Category:** General\
**Created:** [10 March 2021 08:57 UTC](https://discourse.nodered.org/t/using-inject-node/42391 "2021-03-10T08:57:01Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Parit](https://avatars.discourse-cdn.com/v4/letter/p/db5fbb/32.png) [@Parit](https://discourse.nodered.org/u/Parit)\
**Post date:** [10 March 2021 08:57 UTC](https://discourse.nodered.org/t/using-inject-node/42391/1 "2021-03-10T08:57:01Z")

</div>

I want to use the inject node to send to value every 5 seconds but i'm not sure to to do it.

 ![Node red](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/5/952bbc42df090989da5a2eb6b867c163ffdd6e92.jpeg)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [10 March 2021 09:07 UTC](https://discourse.nodered.org/t/using-inject-node/42391/2 "2021-03-10T09:07:28Z")

</div>

Send what value where?

I assume you mean you want to log the temp and RFID value every 5 seconds?

---

<div class="post-metadata">

**Author:** ![Parit](https://avatars.discourse-cdn.com/v4/letter/p/db5fbb/32.png) [@Parit](https://discourse.nodered.org/u/Parit)\
**Post date:** [10 March 2021 09:21 UTC](https://discourse.nodered.org/t/using-inject-node/42391/3 "2021-03-10T09:21:08Z")

</div>

yes, and then insert it into my database.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [10 March 2021 09:31 UTC](https://discourse.nodered.org/t/using-inject-node/42391/4 "2021-03-10T09:31:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Parit](https://avatars.discourse-cdn.com/v4/letter/p/db5fbb/32.png) [@Parit](https://discourse.nodered.org/u/Parit)\
**Post date:** [10 March 2021 09:37 UTC](https://discourse.nodered.org/t/using-inject-node/42391/5 "2021-03-10T09:37:13Z")

</div>

I see thank you. I'm not necessarily gonna use it for anything just trying to how to use database in node red

---

<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:** [10 March 2021 10:54 UTC](https://discourse.nodered.org/t/using-inject-node/42391/6 "2021-03-10T10:54:27Z")

</div>

How often are the values coming in from MQTT?

---

<div class="post-metadata">

**Author:** ![Parit](https://avatars.discourse-cdn.com/v4/letter/p/db5fbb/32.png) [@Parit](https://discourse.nodered.org/u/Parit)\
**Post date:** [10 March 2021 13:22 UTC](https://discourse.nodered.org/t/using-inject-node/42391/7 "2021-03-10T13:22:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [10 March 2021 13:27 UTC](https://discourse.nodered.org/t/using-inject-node/42391/8 "2021-03-10T13:27:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Parit](https://avatars.discourse-cdn.com/v4/letter/p/db5fbb/32.png) [@Parit](https://discourse.nodered.org/u/Parit)\
**Post date:** [10 March 2021 13:29 UTC](https://discourse.nodered.org/t/using-inject-node/42391/9 "2021-03-10T13:29:27Z")

</div>

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

---

<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:** [10 March 2021 14:56 UTC](https://discourse.nodered.org/t/using-inject-node/42391/10 "2021-03-10T14:56:12Z")

</div>

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.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/3/a3b2a746360204275aa3f394b1d0b7a8100fc336.png)

---

<div class="post-metadata">

**Author:** ![Parit](https://avatars.discourse-cdn.com/v4/letter/p/db5fbb/32.png) [@Parit](https://discourse.nodered.org/u/Parit)\
**Post date:** [10 March 2021 15:39 UTC](https://discourse.nodered.org/t/using-inject-node/42391/11 "2021-03-10T15:39:34Z")

</div>

That should work, I'll give it a try. Thanks
