# Average from 4 MQTT In nodes

**URL:** https://discourse.nodered.org/t/average-from-4-mqtt-in-nodes/83511
**Category:** General
**Tags:** function-node
**Created:** [7 December 2023 19:34 UTC](https://discourse.nodered.org/t/average-from-4-mqtt-in-nodes/83511 "2023-12-07T19:34:51Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![bastler500](https://avatars.discourse-cdn.com/v4/letter/b/e19adc/32.png) [@bastler500](https://discourse.nodered.org/u/bastler500)
#### Post date: [7 December 2023 19:34 UTC](https://discourse.nodered.org/t/average-from-4-mqtt-in-nodes/83511/1 "2023-12-07T19:34:51Z")

</div>

Hello guys, in my NODE-RED flow, I have 4 MQTT In nodes receiving data every 10 seconds from a Python script via the server. Now, I want to integrate the 4 inputs from the MQTT nodes into a function and output the average every 10 seconds. I don't have a solution on how to precisely calculate the average value in the end.

---

<div class="post-metadata">

### Author: ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)
#### Post date: [7 December 2023 19:43 UTC](https://discourse.nodered.org/t/average-from-4-mqtt-in-nodes/83511/2 "2023-12-07T19:43:39Z")

</div>

Hi and welcome

You could join the four mqtt nodes manually using a join node, then do your calculation. [Create a single message from separate streams of messages : Node-RED](https://cookbook.nodered.org/basic/join-streams)

Or possibly feed your mqtt nodes into the smooth node which can do an average. [node-red-node-smooth (node) - Node-RED](https://flows.nodered.org/node/node-red-node-smooth)

p.s. I have moved the category to general, as this is not about developing a node.

---

<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: [5 February 2024 19:44 UTC](https://discourse.nodered.org/t/average-from-4-mqtt-in-nodes/83511/3 "2024-02-05T19:44:29Z")

</div>

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