Safest way to measure AC mains 220-250 voltage? - Page 1
Forum section: electronics / beginners

author: paulca
author_rank: Super Contributor
timestamp: July 17, 2019, 09:18:22 am
content: I intend to install a DIY mains electric monitor (or several) in my distribution board / meter box.For current I hope to use one of these:https://www.ebay.co.uk/itm/100A-SCT-013-000-Non-invasive-AC-current-sensor-Split-Core-Transformer-ODHN/264087793339?epid=7008163687&hash=item3d7cdbeebb:g:EMoAAOSw-CpYBowrI gather this will output a 50mA (for 100A) AC current, so I still have open questions on how to correctly sample that to get a genuine current value.For voltage, I believe I could use an unregulated transformer based AC/DC power supply and calibrate it's unloaded output with a multi meter. Obviously this will not allow me to measure things like power factor, apparent power etc. but I have no requirements to do so. A simple DC voltage, as close to linearly related to the AC input voltage as possible. I do not expect my voltage to fluctuate that much, the lowest I have ever measured locally was 239V and the highest 245V.I also realise that if I just assumed 240V I would get a fairly accurate figure anyway, within a few percent.

author: paulca
author_rank: Super Contributor
timestamp: July 17, 2019, 09:39:23 am
content: Quote from: paulca on July 17, 2019, 09:18:22 amA quick google for example circuits and of course this should be as simple as a current sense resistor to convert the current to a voltage and a suitably sized capacitor to smooth the voltage out.My AC is a little rusty (always has been), but if you pass 1A through a 1 Ohm resistor you get 1V, but if you then pass -1A through the same resistor you would get -1V across it, no? Surely this would just discharge the smoothing capacitor or reverse it's polarity. So I'm confused. Should there not be a diode in the circuit somewhere to filter out the negative voltage across the current sense resistor?

author: richard.cs
author_rank: Super Contributor
timestamp: July 17, 2019, 09:56:38 am
content: You can put a bridge rectifier on the output of the current transformer then have your shunt resistor after that. The diodes introduce some extra voltage drop which is OK because the current transformer acts as a constant-current source. Your voltage across the resistor will be full-wave rectified so will be bumpy. Don't connect a capacitor directly across the shunt resistor, include it in a resistor-capacitor filter after the shunt resistor. That capacitor will then have a voltage across it that is proportional to the average current magnitude, as a reasonable approximation this is proportional to RMS current which is what you actually want.Or, if you are feeding this signal into a microcontroller you don't need the diodes or the capacitors, instead you connect the shunt resistor directly across the current transformer, bias the signal (offset it positive so your signal goes from e.g. 1 to 3 V instead of -1 to 1 V) into the ADCs input range, and then sample multiple times per AC cycle to allow you to calculate the RMS current.

author: paulca
author_rank: Super Contributor
timestamp: July 17, 2019, 10:00:33 am
content: Quote from: richard.cs on July 17, 2019, 09:56:38 amAh, yes. For some reason I was trying to shy away from dealing with the actual AC current waveform, but as you point out, if biased correctly and sampled fast enough, the rest just becomes mathematics.I found this, which will help with the mathematicshttps://learn.openenergymonitor.org/electricity-monitoring/ct-sensors/how-to-build-an-arduino-energy-monitor-measuring-current-only?redirected=true

author: soldar
author_rank: Super Contributor
timestamp: July 17, 2019, 10:04:47 am
content: I have several of thesehttps://www.ebay.com/itm/113704114092and they work fine.If you search ebay for -- panel meter ac 300V 100A -- you can find many similar items.You can also find power meters and energy meters.

author: Kjelt
author_rank: Super Contributor
timestamp: July 17, 2019, 10:11:08 am
content: Quote from: soldar on July 17, 2019, 10:04:47 amI also have something similar from China for $15 but it is only powered when I am there (for my machine).I would not like to have it 24/7 unattended in my house: if it fails what guarantees do you have it will not catch fire ?

author: paulca
author_rank: Super Contributor
timestamp: July 17, 2019, 10:14:37 am
content: Quote from: soldar on July 17, 2019, 10:04:47 amI should have stated my original requirements better. I already have an energy monitor, it's wireless with a current clamp and transmitter tied onto the main meter OUT "tail", and the receiver has an LCD display showing Kw, accumulated kwh and cost (if provided the KWh cost). However this is a closed system and without reverse engineering it's signal or trying to tap the LCD signals I cannot get the data out.I need something that will provide current and potentially (bad pun) voltage to an ESP8266 or similar Wifi capable MCU to allow me to send this data onto my home automation hub for logging, display etc.Also, on EBay mains panel meters I have had bad experiences. One I bought "the Internet" told me the wrong instructions where sent with some of them with completely incorrect wiring diagrams. However I figured if I choose to ignore the instructions that came with it and trusted "the internet" and it blew up I would look stupid. So I wired it based on the instructions that came with it. It promptly detonated all over my carpet spraying capacitor guts and putting a burn hole in the shape of my devices cooling vents in the carpet.Landlord was not happy and I lost most of my deposit, although I'm still fighting to get that back.

author: Terry01
author_rank: Frequent Contributor
timestamp: July 17, 2019, 11:08:30 am
content: Quote from: paulca on July 17, 2019, 10:14:37 amSorry but that's some funny chit!

author: paulca
author_rank: Super Contributor
timestamp: July 17, 2019, 02:22:48 pm
content: So thoughts on measuring the mains voltage?a) Don't bother, just hard code 240V and power might be off by a few watts.b) Ebay special mini-transformer module and calibratec) 9V Transformer unregulated wall wortI'm leaning towards option a at the moment.

author: Kjelt
author_rank: Super Contributor
timestamp: July 17, 2019, 03:05:04 pm
content: If you do choose a, than I would suggest measuring the voltage with a true rms multimeter.I don't know how it is in the UK (probably location dependent) but here in NL we have a rather steady voltage BUT it is never 230VAC as it should be.In my house it is 228VAC +/- 1V during the daytime. If you know that than you at least have a more accurate number to start with.

author: james_s
author_rank: Super Contributor
timestamp: July 17, 2019, 03:52:39 pm
content: My energy monitor is powered by a small AC output unregulated wall wart, it's just a transformer. That's the safest way I can think of and it works well enough. As long as the load on the transformer is not too variable the result should be quite accurate.

author: soldar
author_rank: Super Contributor
timestamp: July 17, 2019, 06:08:14 pm
content: If what you want is a transducer that will output a standard 0 - 5 V or 4 - 20 mA you can find commercially built units and unless they are very expensive you are better off just buying something off the shelf.https://www.set-transducer.com/CurrentTransducer.html?RC=5You can also find them for voltage and other physical magnitudes.

author: ogden
author_rank: Super Contributor
timestamp: July 17, 2019, 06:11:01 pm
content: Quote from: paulca on July 17, 2019, 09:18:22 amYou shall start reading electricity meter reference designs:http://www.ti.com/solution/smart-e-meter-amr-amihttps://www.st.com/en/applications/metering/single-phase-meter.html

author: james_s
author_rank: Super Contributor
timestamp: July 17, 2019, 08:27:54 pm
content: The proper device is called a potential transformer, however in practice any ordinary mains frequency power transformer is likely to be good enough. It only needs to be accurate over a range of say +/-20% at most.

author: soldar
author_rank: Super Contributor
timestamp: July 18, 2019, 06:41:58 am
content: I may be mistaken but I believe the OP is looking for transducers which will convert AC voltage and AC current into DC signals proportional to the RMS values of the originals and which can then be fed and measured.

