Introduction: 8-64 Channel FFT Spectrum Analyzer
This is related to the FFT Spectrum analyser. It has 8, 16,24,32 or even 64 frequency bins (channels) and you might be able to double that number of bins if you modify the firmware.
The pcb is capable of driving a matrix of pixelleds ( WS2812 or led matrix) or you can connect one or more HUB75E displays but you will have to make a choice which one to use and adjust the parameters in the settings accordingly.
You can connect your audio signal by using the audio input or you can use the microphone input to connect a small condenser microphone. Although using the microphone will limit the frequency response because of its limitations.
The input sensitivity is automated and it will adjust to the levels off the input. You can adjust brightness and peak hold time. When it does not receive any input signal, after a while, it will go to fire mode in which some leds/display will light up like a fire.
I used two HUB75E panels for my prototype as I mounted them on a wooden stand. The PCB was mounted to the back of the display. I designed a PCB for the electronics. The PCB can be purchased at my Tindie web shop. The firmware (Arduino Sketch ) is open source and you can modify it to your needs.
Here are the specs:
- Line in Audio
- Mic in Audio
- 8,16,24,32 or 64 channels
- Different patterns and colors
- Adjustable Peak Delay time
- Selectable input filter
- Auto change of patterns every few seconds ( can be set to on/off)
- Based on ESP32
- PCB available with onboard pre-amplifier and connector or HUB75 Displays
- Can drive ledstrip like WS2812 and similar
- Can drive series of HUB75€ Panels
- Adjustable overall brightness
PCB available with SMD components pre-assembled. You will only need to add the ESP32 board and the connectors / opamp and sockets.
Schematic and PCB layout and gerber files( PCB production files) available
Work in progress:
Future firmware update will include:
- Smooth LED transition as the LEDS are so fast it will follow the datastream. I want to implement a sort of afterglow on each led when it turns of. That will moving bars will look less hectic.
- Web interface, I would like to output data on wifi to visualize the spectrum live on a webbrowser. Although technically this already has been done, the challenge will be the use of the ADC's at the same time. Those of you who know the architecture of the ESP32 will now what I mean.
- Changing the number of bands runtime unlike now it is done before compiling and can only be changed by uploading the firmware with changed parameters.
- Elaborate and automatize the calibration modes.
Step 1: Hardware
I designed a PCB that you can buy at my Tindie store:
All SMD components are preassembled and you only need to add some sockets, connectors and e ESP32 board.
I used the ESP32 DEVKIT V1 from DOIT
you also need a decent power supply, feeding this PCB and displays or ledmatrix with USB only will destroy your ESP32 because the onboard regulator cannot handle that much power.
You also have to decide what visualization you are going to use. You can use one or more HUB75 displays or you can use a pixelled based matrix. You can buy a matrix or you can make one with several ledstrips.
You will need to adjust the settings in the arduino sketch accordingly.
Step 2: Prepairing the Arduino IDE
I used the Arduino IDE. It is freely available online and it does the job. However, I recently stumbled on something called Sloeber Beryllium which is a great tool that offers a much better compiler interface. However, it has a bit of a learning curve but I promise, it's worth it! Why don't you check it out? You can also use Visual Studio or some other great IDE. However, it is important the right library and it is best not to install what you don't need as it might give you errors when compiling. Make sure that your Arduino IDE is set for using the ESP32. If you don't know how to do so, google or look it a youtube video. There are some very clear instructions and setting up the IDE is not hard. You can do it! In a nutshell, it comes down to this:
1. In the Ide preferences window, look for the line: Additional Boards Manager and add the following line;
2. Go to your board manager and look for ESP32 and install the ESP32 from Espressif Systems.
3. Select the correct board before you compile and you are good to go
Step 3: Uploading Your Sketch
When you'r Arduino IDe is good to go for using the ESP32, you can continue by installing the needed libaries.
the libraries that you will need to install using the Arduino Library manager. These I the versions I used. Higher version might work just fine.
- Adafruit_BusIO at version 1.7.1
- Adafruit_GFX_Library at version 1.10.4
- arduinoFFT at version 1.5.6
- ESP32_HUB75_LED_MATRIX_PANEL_DMA_Display at version 2.0.5
- FastLED at version 3.4.0
- FastLED_NeoMatrix at version 1.1
- Framebuffer_GFX at version 1.0
Remark: I had some trouble compiling when I started. Turned out that Arduino IDE had many libraries activated and it decided to choose the wrong ones whenever it had to choose between libraries. I solved it by uninstalling the Arduino IDE and re-installing it from scratch.
Did you select the correct ESP32 Board for you sketch? check your settings or it will not compile. Next, is compiling the sketch and trying to upload it to the microcontroller
Step 4: Adjusting to Sketch to Your Needs
There are several settings you can change to your likings:
You can select 1 of 2 option for visualizing the spectrum data. You have to make a selection in the settings panel of the Arduino sketch to match your setup. You can use WS2812 or similar ledstrips/Matrix or you can use HUB75 displays.
// select one of these and comment out the other
Using one or more HUB75E Panels
You can connect several panels together to increase the height or width of your matrix. In my prototype, I used two 64x64 HUB75E panels. So the height of my matrix was 64 pixels and the width was 128. Depending on the type of HUB75 display you are using, you might have to change some of the parameters to get it to work correctly. Also note that it is not likely that two panels with different chipset will work together. If you need more info on how and what, regarding these panels, take a look at the github of the driver, all info ( and driver) is here:
The following settings apply to the use of this panel:
#define PANEL_WIDTH 64
#define PANEL_HEIGHT 64 // Panel height of 64 will required PIN_E to be defined.
#define PANELS_NUMBER 2 // Number of chained panels, if just a single panel, obviously set to 1
Using Pixelled Matrix
The software was tested with two Led Matrixes that where connected together. Each matrix has a dimension of 16x16 pixels so the led matrix I tested with was 16 pixels in height and 32 pixels wide. Remember that the more leds you use, the slower the matrix will be. If the matrix is too big, it will react visibly slow.
You can tell the firmware how your ledmatrix is configured by changing the following parameters
FastLED_NeoMatrix *matrix = new FastLED_NeoMatrix(leds,
NEO_MATRIX_BOTTOM + NEO_MATRIX_RIGHT +
NEO_TILE_TOP + NEO_TILE_LEFT + NEO_TILE_ROWS);
// Ledstrip settings
#define CHIPSET WS2812B // LED strip type
#define LED_PIN 21 // LED strip data Pin
#define COLOR_ORDER GRB // If colours look wrong, play with this
#define LED_VOLTS 5 // Usually 5 or 12
#define MAX_MILLIAMPS 2000 // Careful with the amount of power here
const uint8_t kMatrixWidth = 32; // Matrix width --> number of columns in your led matrix
const uint8_t kMatrixHeight = 16; // Matrix height --> number of leds per colum
Step 5: Wiring
The wiring is not that difficult. The wiring diagram is shown on the photo
I used shielded wire to connect the microphone and the audio input and I used some general wire for everything else.
Give some extra attention to the power lines that feed the LED Strips. You must wire the data lines in series, meaning that the data out of one strip will be connected to the data in of the next. Etc. You can also do that with the power lines, but I would not recommend that. It is better to feed each strip with its own power. This will keep the current trough the power line limited for each wire and it will better distribute the power to all leds.
HUB75E display wiring
If you are using HUB75 Panels, make sure to use a decent flatcable and keep it's length as short as possible. Simple connect the flatcable to the PCB and display and don't forget to connect the powerline. Be warned: If you are using a large panel or several at at the same time, the on board 5V connecter shouldn't be used. Wire the panel directly to a 5V supply instead.
LEDSTRIPS / Matrix wiring
The ledstrips or matrix is connected using three wires only, gnd, +5V and the data line.
Step 6: The Arduino Sketch Explained
In general you can say that the program in running in repeated mode. Every loop, it will process data from a buffer using FFT. The buffer itself if filled with data in the background while the main program is running by using I2S direct communication. One of the perks of the ESP32. The FFT data is analysed and grouped into bars that are displayed. The ledstrip/matrix is controlled with a fastled library while the HUB75 display is driven using another great library with I2S approach. Each bar represents a frequency band and the code calculated the number of leds it should light up per bar. If the number of 'new' LEDS is lower than the number of LEDS that are currently on, it will initiate a dropping of the top light. The speed it used to drop is adjustable by a variable resistor. There is also a variable resistor to adjust the brightness of the LEDS. This brightness is limited in the software because a maximum brightness of all 280 LEDS being activated at the same time, could result in a very high current. The current input is limited by a 4A fuse. The traces on the PCB are not calculated for a higher current.
The unit has two switches, one to do a reset and one to change the operating mode. (Changing colours and patterns)
Although the ESP32 has a dual core and one can assign functions to a specific core, it is not used in this version because it is not needed. Although, that might change in the future when more functions are implemented. ( for example a web interface)
firmware can be divided into 9 files
- FFT_ESP_V1.0 main function and code
- FFT.h Specifications and settings for the FFT functions
- I2SPlUGIN.h Initialisation of the on board I2S audio functions
- LEDDRIVER.h Settings that are specific for HUB75E and/or Ledstrip
- PatternsHUB75.h All the graphic patterns specific for HUB75
- PatternsLedstrip.h All the graphic patterns specific for Ledstrip
- Settings.h All settings
- Fire.h code for fire screensaver
- Logos.h contains the logo data of The Electronic Engineer
You can download the latest sketch here:
Participated in the
1 Person Made This Project!
- kohlakhine made it!