We all know the frequency of our AC grid. 60Hz for Americans, or 50Hz for Europeans, for example. But the real story has some complexity. In a plural but interconnected grid such as Europe’s, that frequency can drift around a nominal center value. To keep track of this, [Jeroen Brinkman] has created a grid monitor that can show long-term trends as well as instantaneous frequencies.
Hardware-wise, it’s somewhat old-school, with an Arduino Uno and a ubiquitous 2×16 character LCD, but the interest here lies not in the microcontroller. Sensing mains frequency is fraught with spicy high-voltage danger if done directly, so [Jeroen] is performing the task using an optocoupler that toggles an interrupt pin on the Arduino. The monitor stores long-term data by the week, using only four bytes per week. That means the monitor can hold up to 240 weeks, or about 4.6 years, on a Nano R3 and over 2,000 weeks, or around 39 years on a Nano R4. The data can be retrieved via serial transfer over the Arduino’s USB port.
The subject of grid monitoring is a fascinating one, as geopolitical events can show up in it. Back in 2018, we covered the moment when Europe lost six seconds as a result.

The best way to describe these things are as “Zero Crossing Detector”. As that is what they are doing: Detecting when a AC signal is crossing the Zero.
Taking the optocoupler approach is a good way to go about it. Do believe i’ve seen such implementations in a few EV Charging Equipment as part of their grid monitoring. Also seen a implementation where a Transformer is used to create a smaller AC Signal for a comparator to work.
Personally. I’d probably jam in a AVR-Dx chip or similiar. These come outfitted with integrated ZCD specifically for this kind of stuff and can simplify things a little bit. Don’t underestimate what kind of exotic little features you can find in microcontroller these days!
I wonder if it would be possible to use an antenna to listen to the static around 50 (60) Hz over the air without actually connecting to the grid.
Yes, that would work, BUT this would also pick up all the other frequencies that populate our electric grid. And since this project is about checking the 50/60 Hz, it doesn’t work. You really only want the grid frequency, nothing else.
For more info on grid pollution look for ElektroSluch or EMF-Explorer-badge.
This pollution is the main reason why grid frequency dependent clocks on microwaves or ovens run fast.
An antenna with a bandpass filter at 50 Hz will probably work.
You can use a small coil and op amp to detect the magnetic field…very easy.
An optocoupler based on an traditional incandescent lamp+selenium cell or solarcell would be “better” here because the lamp operates on both AC and AC natively.
The newish optocouplers of the past decades do use a light emitting diode+phototransistor or photodiode combo and as such flickers on AC.
Just like the bicycle lights by some, um, simple minded people do who wired a LED lamp (DC) as a modern subsitute directly to the 6,2v AC dynamo..
WIthout OCXO or GPS signal you might as well display some random value between 4900 and 5100.
All the effort to design pretty user interface and stuff is moot when the very fundamental part of the project is flawed.
Count and middle the clock cycles between zero crossings for a long time and for a short time, then the instantaneous frequency is 50 (or 60) Hz times the latter divided by the former. The “long time” should be correlated to the drift your clock can manage, absolute clock precision is not necessary. For smaller variables and faster clocks it is possible to ignore the highest bits, as long as the observable frequency window is larger than the largest expected frequency deviation.
The grid frequency is almost never correct because it is allowed to drift, and because it is then deliberately made to drift the other way for time-error correction. They’re not required to maintain any particular average frequency just so long as they stay within +/- 20 seconds of correct time at the end of the day, and stay within the steady-state frequency window between 49 – 51 Hz in the typical case. That way, small deviations from the average 50 Hz may persist for weeks and months and bias your measurements.
Meanwhile, your CPU oscillator or RTC module like the DS1307 they propose also drift by an unknown and variable amount, so the number of cycles per second you count doesn’t remain constant over time even if the grid frequency actually did. You’re measuring one random variable against another random variable that both keep drifting independently.
The DS3231 is a temperature compensated RTC with 2 ppm accuracy over a year, which does fix the problem, or at least gives you a knowable error band. It’s pretty much mandatory if you want to follow long term trends.
Also, here’s an interesting question: if you have a grid failure and have to disconnect the grid into two sections, the time error in those two sections will then drift independently and most likely very rapidly. Then you re-connect the two back together and synchronize. Whose time error do you now compensate for? Or do you just reset the clock for all and start over?
I’d reconnect after adjusting the clock drift (but I don’t know how it is really done).
With the clock counter you will see the sum of the grid frequency shift and the clock drift, but usually after some time the clock drift is much slower than the grid frequency shift you are going to see.
For observing the grid time error, measuring the frequency and then integrating the difference to the mean value is probably not very reliable.
Typically, they stay in a 49,95..50,05 Hz window. To see if something special happens, you only have to detect if the frequency quickly leaves that window. The specialty then is either a grid problem or a failing clock oscillator.
If you’re going to complain about fundamentals then it’s best to be correct about said fundamentals. Even crappy internal oscillators are more than sufficient to determine frequency errors with the precision presented here.
The clock signal will shift the results, but is unlikely to be random error, it’ll be high or low and stay there unless the temperature changes drastically. Once it’s running for a few minutes that drift should settle out. The difference between the clock and actual frequency will result in the samples being shifted accordingly, but the change in grid frequency over time will be representative.
Now, if it is sitting near a heating or cooling element in a room, near a window and draft, etc, the variance will also drift and values from different times of the day, season, etc won’t be comparable.
That is the issue: daily and seasonal variability. Nearly everyone’s house gets hotter or colder at times, and the idea is to compare long term trends so you kinda want to eliminate that effect. You could put the thing in a box and maintain constant temperature and humidity, air pressure, whatever is needed, and then calibrate your drift out.
Or you could use a proper frequency standard in the first place instead of an Arduino.
“Back in 2018, we covered the moment when Europe lost six seconds as a result.”
It was six minutes, as even the link you posted shows.
I just grabbed data from ERCOT which includes integrated frequency error. In seconds. I didn’t get all of the 2021 blackout because, blackout.
I used to doing substation maintenance for a US power company. Every substation monitors frequency very closely with specialized sensors. If the frequency ever gets more than 0.5 Hz above or below 60Hz, the circuit breakers trip, taking the substation off-line. So I am dubious about the utility of this device.
Are people seeing variations of more than 0.5 Hz?
I still get a headache the first few hours of arriving in Europe. I don’t know if I am “Frequency Sensitive,” but I hear the differences in the power output of the fluorescent lights and transformer hums. It is almost akin to that of watching LED lights out of the corner of your eye and see the flashing. I guess some people are more sensitive to frequency shifts along with those that want to keep perfect time constants. Does anyone else have that problem?
Which country ? In France, the powerlines are highly polluted by PLC.
I can tell tell you which hour it is just by looking at fluorescent lights.
power line comms?
PLC (Powerline Communications) aka CPL (Courants porteurs en ligne) in France.
CPL G3 is used by Enedis ‘s Linky the spybox that reports your energy consumption through the powerlines.
We have cheap LED lamps without smoothing caps in the lamps “power supply”..
It’s basically an LED wired to a cheap diode.
Since the days of that darn “CE” sign we’re flooded with cheap products from all over the world.
I miss the 90s, when we still had real compliance stickers and hard RFI regulations.. 😢
I live near a “Rundsteuerung” transmitter. Basically a day/night electricity tariff information is modulated (around 1 bps) onto the 50Hz grid. The signal is strong enough to cause crappy LEDs to flicker visibly. You can hear it also through metal pots on an induction heater. Perhaps that’s what you’re looking for?
We used to have that in France but now we got the even “better” v2.0 it’s night and day, all day long and bidirectionnal. Pure crappiness.
Or the headaches could be “jet lag,” or a reaction to the pressure changes from flying, or delayed motion sickness. It would be an interesting thing to try and narrow down. If you are ascribing the issue to frequency, that implies that you’re coming from North America or Japan. The distance alone might explain some ill effects.
If you want to watch paint dry: https://www.netzfrequenzmessung.de/
Dankeschön! 🙂🖤
What’s missing on those monitoring webpages is the noise level, unfortunately.
It’s not their fault, of course, because the noise level is different in each country/federal state/city or even street.
But it’s one of these little things that people may forget to think about.
A perfect 50/60 Hz frequency with perfect phase levels is of little help if the AC in the mains outlet looks more like a sawtooth than a sine.
I’ve once checked my mains with a CRT oscillograph and I got a bit pale and scared by looking at the waveform.
If it was a person I would have called an ambulance.
Things like this make me glad that residual current circuit breakers (better known as RCDs) are now mandatory, at very least.
In such cases, power strips with AC filters and ferrite clips on various cables (DC cables, USB cables etc) are worth thinking about, I guess.
Simple things like AM pocket radios might also be useful to detect noise sources, I guess.
Though an SDR might be even better, I guess.