author: paulca
author_rank: Super Contributor
timestamp: July 18, 2019, 06:54:29 am
content: Quote from: soldar on July 18, 2019, 06:41:58 amTrue, but as the device (MCU) will be doing nothing much else it can probably sample a 50Hz waveform fast enough to calculate the RMS values.I bought SCT current clamp, took note of the warning about clamping it to anything while un-burdened! I'll start with just a periodic measurement of my mains voltage and calibrate it using something like a 100W incandescent lightbulb on the bench before putting it in the meter box.The OpenEnergyMonitor project has lots of gudies and code libraries that will help.Last night I dusted off my soldering iron which has been boxed up for months due to house move. Took an hour to make a temp sensor for my living room using an ESP32. Next job is the energy monitor.

author: soldar
author_rank: Super Contributor
timestamp: July 18, 2019, 03:06:16 pm
content: There are many ways to go about this depending mostly on what you need. If you need to know polarity that is one thing. If you just need to know absolute magnitude that is different.If just magnitude is enough then optoisolators can come in handy.If you need polarity and do not want to handle negative voltages then you can have an input of -2.5 to +2.5V and offset it by +2.5V which gives you 0 - 5 V.

author: paulca
author_rank: Super Contributor
timestamp: July 18, 2019, 06:02:25 pm
content: All I'm after is a fairly accurate electrical usage figure, so I can display it, log it and graph it with my home data logger system.As power is current * voltage I figured I'd need a safe way to measure the mains voltage with a 5V MCU, well actually a 3.3V MCU.However as pointed out by others if the mains voltage is stable, and it pretty much is here, there is no real need to measure the voltage, just add it as a calibration configuration value.

author: soldar
author_rank: Super Contributor
timestamp: July 18, 2019, 06:42:15 pm
content: That won't work because you need instant value. Phase counts.You need to measure voltage and current at least several hundred times per cycle and multiply those values.Or how would you measure the power used by a bridge rectifier followed by a capacitor where you get very short bursts of current?You would probably be better off getting a specialized IC. You are aware that these things are sold off the shelf commercially.

author: paulca
author_rank: Super Contributor
timestamp: July 18, 2019, 07:44:08 pm
content: Quote from: soldar on July 18, 2019, 06:42:15 pmDo you have an example?

author: soldar
author_rank: Super Contributor
timestamp: July 18, 2019, 10:42:05 pm
content: Sorry, I expressed myself very poorly. I am sure there are specialized IC for this type of job because that is what Energy meters would use.But when I wrote the second phrase what I meant is that maybe you could buy some cheap power or energy meter and hack it so you could get the info out. They can probably do most, if not all, of what you are trying to do.Although, unless you are trying to do something very specific, energy counters, like the ones power companies use, can do pretty much everything, including interfacing with other devices.The one my company has installed is Landis & Gyr but I'd have to check the model.I also have about a dozen electro-mechanical meters which were to be dumped some years ago when they replaced them with the electronic remote control ones.The old ones have a spinning disk and it would be simple to install a photodiode to check how fast it is spinning. Not to mention that it totals the energy right there. I have several installed in several devices just to check how much appliances use.Again, it depends a lot on what you are trying to do and whether you are trying to be efficient or trying to have fun designing something.Quote from: ogden on July 17, 2019, 06:11:01 pm

author: james_s
author_rank: Super Contributor
timestamp: July 19, 2019, 12:46:44 am
content: There was an IC made by Austria Microsystems for kWh meters but I don't know if it was widely used. It's not uncommon to use a standard microcontroller, a friend of mine did some experiments and using a 8 bit AVR he was able to capture fast enough to digitize a 50/60Hz sine wave and then calculate the RMS, power factor, crest factor, etc. For monitoring the voltage the power transformer powering the device was used.

