Support Forum

Share your projects and post your questions

Register   or   Sign In
The Forum

AC RMS Voltage and Current monitoring with the ADC Pi

2572 Views - Created 02/09/2020

02/09/2020

Posted by:
Computerman142

Computerman142 Avatar

Hi

I am currently working on a project that requires to be able to calculate/monitor the RMS AC current and voltages for different circuits for safety monitoring and reporting, which will have threshold sets on the RPi for current usage and voltage levels etc. These circuits may/will have different current loads and are all AC, and some may be using 240VAC while others maybe 48VAC. However I'm not sure how to best acehive what I need it to do with the current hardware and code, due to inaccurate readings and sinewave data capture/sampling issues etc.

I have got a few ADC Pi's a few months ago and bought some sensors to test with, the ACS712 for AC current sensing and the LC Technology ZMPT101B Voltage sensor module for AC voltage sensing. I am using the demo_readvoltage.py and demo_acs712_30.py from the github ABELectronics ADCPi python libraries. However after hours of testing, I have found the current sensor on AC seems to be inaccurate and give different readings on each test run of the script, regardless on if the same ampage test current is applied or not, Ie not always on either side of 0V on screen, I've tried another sensor same issue. When testing the AC voltage sensor this seems to be more stable in its sinewave like analog output, always either side of 2.5V. However I have adjusted the on board potentiometer, so this may sorted that, hard too tell based on the output to the screen. I have also noticed the sinewave of both voltage and current sensor modules on screen seem to a bit slow to refresh/capture the sinewave. Is this the os.clear function or a possible sampling speed issue by the ADC Pi, I currently have it set on 18?

I have tested the current sensor on DC current to see where the issue may lie, again with the demo code (albeit a slight change to the calc_current function, changed workings out to be 2.5) * 10), however it seems to be near accurate current reading with DC so seems to be just an issue with AC.

What I'd like to know is whether these two sensor modules would work as desired with the the ADC Pi on AC supplies and if so how I would go about coding the calculation for the current and voltage based on the sinewave input, and if not what other solutions I could look at implementing to acheive this. Ideally I'd like to keep it with the RPi and ADC Pi' s due the rest of the project incorporating other ABElectronics libraries etc.

The other options I can think of that could work if the above doesnt, is RMS to DC converters, however I am not sure how these would work when mesauring AC current, and if it did, the below item doesn't look like it supports much current at all. I can see how it would work for AC voltage but not for current, further to this I am not sure how I would begin to code this to work out a voltage to display on screen. I have found one here but not sure if this would be suitable, if it came to finding one: LTC1966-Converter-Precision-Micropower-Delta-RMS-to-DC-Convert-Module

The other only option apart from above I can think of would be to buy an Arduino, or two and connect the analogue inputs to this. The Arduino would then sample the data from the sensor modules and feed the calculated voltage and current readings back to the RPi, or the RPi would poll/request for the calculated voltage and current readings. As Arduino is a new thing to me I'd rather stick with the ADC Pi and Raspberry Pi, due to not knowing how to code in Arduino languages at all, and also how I would set the the Pi and Arduino communcation and analog inputs up properly.

Any assistance with this and or how to best go about this would be greatly appreciated, its starting to send me slowly insane. If only it could all be DC for this project, it would be much easier. Sorry about the post length, realised I've gone on a bit.

Many Thanks

Rhys

02/09/2020

Posted by:
andrew

andrew Avatar

Location:
United Kingdom

andrew Twitter  andrew Website  

Hello Rhys

The sample rate for the ADC Pi will be too slow for measuring AC voltages directly using the ACS712 or ZMPT101B. To measure a sinewave you need to sample at a rate at least 10 times faster than the frequency so for a 50Hz sinewave you would want to sample at 500Hz. The ADC Pi has a sample rate of 3.75 SPS at 18-bit or 240 SPS at 12-bit so you will not be able to get enough samples to make an accurate calculation of the RMS voltage. You also have the problem that the ADC Pi can only measure positive voltages so you would be unable to measure the negative half of the sinewave.

Your best option with the ADC Pi would be to convert the AC signal to DC before measuring it. The LTC1966 should work for converting AC to DC but it has a maximum input voltage of 1V peak so you will have to make sure the voltage from your sensors does not exceed this. For measuring voltage you could use an isolation transformer to drop the voltage down but finding one with an output voltage of less than 1V will be difficult so you would need to use a voltage divider to drop the voltage to a safe level before passing it into the LTC1966.

Using an Arduino would be another option. The ADC on an Arduino should have a fast enough sample rate to measure a 50Hz sine wave and you could do all of the RMS calculations inside the Arduino before sending the data to the Raspberry Pi through the UART, I2C or SPI bus. I found this article on the open energy monitor website which explains how to use an isolation transformer and resistors to measure an AC voltage on an Arduino.

Sign in to post your reply

Note: documents in Portable Document Format (PDF) require Adobe Acrobat Reader 5.0 or higher to view, download Adobe Acrobat Reader or other PDF reading software for your computer or mobile device.