# RMS AC voltage measurement

**URL:** https://discourse.nodered.org/t/rms-ac-voltage-measurement/67767
**Category:** General
**Created:** [15 September 2022 20:31 UTC](https://discourse.nodered.org/t/rms-ac-voltage-measurement/67767 "2022-09-15T20:31:37Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![Lubotinus](https://avatars.discourse-cdn.com/v4/letter/l/5daacb/32.png) [@Lubotinus](https://discourse.nodered.org/u/Lubotinus)
#### Post date: [15 September 2022 20:31 UTC](https://discourse.nodered.org/t/rms-ac-voltage-measurement/67767/1 "2022-09-15T20:31:38Z")

</div>

I have a Raspberry Pi and MCP3008 I need to measure the RMS value of AC voltage 50Hz. Can you please tell me how this can be done software in Node-red?  
There is no problem with the hardware part.

---

<div class="post-metadata">

### Author: ![edje11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/edje11/32/572_2.png) [@edje11](https://discourse.nodered.org/u/edje11)
#### Post date: [16 September 2022 14:04 UTC](https://discourse.nodered.org/t/rms-ac-voltage-measurement/67767/2 "2022-09-16T14:04:58Z")

</div>

Hi,  
I don't think Node-red is suitable for these kind of real time application.  
You can do the acquisition and preprocessing in C or Python and pass the values to Node-red.

---

<div class="post-metadata">

### Author: ![Lubotinus](https://avatars.discourse-cdn.com/v4/letter/l/5daacb/32.png) [@Lubotinus](https://discourse.nodered.org/u/Lubotinus)
#### Post date: [16 September 2022 19:23 UTC](https://discourse.nodered.org/t/rms-ac-voltage-measurement/67767/3 "2022-09-16T19:23:16Z")

</div>

Thank you for your reply,  
I unfortunately do not know C and Python, so I chose Node-Red.  
Why can't Node-red do it? Is it too slow?

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [16 September 2022 19:37 UTC](https://discourse.nodered.org/t/rms-ac-voltage-measurement/67767/4 "2022-09-16T19:37:59Z")

</div>

There is a node-red-node-pi-mcp3008 node that should work - but I'd be more worried about hooking anything to AC (mains) voltage - so I assume you have some sort of rectifier and isolation before the mcp3008 ?

---

<div class="post-metadata">

### Author: ![Lubotinus](https://avatars.discourse-cdn.com/v4/letter/l/5daacb/32.png) [@Lubotinus](https://discourse.nodered.org/u/Lubotinus)
#### Post date: [16 September 2022 19:45 UTC](https://discourse.nodered.org/t/rms-ac-voltage-measurement/67767/5 "2022-09-16T19:45:13Z")

</div>

I used this Node it works fine with DC, and on AC it outputs values varying at 50Hz. How do I calculate the RMS value from these values?

If you rectify the AC voltage, the system will work, but if the AC voltage has decreased very fast, and we have a capacitor in the rectifier, will it stay charged?

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [16 September 2022 19:50 UTC](https://discourse.nodered.org/t/rms-ac-voltage-measurement/67767/6 "2022-09-16T19:50:55Z")

</div>

It depends how fast is fast (compared to the slope of 50hz signal). If you really want to measure live then you will probably be pushing the processor ( hence suggestion to use either specific hardware or outside node-red). If it can be over several cycles then rectifying and smoothing would be much more achievable.

---

<div class="post-metadata">

### Author: ![Lubotinus](https://avatars.discourse-cdn.com/v4/letter/l/5daacb/32.png) [@Lubotinus](https://discourse.nodered.org/u/Lubotinus)
#### Post date: [16 September 2022 19:59 UTC](https://discourse.nodered.org/t/rms-ac-voltage-measurement/67767/7 "2022-09-16T19:59:59Z")

</div>

Let's say I do not need super great accuracy, still the question of how to measure it remains? Or rather, how to calculate from the data stream that the MCP3008 outputs?

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [16 September 2022 20:02 UTC](https://discourse.nodered.org/t/rms-ac-voltage-measurement/67767/8 "2022-09-16T20:02:41Z")

</div>

If you use a diode bridge to rectify the signal (and a smoothing circuit) then it will be a smooth dc level which will be the rms value

---

<div class="post-metadata">

### Author: ![Lubotinus](https://avatars.discourse-cdn.com/v4/letter/l/5daacb/32.png) [@Lubotinus](https://discourse.nodered.org/u/Lubotinus)
#### Post date: [16 September 2022 20:07 UTC](https://discourse.nodered.org/t/rms-ac-voltage-measurement/67767/9 "2022-09-16T20:07:42Z")

</div>

Thank you, I will do the experiment and write the result.  
But I am still confused by the fact that with a fast change of AC voltage, the capacitor that will smooth the pulses after the rectifier will remain charged and thus introduce an error in the measurements.

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [16 September 2022 20:11 UTC](https://discourse.nodered.org/t/rms-ac-voltage-measurement/67767/10 "2022-09-16T20:11:53Z")

</div>

A suitable load resistance will help.

> **[Rectifying & smoothing :: Electronic Measurements](https://meettechniek.info/measurement-examples/rectifier.html)**
>
> Voltage current and power measurement on simple power supply.

---

<div class="post-metadata">

### Author: ![Lubotinus](https://avatars.discourse-cdn.com/v4/letter/l/5daacb/32.png) [@Lubotinus](https://discourse.nodered.org/u/Lubotinus)
#### Post date: [16 September 2022 20:15 UTC](https://discourse.nodered.org/t/rms-ac-voltage-measurement/67767/11 "2022-09-16T20:15:44Z")

</div>

Yes, I've already thought about installing a load resistor to discharge the capacitor. After all, the MCP3008 resistance is megohms, so it won't discharge the capacitor very fast.

Thanks again.

---

<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: [17 September 2022 07:29 UTC](https://discourse.nodered.org/t/rms-ac-voltage-measurement/67767/12 "2022-09-17T07:29:06Z")

</div>

How quickly do you need to know about a change, and why?

---

<div class="post-metadata">

### Author: ![Lubotinus](https://avatars.discourse-cdn.com/v4/letter/l/5daacb/32.png) [@Lubotinus](https://discourse.nodered.org/u/Lubotinus)
#### Post date: [17 September 2022 08:36 UTC](https://discourse.nodered.org/t/rms-ac-voltage-measurement/67767/13 "2022-09-17T08:36:36Z")

</div>

The device will measure the voltage across the load resistor and save the voltage change data to a file. I would like to measure with an accuracy of at least 3 to 5 periods of AC voltage, i.e. every 60 to 100ms.

---

<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: [17 September 2022 09:03 UTC](https://discourse.nodered.org/t/rms-ac-voltage-measurement/67767/14 "2022-09-17T09:03:21Z")

</div>

If you use a time constant of 33 msec then it will get 96% of the way to the new voltage in 100ms. Would that be good enough?

---

<div class="post-metadata">

### Author: ![Lubotinus](https://avatars.discourse-cdn.com/v4/letter/l/5daacb/32.png) [@Lubotinus](https://discourse.nodered.org/u/Lubotinus)
#### Post date: [17 September 2022 14:10 UTC](https://discourse.nodered.org/t/rms-ac-voltage-measurement/67767/15 "2022-09-17T14:10:14Z")

</div>

100ms it will be fine, but I still don't understand how to measure the AC voltage in Node-red?  
The AC to DC conversion will only work if the AC voltage is greater than 1V, at lower voltages the diodes will not open.

---

<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: [17 September 2022 16:00 UTC](https://discourse.nodered.org/t/rms-ac-voltage-measurement/67767/16 "2022-09-17T16:00:35Z")

</div>

Well since you have not told us what voltage range you wish to measure then we could not have been expected to know that you wanted to measure accurately below 1 volt. What range of RMS are you trying to measure, and where is that coming from?

---

<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: [16 November 2022 16:00 UTC](https://discourse.nodered.org/t/rms-ac-voltage-measurement/67767/17 "2022-11-16T16:00:57Z")

</div>

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