author: paulca
author_rank: Super Contributor
timestamp: July 19, 2019, 06:38:29 am
content: So the energy meter I have with it's wireless LCD display has no voltage tap, just the current clamp. So it obviously assumes the voltage waveform.I realise without a voltage tap I would be left assuming the voltage and current waveforms are exactly the same and thus I would miss account anything with a power factor not equal to 1. That would include inductive loads like washing machines, dryers, fridges, freezers etc. and capacities loads, which other than start up bursts of most things with capacitors would, I assume not be very common in a domestic setting.I would also have to sample the current waveform, determine it's peaks, and crossing points to put my virtual voltage waveform in phase with it.Or I could try and source a transformer that outputs 3V pp AC from 240V RMS mains. There are ebay modules as I suggested in my original post. Although any solution would need to be fused to prevent any significant current being able to pass through it, so that in the worst case, of say, a short in the device cannot possibly cause fire.EDIT: I do have a little dual tap 18V sealed 100mA transformer and I could always tap it and run it through a divider to get 3V pp.

author: soldar
author_rank: Super Contributor
timestamp: July 19, 2019, 07:51:30 am
content: I can't see how an energy meter can work without measuring the voltage.As discussed in another thread, the shape of the voltage is far from being a perfect sine.And the shape of the current in devices with rectifier bridges is tiny bursts at the peak of the voltage.To have any kind of accuracy you would need to sample V and I hundreds of times per cycle and then multiply.And make sure you got them right because using a normal voltage transformer will introduce phase shift in the signal.This issue is more complex than might seem at first sight.

author: paulca
author_rank: Super Contributor
timestamp: July 19, 2019, 10:25:25 am
content: But you are assuming a very high level of accuracy. A home energy monitor is probably not that accurate. it might be out of 10% of so.I can't find a link to the one I have, but here is an example similar to it:https://www.amazon.co.uk/Micro-CM180-Wireless-Energy-Monitor/dp/B007W0SQ3Y/ref=lp_1938287031_1_16?s=diy&ie=UTF8&qid=1563531804&sr=1-16You will note it only has a current clamp. So unless it can measure voltage via that and not just current, then it is assuming the voltage waveform.If you google you will find dozens of similar devices with a current clamp and a transmitter. Some integrate with smart home monitors, some with battery powered LCD displays.

author: soldar
author_rank: Super Contributor
timestamp: July 19, 2019, 03:21:04 pm
content: I do not understand how those things work. It would seem to me that it would not distinguish between reactive and resistive loads.I would check to see how precise they are because bad information is worse than no information.Whatever trick they use I see they have a USB model which you can connect to a computer if that's what you want to do.Personally I have a similar device but it is placed at the mains panel and is connected to the wires so it does have voltage information as well as using that to supply power so it does not need batteries. I find that is good enough for me as the panel is right at the front door and I feel no need to carry the receiver around with me around the house.Most of the time I am only concerned with the current being used because in Spain we have current limiters and pay by the max current you can pull so I have a lower current limit but have to watch how much current I am pulling at any one time and disconnect something if I am over the limit.

author: paulca
author_rank: Super Contributor
timestamp: July 19, 2019, 06:14:45 pm
content: Peak demand based billing is only applied to large commercial and industrial supplies here. Thankfully.I think we have different aims. If the energy monitor I have tells me I'm drawing 450W and that figure it out by 10% because one of the loads is inductive like the washing machine, I'm fine with that.I do not need this to verify or cross check the electric utility meter (magnetic rotating disc and clockwork digits type). I really just want indicative, comparable measurements.If logged and graphed this can show me an estimate of the base load and see where and how hard the spikes hit when the "big hitters" are used, shower, washing machine, cooker, space heaters etc.As to hacking into an off the shelf module, it's took fiddly. As to the USB style monitors; they often save a CSV file to a memory card and so not realtime data, that or a prepriatory file which you have to pen with their "app".I might just follow the open energy monitor spec and see how far I get.

