When I was working on the Morse Code Decoder project I got unexpected results from the output of of the KY-037 audio module. The output was being monitored by an interrupt in the Arduino Nano. It was triggering far more than I expected. I wondered if it was triggering at the frequency of the audio tone of the Morse code being received.
Rather than research it online I decided to have a go at investigating it myself. I wrote a simple sketch that counts the number of times the interrupt is triggered and at regular intervals does a simple calculation and displays the results as Hz. I’m sure this is all widely known, but it was enjoyable working it out for myself.
It is triggering once per wave of the tone it hears. While monitoring a steady tone I found it to be reasonable at displaying the frequency. I used this online tone generator for testing. Results were fairly consistent from below 100Hz up to 20kHz. I had to crank the volume up a bit and hold it close to the speaker for 20kHz, I presume because the speakers I have don’t work well at that frequency.
Here is a closeup of the audio module. It is a cheap one from ebay.
I’ve uploaded the code for anyone interested to by GitHub repository https://github.com/garrysblog/Audio-Frequency-Measurement-Test
Leave a Reply