# ESP8266/ESP32 Audio Spectrum Analyser using FFT

### Overview

This project converts an analogue signal and displays its frequency components in the form of a spectrum of 7 octave bands on an OLED display. To do this, it uses a Fast Fourier Transform which is a sampling theorem that is a fundamental bridge between continuous-time signals (analogue signals) and discrete-time signals. It uses a sample rate that enables discrete sequences of samples to capture all the information from a continuous-time signal of finite bandwidth.

Two versions are support, an ESP8266 variant that can analyse analogue signals with a maximum fundamental frequency of 5100Hz (5.1KHz) with a sample size of 256 elements. This limit is determined by the Analogue to Digital Converter (ADC) speed which can convert at a rate of approximately 10Khz. The second is an ESP32 variant that can analyse analogue signals with a maximum fundamental frequency of 20,000Hz (20.0KHz) with a sample size of 512 elements. This limit is determined by the Analogue to Digital Converter (ADC) speed which can convert at a rate of approximately 40Khz.

The system is comprised of the processor either ESP8266 or ESP32, an OLED display either 0.96″ or 1.3″ and a audio microphone unit that is comprised of an electret microphone and amplifier. The received audio is applied to the ADC input of the process. Note: Most ESP8266 development boards have an on-board voltage divider to limit input voltage, for example on the WEMOS D1 Mini 5v peak-peak are reduced to 1v peak-peak. The ESP32 tends not to have any input voltage dividers.

### FFT Elements – Sample Size and Sampling frequency

Sample Size – The FFT-algorithm defines a set of samples for the analysis results to be stored in. For most algorithms, the number of samples is usually a factor of 2, so 16,32,64,128 or 256 are not unusual. The greater the number of samples the more time it takes to convert an analogue signal, but the greater the frequency resolution and discrimination will be.

Sampling Frequency – Reference to the Nyquist-Shannon Sampling Theorem says sampling of an analogue signal needs to be at least twice the frequency of the signal being analysed, this limits the maximum frequency to half of the sampling frequency.