author: richnormand
author_rank: Unknown
timestamp: July 19, 2019, 09:19:22 pm
content: Interesting timing for your post.A few days ago Ontario Hydro had a statement about a test where they would lower the mains voltage by 5% to test their various systems across the province.So, using stuff in the misc and spares drawer, I put a test system to monitor the line voltage behaviour.I was not comfortable going straight to the mains so I located a wall-wart that had a non-regulated AC output (ie: just a transformer).I then put together a full bridge rectifier with very low filtering and a resistive load on it so it would react fast to changes in voltage (just the opposite of what you do for a good supply). I then put a resistor/LED to signal the system is on.For monitoring I used my Lascar voltage monitor. Could have used the computer monitoring on the DMM but the Lascar is simpler.Photos:Setup.Results.Used a Variac to change the line voltage and get a calibration reading rms voltage from DC generated.Edit: just realised that the dip was in sample units. The 5% voltage drop was from 2:00 to 3:00 pm.

author: james_s
author_rank: Super Contributor
timestamp: July 19, 2019, 10:43:18 pm
content: Is there a reason you put a rectifier and capacitor on it instead of just taking the raw AC out of the transformer? I suppose it shouldn't make much difference either way but I figure it's less stuff to potentially influence the reading.

author: richnormand
author_rank: Unknown
timestamp: July 19, 2019, 10:48:58 pm
content: No not really, but in my case the Lascar only take 0 to 30VDC as an input.All depends on what you have to monitor mains voltage.Edit: just added in my previous post that the voltage dip was one hour long. Most people probably never noticed.

author: soldar
author_rank: Super Contributor
timestamp: July 20, 2019, 08:12:06 am
content: Quote from: paulca on July 19, 2019, 06:14:45 pmIn this case you can just measure current, you do not need to measure voltage. If you are going to assume constant voltage then measuring only the current is a directly related magnitude.But you need to measure RMS current because measuring peak current is going to be very misleading. A diode charging a capacitor is going to give you a big peak.So you can put the 50 mA of the current transformer through a bridge and get DC pulses. A current transformer should never be left open so I put a Zener diode to prevent that. The Zener is just a protection and has no use in normal operation.I guess you could follow with a low pass filter to get rid of current spikes.ETA: I guess I am a bit confused because the title of the thread is how to measure voltage but then in the discussion the OP says he wants to measure power and without need for precision and power is correlated with current since we can assume voltage is stable. So I am not really sure what the purpose of all this is.

author: paulca
author_rank: Super Contributor
timestamp: July 20, 2019, 11:42:15 am
content: Quote from: soldar on July 20, 2019, 08:12:06 amI wanted to find the easiest and safest way to measure the voltage, but then started to question if I needed to or not.With the current clamp, through a burden resistor and into a voltage divider to size it for my MCU there is very little that can go wrong, there is no mains connection.When I come to measuring voltage, I need to actually connect something to the mains and I don't like mains.I'm still not 100% decided on whether to try and measure the voltage or not and if I do, how.Option 1: Chinese module:https://uk.banggood.com/Single-phase-AC-Active-Output-Voltage-Transformer-Voltage-Sensor-Module-p-1228141.html?gmcCountry=GB&currency=GBP&createTmp=1&utm_source=googleshopping&utm_medium=cpc_bgcs&utm_content=garman&utm_campaign=pla-gbg-ele-diy2-pc&ad_id=339489662626&gclid=CjwKCAjw98rpBRAuEiwALmo-yi4ig3-CtTFTSgPBmLTfxfxN_iy3w0Mn14YECcKBKPcyJBi3743RDhoCZcUQAvD_BwE&cur_warehouse=CNOption 2: Ac-Ac power supply, but finding the right one that isn't regulated does not appear to be easy, although I could modify it. Then I need to start considering the transformer phase shift, voltage dividers, offsetting the voltage etc. etc.

