To sample sound I needed to sample fairly fast, faster than what the Arduino supports using analogRead, which is about 8khz. For my project I'd like to work in the range that humans can hear, which is up until about 20khz, and to take the Nyquist Theorem into account, I'd need to sample at about double that rate, at about 40khz. Luckily this can is achievable on an Arduino, which I did by implementing this method (Thanks to amandaghassaei for sharing). Testing my implementation with a frequency generator I found that it wasn't entirely precise, but the current implementation could be redone using interrupts to increase precision - I might fix that later.
To process the incoming signal I applied the arduinoFFT library, and formatted it all using ArduinoJson, to make it easier for my backend to digest.
The code is available on the github for the project, https://github.com/Lazarus9000/WashingV2/blob/master/logtest1.ino
Here's a quick demo of sampling on the machines, showing the FFT for the two microphones over time. The visualization is a quick hack, so there's some bugs with it, and I clearly have some debugging to do regarding sampling and FFT, but it was great to see some sort of result of my efforts.
The blue area was a wash cycle, and the red was a tumbling cycle. Both are approximations if there was any doubt.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.