Introduction: Spectrum Analyzer With Intel Edison

Transform your Intel Edison in an amazing spectrum analyzer to use in your audio applications!

With some C lines and terminal commands you will be able to visualize your favorite song in frequency domain or show the frequencies that compose your guitar notes.

Step 1: Setting Up Your Board

In order to compile and run the Discrete Fourier Transform and auxiliary toolkits included in our Spectrum Analyzer you will need latest Yocto firmware for Intel Edison or Ubilinux with mraa library installed.

Also, your board must be connected to your network and accepting SSH connections (Yocto users, run $ configure_edison --setup if you have not already).

For Ubilinux users: follow this tutorial from Sparkfun, but in step "Build and Install mraa", use command:

  • $ cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr -DBUILDSWIGNODE=OFF ..

to change default installation path to /usr. Python setup is optional for this Instructables.

For Yocto users: just go to the next step. libmraa is already installed in your system.

Step 2: Cloning and Compiling

Connect with your Edison board through serial or ssh and change working directory to selected folder to install the Spectrum Analyzer software (/home/YOUR_USER/ will work fine).

Type:

  • $ git clone https://github.com/renanlino/spectrumAnalyzer-edison.git

to copy my GitHub repository to your Edison board.

Now, change working directory to the new spectrumAnalyzer-edison folder and type:

  • $ chmod a+x compileFFT.sh && ./compileFFT.sh

to generate binaries. GCC will use your libmraa installation to compile the software.

Read README.md at GitHub to detailed description of software configuration.

Step 3: Connect With Edison Through SSH

In order to obtain an acceptable drawing frame rate you should connect with your Edison board through SSH interface. The serial interface and its slow transfer data rate will decrease the quality of output.

This step must be made at your desktop or notebook, not in Edison board.

Linux users: just open a terminal and type:

  • $ ssh YOUR_USER_AT_EDISON@EDISON_IP

Enter password used for Edison login and go to Spectrum Analyzer folder.

Windows users: download and install putty. Run putty and select SSH option in main screen. In Host Name field, type Edison board IP. In Port, type 22, then click Open. Enter with your login and password for Edison user and go to Spectrum Analyzer folder.

>>>> Important! You need at least 130 horizontal lines to correctly display the Amplitude x Frequency graph. Maximize your terminal session window before going ahead.

Step 4: Wiring

The input signal must be entered in Analog Pin 0 by default. You can use analog sensors, signal generators, microphones or your PC's sound card[1] to generate electric signals to analyse.

For now, we will connect the Sound Sensor from Grove Starter Kit, but, again: you can connect any analog device. Just remember to connect device ground with Edison's Ground Pin.

>>>> Important! Please note that Intel Edison Arduino Breakout Board can't acquire negative signals. There is no problem if you feed the Analog Pin with negative tensions, but the AnalogRead() of mraa library will result in 0V for any negative input level. If you want to analyse musics playing from your PC's sound card, keep this note in mind: only positive parts of signal will be considered. To correct this behaviour, add an offset level to your input signal (check the optional step II to learn how to make a circuit with operational amplifier).

[1] Check the optional step to learn how to make an earphone with breadboard output.

Step 5: Running!

After compiling, connecting and wiring, let's run the Spectrum Analyzer! Inside spectrumAnalyzer-edison folder, just type (remember to maximize window before):

  • # ./bin/fft (may require elevated privileges: login as root or add sudo before command)

The fft software will clean your terminal window and start drawing the Amplitude x Frequency graph. Put some awesome music to play and enjoy your spectrum analyzer!

To stop, press CTRL + C.

>>> About the examples

In the first video (Game of Thrones Opening) I put the signal directly in Analog In Pin with my earphone with breadboard wires (see next step). In this case, the negative parts of signal were ignored.

In the other two videos I place my sound sensor (a microphone from Grove Kit) near my notebook's sound output and the terminal session shows the spectral modulus from 0Hz to ~5.1kHz of the playing music.

Learn more about Discrete Fourier Transform with this Wikipedia article.

>>> About maximum frequency and aliasing

Note that audible frequency spectrum goes up to 20kHz, so we are visualizing only one part of the "real sound". But 5kHz allow us to capture the entire voice spectrum and is enough to get an awesome effect :)

The maximum frequency depends only of the sampling rate (read more about Nyquist sampling theorem). In Intel Edison the sampling rate is about 10.2kHz, and there is no way to improve it using mraa.

In this three videos I didn't used a low-pass filter to avoid the aliasing effect. But I heavily recommend that you use one. With an 330 Ohms resistor and a 0.1uF capacitor you can build a low-pass filter with cutoff frequency of ~5kHz.

>>> Network performance

Weak WiFi signal or busy network will affect graph's performance (check the "Set Fire to the Rain" video).

Step 6: Optional Step I: Make an Earphone With Breadbord Connections

It's a very simple idea: remove one side of your old earphone and replace with two breadboard cables.

  • Remove one side of earphone
  • Remove external isolation
  • Join each breadboard cable to a wire (I recommend soldering). There is no polarity.
  • Add some individual isolation and then add external isolation

With this earphone you can obtain signals from any device with P2 connection (such as your PC, smartphone or tablet) and feed your Spectrum Analyzer.

Just connect one wire to Edison's GND Pin and one to Analog In.

There is a good site to generate frequencies or sweeps.

Step 7: Optional Step II: Make an Adder Circuit

This circuit will add an offset to your audio signal, avoiding the rejection of negative parts mentioned in step 4. This circuit uses a LM358 as non-inverting adder. It will add your audio signal (Audio In in the figure) with a continuous tension of 2.5V

You will need:

  • 1x LM358 IC (Dual Op-Amp)
  • 4x 1k Ohm resistor
  • 1x 470 Ohm resistor
  • A breadboard and some breadboard wires

Just follow the attached schematic (in Fritzing or classic version).