author: MrAl
author_rank: Super Contributor
timestamp: July 20, 2019, 12:16:09 pm
content: Hello,When measuring AC voltage and current usually the AC voltage is converted into DC and then the DC level is calibrated against the measured AC level. This way you get good readings.For voltage, one way to do it is to rectify the AC into peak AC which is DC, then calibrate it using known AC voltages.The drawback to this method is that if the peak is loaded down (often the case with softer AC lines) then you dont get an accurate reading unless of course you are just interested in the peak AC.You could look into averaging methods for better results.For AC current, it is usually to use a current transformer. The current transformer output is rectified into DC. The DC is then calibrated against a known AC current.The reason for the calibration in these methods is because each method is somewhat non linear and thus the scale factor changes depending on actual signal level. It's not too hard to do though just input some known levels and note the output then include that in your measurement algorithm.Often a microcontroller is used to do the measuring.Also note that playing with live mains is not always a good idea. To measure voltage an AC transformer can be used that steps the voltage down to a more manageable level and also isolates your measurement equipment from the live mains line.

author: richnormand
author_rank: Unknown
timestamp: July 20, 2019, 03:49:31 pm
content: Quote from: MrAl on July 20, 2019, 12:16:09 pmIndeed for voltage using a wall-wart with an AC transformer is most likely the safest way to have isolation and low voltages for hobby measurements. Calibration is easy like pix 3 of post 27 in this thread.......Current measurement will require a loop/ring to keep a non-contact setup an can be calibrated using various loads on the circuit.

author: paulca
author_rank: Super Contributor
timestamp: July 20, 2019, 04:35:14 pm
content: Quote from: MrAl on July 20, 2019, 12:16:09 pmNow I'm even more confused. Why do I need to rectify them? If I offset them so that I end up with, say, 0-3V with 1.5V being the mid point, when I do the RMS calculation it will (by it's squaring nature) end up positive. Although I can see that a rectified waveform would give more accuracy as I could use the full 0-3V for both positive and negative giving twice the accuracy.Also will rectifying the voltage not change it requiring I calibrate out the diode drops? I realise rectifying the current transformer will have little to no effect as it's a current source.So it's looking like I do need to measure the voltage and I might as well go the full RMS voltage RMS current calculation.I already have the current transformer. Gives me 50mA per 100A, a correctly calculated burden resistor and an offset divider.For voltage I'm going to need a 12Vac adapter and a voltage divider to get it down to 3Vac offset by 1.5V.What about this transformer phase issue? Do I need to worry about it? How much will it shift the phase by? Is it determinable/measurable/negligible?

author: paulca
author_rank: Super Contributor
timestamp: July 20, 2019, 04:48:25 pm
content: I found this:https://meters.co.uk/products/single-phase/Would need the electrician to install it, but it has an RS485 MODBUS output and it would mean I don't need to feck about with the mains or blow myself up.Thoughts?

author: soldar
author_rank: Super Contributor
timestamp: July 20, 2019, 05:32:52 pm
content: Quote from: paulca on July 20, 2019, 04:48:25 pmLooks nice. I think you can install it yourself but if you feel more comfortable having a pro do it then go for it. If you do it yourself you can get the split core which is easier to install. If you get a pro to do it then you can get the solid core which gives a bit better precision.Basically it is the same that I have except mine has no communications capability. Mine is just the cheap Chinese eBay version. Just connect two wires to voltage and the current transformer around the main wire. You can do it with the general breaker cut off so there is no risk involved. Easy peasy.This onecosts the same and looks a bit better if you have the space for it.

author: ledtester
author_rank: Super Contributor
timestamp: July 24, 2019, 05:04:43 am
content: Here's a design which utilizes HCPL-7520 linear optoisolators to provide isolation:https://atmega32-avr.com/powerbox-the-safe-ac-power-meter-using-atmega32/Perhaps others can comment on whether or not this part is appropriate for this kind of use.Also, a couple of power meter projects that I've found useful to study:-http://elm-chan.org/works/heco/report_e.html-http://ww1.microchip.com/downloads/en/AppNotes/Atmel-2566-Single-Phase-Power-Energy-Meter-with-Tamper-Detection_Ap-Notes_AVR465.pdfIn particular, the way you measure the current has to be carefully considered since that has quite a large dynamic range -- from a few milliamps to several amps. The Elm Chan project solves that by using a 16-bit ADC. The Atmel/Microchip design uses op amps whose gains are dynamically controlled by the microcontroller.