A convenient adapter to view the electrical grid waveform through your PC's sound card.

Public Chat
Similar projects worth following
There is a lot to be observed from the waveform of the electrical mains. Harmonics, transient changes, periodic fluctuations, frequency shifts, impedance, power line communications - These all give clues as to the state of the country's electrical transmission system (or what loads your neighbour has connected). Platforms like MATLAB allow for the easy analysis of waveforms through powerful software tools, but only once the signal has been acquired.

The purpose of this project is to allow easy and safe access to the electrical grid waveform without a hassle. It's as simple as power cable in and 3.5mm audio out.

Current status (3rd November):

-->All hardware and final enclosures are complete.
-->Reliability has been established (it doesn't burn the house down).
-->Software to be used will be a combination of MATLAB for processing and SpecLab for "listening" and possible pre-processing. See SpecLab here:

Current focus:

-->MATLAB time.

The Grid-2-Audio module is comprised of three main parts:

1. The case and IEC all-in-one power entry connector - As part of teaching myself AutoDesk Inventor, I decided to start with the mechanical aspect of the project. The presence of mains voltage potential is no joke and the design of the case reflects that. The utilisation of an IEC power socket with built in switching, fusing and illumination minimises any mains wiring around the internal space of the unit.

2. The PCB power supply and mains input - As the unit is design to measure the grid voltage and introduce minimal noise, the power supply needs to ideally draw a minimal sinusoidal current (at the fundamental frequency) in phase with the voltage. Additionally, there needs to be isolation between the mains measurement circuit and the output side, forcing the requirement of multiple transformer taps for the whole PCB.

3. The PCB signal conditioning - The mains signal needs to be conditioned to the 3.5mm audio format and protected from shorts. As an extra feature, a 50Hz high-pass filter will be included to provide an alternate "harmonic only" output to increase the dynamic range for harmonic analysis. EDIT - The filter has since been removed and will now be accomplished via software libraries within MATLAB, etc.

Here's some pictures of the hardware:

Late update:

Brian was kind enough to write about this project on the main page some time back:

There were some interesting ideas in the comments about retrieving isolated signals, but what I certainly took to heart was the emphasis on isolation distances. Although I couldn't achieve 6mm clearance (I increased it to 5mm), I added slots (for extra creepage) and increased the mains voltage divider resistance values to only allow a "2mA shock" if the isolation AND earth fail.

Results 2.fig

Latest set of results from approximately 1 hour of sampling. Each sample is an average of a two second window (don't expect it to capture fast changes). Generated from MATLAB 2017a (you'll need it).

Xfig - 13.68 MB - 12/10/2018 at 10:52



A 3D PDF of the Grid-2-Audio PCB. Start here if you want a good look at the 3D model/layout. You'll need to download this and open it with Adobe outside of your web browser (probably). - This is the only 3D model uploaded that contains the additional "CF" capacitor across the final op-amp's feedback path.

Adobe Portable Document Format - 599.66 kB - 10/06/2018 at 12:07


Render Collection Upload.rar

A collection of my best renders from Fusion 360, along with the Fusion 360 file itself should anyone else care to indulge. The selection is somewhat limited due to the 50MB file limit.

RAR Archive - 48.96 MB - 09/27/2018 at 11:55



3D models of the parts of the device enclosure (Autodesk/STEP/STL). This now includes the revised main enclosure extrusion with additional ventilation and the fan cooling add-on.

RAR Archive - 4.36 MB - 11/03/2018 at 07:28


PCB 3D Models.rar

3D models of the PCB design (Step, STL & PDF).

RAR Archive - 1.46 MB - 09/08/2018 at 03:57


View all 8 files

View all 14 components

  • More Results

    David Scholten4 days ago 0 comments

    After leaving the computer on for an hour straight (and teaching MATLAB not to move the graph in front of my web browser) I have some interesting results:

    I seems to have captured a significant peak voltage surge and 15 minutes later, a sudden rise and drop in the THD.

    What's interesting is that the 5, 10 and 15kHz signals came in at exactly the same time that the THD dropped.

    As the THD is calculated only from the first 40 harmonics (<2kHz), it is not the signals causing the THD change. Rather, this may be some kind of signalling from the energy distributor?

    Anyway, I'm installing MATLAB on a laptop so I can monitor for longer periods of time (and have battery power to allow for the capture of blackouts!)

    This plot is currently uploaded as a MATLAB figure file for a limited time.

  • It's all downhill now!

    David Scholten6 days ago 0 comments

  • Quick MATLAB Progress

    David Scholten12/04/2018 at 11:44 0 comments

    So, first of all, sound card samples through MATLAB look like this raw:

    So I have to purge near 10 cycles (also not seen is the initial transient spike for the first 100 or so micro seconds).

    After this though, I can grab some nice data!

     I'll have a go at adding some FFT functionality over the next few days and get back to you.

  • Heat Problem is Under Control

    David Scholten11/03/2018 at 07:04 0 comments

    Okay, so after developing another version of the cooling add-on (that's far more mechanically robust and requires no printing supports), I have finally managed to keep the thing cool.

    And by cool I mean stupidly cool - We're talking only a 5-10 degrees Celsius rise above the ambient.
    It turns out it needed minimal air flow (of any amount) to move the little amount of heat it's producing.

    Here we go:

    It's not the prettiest looking case accessory, but it certainly gets the job done via the 1W/5V USB fan. Now instead of going from 23C to 75C in 2 hours it goes from 23C to 30C in 20 minutes.

    I also had a look at the waveform directly to see if the fan attachment was coupling any EMI to the measurement circuit. Turns out it isn't! I also tuned the output filtering pF capacitor a little to ensure that the RF/op-amp oscillation fluff was minimised.

    Next step is the MATLAB stuff!

  • It's Still Too Damn Hot!

    David Scholten10/20/2018 at 12:42 0 comments

    Okay, after leaving it running for 3 hours with a thermocouple in it and the "grid" (variac) set to 280Vrms I've found the following:

    -->The air temperature just above the transformers reaches about 65 degrees Celsius
    -->Laser gunning the metal-can electrolytics reveals they are at about 75-77 degrees Celsius (which we can approximate as the PCB temperature).
    -->The temperature was still rising even towards the end of the test.

    This is what I can do to 70 degree Celsius PLA material with one hand by the way:

    So, I know that the PCB is it's not convecting effectively enough (or likely at all) in the new case. However, I also know that the heat build up is so slow that ANY air movement will cool the thing down.

    Well, then aside from ice cubes, air-conditioners and desk fans, this has to happen:

    It's basically an add-on case assembly that clicks on top and adds active cooling to the device. It uses a 60mm 5V USB fan that will simply plug into the computer that is measuring it's output. In this way, the power is being drawn through the existing computer an is not utilising a potentially noisy additional power supply that would have been connected to the same power outlet as the Grid-2-Audio measurement device. However, I am still very concerned about induced EMI noise from the fan itself. We'll see how that goes soon:

  • New Enclosure Finished

    David Scholten10/15/2018 at 12:14 0 comments

    Here it is, the new enclosure fresh from the printer:

    This was printed at a 100% percent infill with a 200um layer height and took 10 hours with a print speed of about 60mm/s. Not seen are the 5 rows of vents on the side of the unit, which should allow the air to flow in and to naturally convect upwards through the top vents.

    Taking some measurements with the IR gun, the temperature of the bottom seems to reach 60 degrees Celsius on a fair day. It's a bit too hot for my liking, but there isn't anything else I can do and still maintain the safety of the device - Unless of course I give active cooling a go, but this would need an external power supply. Ultimately though, it should be fine, but with a side of caution.

    That aside, I did have fun decorating with the spare jewel thingies and stickers!

    For comparison, here is the old casing:

  • Some Basic Results

    David Scholten10/13/2018 at 12:29 0 comments

    Here we have a waveform:

    And a spectrograph:

    Finally, a plot of the RMS voltage (ignore the magnitude) at the top and the frequency at the bottom:

    This was taken over a two hour period (8:10pm - 10.00pm) on a Saturday night in Adelaide. Although the voltage magnitude is nonsensical, the proportional values are very relevant. The frequency plot, however, is correct is it's measurements.

    We can start to see some patterns emerging, such as a some sort of overall frequency governing control loop that operates with an approximate 49.9-50.1Hz hysteresis range across the network. This may just be a coincidence. Another theory is that as these dips seem to occur in half-hour intervals, which would coincide with the starts and stops of TV programming. I'll need to do a longer run and check the TV guide for what's on. Next I need to print the new case that will allow the board to run cooler - It heated up significantly during this run and I wouldn't leave it unattended at this point.

    The 12 hour print starts tomorrow morning!

  • Hardware is Working! Waveforms be Soon!

    David Scholten10/11/2018 at 12:20 0 comments

    Yes! The hardware is finally working!

    And of course, there were a couple of problems along the way.

    The first problem was an oscillating opamp (1.5MHz) right at the end of the signal chain. During the design I decided to remove the filtering capacitor across the inverting opamp's feedback resistor as I didn't want anything more than a 0.2% decrease of the 20kHz response. However, I didn't expect the opamp to completely take off in the way it did. To correct this a ~25pF was soldered to the top of R22 which seemed to completely fix the problem. 25pF is not ideal (it was all I had on hand) and 10-20pF would be more suitable to preserve the 0-20kHz frequency response. See the filtering capacitor "CF" below:

    The second problem is that there is too much heat and it can't get out. The two tiny transformers are simply too inefficient and are generating more heat than I anticipated. Additionally, the 18% infill of the 3D printed PLA enclosure is acting as a perfect insulator with its internal air pockets. Fortunately, the slow heat build-up allows the PCB to conduct thermal energy from one end of the case to the other without any significant temperature gradient. This means that more heat transfer out of the case at one end will effectively cool the other end as well. This works well for me as I like to insulate the dangerous end of the thing. Here is the only viable 3D printed solution without active cooling:

    Yes, trypophobia is a thing.

    Besides not running it continuously and letting it cool down, there is also my other solution:

    And now, here are a few pictures:

    Back without the panel installed:

    Say I might, it's a flashlight!

    Just after getting home after a day spent fixing it:

    Finally, a use for my variac!

    The grid-2-audio case (Autodesk Inventor design) fits in quite nicely next to my headphone amp (TinkerCAD design). Oh how I've improved my case making skills.

    Yes, I know there are no waveforms to show yet (sorry!) - This will change very soon!

  • PCB Soldering Complete

    David Scholten09/30/2018 at 10:51 0 comments

    Thanks to my loving Father who has soldered every single component to the PCB for me, I am now in possession of a fully populated grid-2-audio PCB!

    Have a look:

    There was an issue with finding the correct capacitor for C22 due to a BOM numbering issue, but this has since been corrected (phantom C25).

    Testing should be able to begin Tuesday night - Very exciting stuff! :)

  • PCB Version 2 Bare Boards

    David Scholten09/29/2018 at 13:53 0 comments

    Seems to be all in order!

    Top view:

    Bottom view:

    Manufactured by the Seeed Studio Fusion PCB service.

    It's not long now until I'll actually have something to show for my efforts!

View all 25 project logs

Enjoy this project?



David Scholten wrote 12/04/2018 at 00:15 point

No updates recently, I know, but some progress is being made.

MATLAB is proving easier to use than I remember (I finally updated to the latest version) and plotting is ridiculously easy.

  Are you sure? yes | no

David Scholten wrote 09/27/2018 at 12:45 point

I've spent waaaay too much time on this and won't dedicating another project log to it, but I've uploaded a 50MB collection of very beautiful Fusion 360 PCB/enclosure renders to the files section. The best of the best (naturally) have become the cover photos you see up the top and top-left. Enjoy!

  Are you sure? yes | no

David Scholten wrote 09/06/2018 at 01:26 point

Orders for the PCBs V2 are away as of the 2nd September! Some critical changes to footprints and safety warranted a new revision. The total cost for 10 unloaded boards was about $30 (including express DHL shipping) from Seeed Fusion (posted to Australia).

  Are you sure? yes | no

chibill wrote 08/23/2018 at 21:26 point

Would this work properly on 60Hz 120V American Power lines? Or would some parts have to be slightly changed?

  Are you sure? yes | no

David Scholten wrote 08/24/2018 at 00:00 point

Hi Chibill, to adapt it to 60Hz/120V you would need to to replace the two transformers:

with equivalent 60Hz/120V variants.

Additionally you would need to remove one of the divider resistors and change the tiny input filtering capacitor that is in parallel with that same resistor (or just remove it, I doubt it will have much of an effect).

Once I have the PCBs/parts and I can test the design I'll upload the CAD files along with regional variations (if I can find alternate transformers in the same footprints).

  Are you sure? yes | no

chibill wrote 08/24/2018 at 00:31 point

okay. Sort of figured the transformers would have to be replaced. (As that would lower the voltage on the inside of the device if it wasn't changed)

  Are you sure? yes | no

David Scholten wrote 08/15/2018 at 12:54 point

Orders for the components are away as well! The total cost shared between Element14 and Digikey (including shipping and everything) was $137AUD. I did over-order on a fair few parts to provide a few likely spares though.

I'd rate that new sub-$1000 Australian GST tax a solid 3/10. Ouch.

  Are you sure? yes | no

David Scholten wrote 08/11/2018 at 02:10 point

Orders for the PCBs are away! The total cost for 10 unloaded boards was $18USD (including shipping) from Seeed Fusion (posted to Australia).

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates