# Smooth Node - Getting Mean/Avg from sensors

**URL:** <https://discourse.nodered.org/t/smooth-node-getting-mean-avg-from-sensors/32963>\
**Category:** General\
**Created:** [16 September 2020 15:54 UTC](https://discourse.nodered.org/t/smooth-node-getting-mean-avg-from-sensors/32963 "2020-09-16T15:54:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![phreaq](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@phreaq](https://discourse.nodered.org/u/phreaq)\
**Post date:** [16 September 2020 15:54 UTC](https://discourse.nodered.org/t/smooth-node-getting-mean-avg-from-sensors/32963/1 "2020-09-16T15:54:18Z")

</div>

I have several temperature/humidity sensors, and I'm currently using the 'smooth' node to determine the mean/avg values for all the sensors.

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

However, I am unsure about the 'over the most recent x values' option, and if I'm using it correctly.

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

I have it set to 7, as I have 7 sensors total. My plan was to keep feeding it the 7 sensors inputs, and have the mean update accordingly based on the 7 readings. However, what happens if a sensor is unavailable, and only 6 sensors are read? I believe it will skew my readings, correct?

Is there a better way to do what I'm after?

---

<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:** [16 September 2020 16:46 UTC](https://discourse.nodered.org/t/smooth-node-getting-mean-avg-from-sensors/32963/2 "2020-09-16T16:46:33Z")

</div>

I think I would use a Join node in key/value mode to give you a message containing the most recent values of all channels in one message and then use a function node to give the average of those.

---

<div class="post-metadata">

**Author:** ![phreaq](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@phreaq](https://discourse.nodered.org/u/phreaq)\
**Post date:** [16 September 2020 17:54 UTC](https://discourse.nodered.org/t/smooth-node-getting-mean-avg-from-sensors/32963/3 "2020-09-16T17:54:31Z")

</div>

thanks, the Join node was the key, I got it working as expected now.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [15 November 2020 17:54 UTC](https://discourse.nodered.org/t/smooth-node-getting-mean-avg-from-sensors/32963/4 "2020-11-15T17:54:43Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
