This code measures the mains frequency of 50Hz.
The signal source is a SINE wave.
The sine wave from the output of ZMPT101B
Main parts:
ESP32 - D1
ZMPT101B
TFT display 240x240 - ST7789
This is how the code measures the mains frequency.
The signal is a direct output from ZMPT101B
The code search for the first LOW level of the code
When this is found - the code continius to look for the max of the signal or a level a little below max.
Then the START time (usec) is saved.
Then the code search for the HIGH level of the code
Then the END time (usec) is saved.
The code can measure relativly low frequences - up to 1kHz.
1. Measure the sine signal and find the max and min values
2. update the values in the code to the measured values with a margin of min. 100
3. You can use the file: Code-2023-05-v1.0-ESP32-ADC-Levels.ino