Mains Frequency Measurement¶
50 Hz AC mains power goes through a rectifier and optocoupler and we have a 100 Hz (2 * 50 Hz) digital signal isolated from mains power. A ATmega328 (same MCU as on the Arduino) counts these pulses. Every 100th pulse it asserts the interrupt of a u-blox ZED-F9P GNSS receiver. The receiver outputs a UBX-TIM-TM2 message with the precise absolute timestamp of the time when the interrupt was triggered. We can now calculate the precise mains frequency using these timestamps. The values should be accurate to at least 1 us (I think).
Credits: https://revspace.nl/MainsFrequency, https://www.electroschematics.com/detector-module/
created: 2022-11-30, updated: 2022-12-06