# Modify node-arduino to create a msg on every received analog value

**URL:** <https://discourse.nodered.org/t/modify-node-arduino-to-create-a-msg-on-every-received-analog-value/17386>\
**Category:** General\
**Created:** [31 October 2019 19:57 UTC](https://discourse.nodered.org/t/modify-node-arduino-to-create-a-msg-on-every-received-analog-value/17386 "2019-10-31T19:57:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![m\_elias](https://avatars.discourse-cdn.com/v4/letter/m/94ad74/32.png) [@m\_elias](https://discourse.nodered.org/u/m_elias)\
**Post date:** [31 October 2019 19:57 UTC](https://discourse.nodered.org/t/modify-node-arduino-to-create-a-msg-on-every-received-analog-value/17386/1 "2019-10-31T19:57:36Z")

</div>

I'm using analog inputs on my Arduino running the StandardFirmataPlus example sketch to measure pressure sensors. I've modified the sketch to read the analog inputs only every 5 seconds to reduce USB serial traffic and cpu load on both devices but node-arduino does not create a msg and trigger my flow unless the new value is different than the previous one. I want to have a that value saved to a time series db regardless of whether the value has changed.

The two options I prefer are:

1. Modify the node and remove the [comparison](https://github.com/node-red/node-red-nodes/blob/master/hardware/Arduino/35-arduino.js#L85).  
I don't know how to do that yet.

2. Request a feature for node-red-node-arduino to pass msgs even if the value has not changed  
(maybe also request support for setting the analog sampling rate from within the node, contrib-gpio supports this but doesn't support INPUT\_PULLUP)  
This could take longer so I like the first option for the interim.

Any other reasonable options?

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [31 October 2019 20:13 UTC](https://discourse.nodered.org/t/modify-node-arduino-to-create-a-msg-on-every-received-analog-value/17386/2 "2019-10-31T20:13:35Z")

</div>

Modify the arduino sketch to send the data each time there is a reading then send 0 or some other number out of range. Then in your flow, ignore any msg with that value.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [31 October 2019 21:38 UTC](https://discourse.nodered.org/t/modify-node-arduino-to-create-a-msg-on-every-received-analog-value/17386/3 "2019-10-31T21:38:30Z")

</div>

If you just want a repeat of the message if nothing arrives after 5 minutes maybe the node-red-contrib-msg-resend will do the job for you

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/e/ef013b802556021a5120d31efc7263ceae7b4803.png)

---

<div class="post-metadata">

**Author:** ![m\_elias](https://avatars.discourse-cdn.com/v4/letter/m/94ad74/32.png) [@m\_elias](https://discourse.nodered.org/u/m_elias)\
**Post date:** [31 October 2019 21:55 UTC](https://discourse.nodered.org/t/modify-node-arduino-to-create-a-msg-on-every-received-analog-value/17386/4 "2019-10-31T21:55:26Z")

</div>

Good ideas, thanks.
