Open Source FFT Spectrum Analyzer

An FFT spectrum analyzer for machinery vibration analysis, using open source hardware and software

Similar projects worth following
A computer running a program written in Python and using the libraries, Numpy, Scipy, Matplotlib, and Pyserial is the FFT spectrum analyzer. An Arduino Nano is used as the data acquisition system for reading acceleration form a ADXL335 accelerometer.
This combination makes an effective, simple and low cost FFT spectrum analyzer for machinery vibration analysis.


Machinery vibration is usually the best indicator of overall mechanical condition. It is used in preventive and corrective maintenance.

It can be measured using displacement and velocity transducers, and accelerometers. You can get an overall reading indicating the maximum value of vibration, but the most useful information is obtained with a FFT spectrum analysis of a time period reading.

Machinery vibration analyzers are usually expensive and complicated and many small and medium sized industries can't afford this instruments, particularly in my country (Bolivia).

Open source hardware and software tools are very accessible this days, and a simple, inexpensive and open source FFT spectrum analyzer can be easily built using some of this tools.


For this project, an Arduino Nano is used as the data acquisition system, it contains an USB to serial converter and ADC channels. A common accelerometer, the ADXL335 is used as the transducer for vibration measurement, and a computer is the FFT analyzer, using Python and Numy, Scipy and Matplotlib libraries.

A system diagram is shown below.

The Arduino Nano listens for an incoming command from the computer, that tells it to start or stop sending ADC readings. The ADC reads the accelerometer vibration channels on a given sampling frequency (5000 Hz), controlled by one of the micro controller timers. This readings are sent on the serial port at a speed of 0.5 Mbps.

The Arduino Nano program (adxl335_01.c ) is compiled with Avr gcc, and programmed using Avrdude and the Arduino Bootloader installed in the atMega328 microcontroller. The Arduino libraries and IDE are not used.

The ADXL335 is a small, thin, low power, complete 3-axis accelerometer with signal conditioned voltage outputs. Maximum bandwidth is selected for the application, with a range of 1600 Hz for the X and Y axes. The Z axis maximum range is 550Hz, and is not used because the limited range, but it is wired to the micro controller in case it is used in the future.

A circuit diagram is shown next.

The computer controls the data acquisition sending commands to start or stop the transmission of samples. The program counts the amount of data received and the amount of data it needs (sample size). When the necessary amount of data has been taken, a command to stop is send to the microcontroller. Pyserial is the python library used to control the serial communication.

The serial communication is binary based and a mechanism to mark the end of packages is necessary. A PPP type byte stuffing algorithm is used for this. In PPP frame boundaries are marked with a reserved byte value 0x7E. This reserved value is not permitted to occur in any other place than frame boundary. In a case the reserved value should occur in data packet, an escape sequence is used to transfer 0x7E into byte sequence of 0x7D, 0x5E. The byte value 0x7D means that a possible escape follows and is called a Control Escape value. Also the Control Escape itself needs to be escaped and becomes to byte sequence of 0x7D, 0x5D.

This PPP framing algorithm is used in the Arduino Nano and on the python program for the computer.

There are two python programs, one for data acquisition from the serial port and saving that data, and the second for file opening, plotting of data and FFT spectrum calculation and plotting.

Program sends commands to the Arduino and reads data from the serial port. Once the desired amount of data has been acquired, it is saved on a file, as text, separated by comas and delimited by tags.

Program waits for a file name introduced on console, opens the file and plots the signal from the accelerometer. It is shown on the next picture.

Then, the FFT spectrum is calculated and plotted. It can be seen in the next picture.

This images correspond to a motor running at 1450 rpm (24.17 Hz). It can be seen that the peaks in the FFT spectrum are multiples of this frequency (24.17, 48.33, 72.5, 95.67, 120.83 and so on).

This... Read more »

ino - 4.82 kB - 04/10/2017 at 12:44


plain - 192.06 kB - 12/20/2016 at 19:20


FFT sperctrum analyzer for 3 accelerometer axis. Python 3.5

text/plain - 22.95 kB - 01/12/2017 at 20:18


FFT sperctrum analyzer for 3 accelerometer axis. Python 2.7

plain - 21.50 kB - 12/20/2016 at 19:08



AtMega328 program to send 3 accelerometer axis.

C Source File - 5.54 kB - 12/20/2016 at 19:08


View all 17 files

  • 1 × Arduino Nano Microcontroller atMega328 and USB to serial converter on a single and small board.
  • 1 × ADXL335 breakoutboard ADXL335 3-axis accelerometer and a breakout board to make signals accessible.

  • Correction in g calculation

    Ariel Quezada02/08/2018 at 14:41 0 comments

    An error regarding the g_scale for calculating g from accelerometer voltage was pointed and corrected by Steve Ferry (thank you Steve).

    adc_resolution = 3.3 / 1024 # Vref = 3.3V, 10 bit ADC.

    accelerometer_sensitivity = 1000/300 # 300 mv/g

    g_scale = adc_resolution * accelerometer_sensitivity = (3.3 / 1024) * (1000/300)

    The Python 3 program has been corrected with this new value.

    I think the mistake was to assume that +-3g would cover the whole ADC range, but it will cover only around 2 V, not all the 3.3 V (Vref) range.

    Looking through the ADXL335 datasheet, the output is ratiometric (proportional to supply voltage), and the 300 mV/g is the approximate value using a 3.0 V supply. This numbers can have around 10% variation between devices, so I think that an additional correction factor will have to be introduced and calculated (calibrated) for each different accelerometer used.

  • Third axis and Python 3.5

    Ariel Quezada12/20/2016 at 19:39 0 comments

    I have added a third axis to the spectrum analyzer. The atMega328 (Arduino Nano) program is adxl335_3can_01_en.c. The Python 2.7 program is

    I also made a version of the three axis analyzer that works with Python 3.5,

    There is also a file with sampled data for testing purposes datos_3can_20-12-2016__11_39_50.txt. Works with both versions of the 3 axis FFT analyzer.

    Notice that the accelerometer Z axis is limited to 500 Hz.

    This files are also available on GitHub at

    The screen shot is shown below.

  • GUI program with window functions

    Ariel Quezada07/13/2016 at 21:40 0 comments

    I updated the GUI program, and now it includes the window functions (rectangular, Hann and Flattop). These functions can be selected using radio buttons.

    This is a screen shot of the new GUI. The radio buttons are at the end of the left panel.

    I also uploaded some text files with acceleration measurements. The file names start with “datos…” and a date and time. These files can be used for testing.

  • GUI program

    Ariel Quezada06/24/2016 at 19:39 0 comments

    A program with a GUI has been developed ( It uses the Tkinter library, basically because it is the one included with Python, and no additional programs are needed. Also, it integrates very well with matplotlib.

    The new program combines the programs and This new interface lets you scan serial ports, select the serial port, save the sampled data to file, and open files with sampled data previously saved. It also has a scrolled textbox where messages are displayed (the ones printed on the previous programs).

    A screen shot is shown below.

  • Window functions

    Ariel Quezada06/09/2016 at 15:15 0 comments

    Window functions are used to avoid signal leakage, that can hide low amplitude level signals when their frequency is close to high amplitude level ones. To avoid this leakage, the input samples are multiplied to a mathematical function, so the samples at the center of the sampled time are favored while the values of the samples at the extremes, are lowered. Usually Hann and Flattop windows are applied. Using Python and Scipy, applying window functions is very simple.

    First, you have to import the signal module

    from scipy import signal

    Then create the window function coefficients. For the Hann window use

    w = signal.hann(N, sym=False)

    For the Flattop window use

    w = signal.flattop(N, sym=False)

    N is the length of the signal (number of samples).

    Finally apply the FFT to the signal weighted with the window function.

    yf = fftpack.fft(y*w)

    Program plots the FFT spectrum using the window functions.

    After applying the window functions, no much change is visible in the signal frequency separation and only the amplitude is reduced. Apparently, signal leakage is low for the sampled data used, and further testing would be required to validate this functions.

  • Some testing

    Ariel Quezada06/08/2016 at 18:06 0 comments

    Three measurements on the same rotating machine were taken for testing the instrument response. The first measurement was taken without modifying the machine.

    The second test was taken adding weight to a certain place on the machine, for creating an imbalance. It can be clearly seen an increase in the magnitude of the acceleration, both in time domain and frequency domain.

    Finally, more weight was added to increase the imbalance and a third measurement was made. Again, an increase in the acceleration amplitude is observed.

    From the test results, it can be seen that the instrument can detect the imbalance variations, and seems to be working properly.

  • Software scaling correction

    Ariel Quezada06/07/2016 at 19:31 0 comments

    The original program was not properly scaled. The signals were plotted using the ADC values and the number of samples obtained.

    The signal size has been scaled to g. The ADXL335 has an output from -3g to +3g, for a voltage range from 0 to 3.3 V, that is converted by the ADC to values from 0 to 1023. The original signal is multiplied by 3.0/512, and then the DC offset is determined, taking the average of all the readings. This approach assumes that the average value of the vibration signal is 0.

    A correction to the time scale has also been done, considering the sampling rate and the number of samples taken. Frequency range has been limited to 1500 Hz, the maximum frequency that the ADXL335 con provide on the X and Y axes.

    The corrected program is, and the resulting plots are now properly scaled.

  • Accelerometer probe construction

    Ariel Quezada06/07/2016 at 14:03 0 comments

    The accelerometer and the Arduino Nano fit together inside a plastic probe (camera film canister). A strong magnet is also included inside, so the probe can be attached very firmly to different parts of a rotating machine and measure its vibration.

    The accelerometer breakout board is soldered to a perforated board and three capacitors are connected and soldered, one to every analog output form the ADXL335. Header pins are placed at the sides of the board and arranged so this pins fit inside single line sockets soldered on the Arduino Nano, instead of the regular connector headers.

View all 8 project logs

Enjoy this project?



josiasguzatti wrote 12/15/2019 at 17:41 point

Hola Ariel Mi español es terrible Por favor, ignore algunos errores.
Me gustaría hablar idéias de algas intercambiais e intercambiais sobre su projeto, tengo un projeto semelhante.
correo eletrônico:

  Are you sure? yes | no

josiasguzatti wrote 12/15/2019 at 17:29 point

Hola Ariel Todo bien. Felicidades, buen trabajo. Me gustó mucho. Você está tentando dificultar ¿Como abrir arquivos Python, qual a versão que você abre arquivos? Por exemplo, desbloquear e instalar o Python 3.8, abrir o arquivo na sintaxe do problema do Python e carregar o arquivo. Você pode escolher uma versão especial do Python para abrir arquivos, como o Anaconda (araña, jupter). Cuide do programa correto para abrir, agradecido.

  Are you sure? yes | no

addiktsl wrote 07/29/2019 at 10:08 point

i have been into engine condition monitoring for the past few months. im working with a raspberry pi 3 model b+ presently and accelerometer ADXL345. can you guys send me the code. please. 

  Are you sure? yes | no

francisco.medellin.zertuche.16 wrote 03/26/2019 at 01:00 point

Hola Ariel, excelente trabajo,me esta sirviendo como proyecto en mi universidad y quisiera saber si me puedes ayudar con una duda, el programa , en que entorno lo puedo depurar? usaste vs code, spyder?? ya que actualmente estoy tradando con spyder y me aparecen errores en el codigo , ya tengo instaladas las librerias pero aun asi no me quiere arrancar el programa, agradeceria tu ayuda muchas gracias por tu tiempo saludos!!.

  Are you sure? yes | no

jobee G wrote 06/13/2018 at 20:07 point

Hola, muy buen trabajo, me gusto mucho tu trabajo.

Tengo una duda, el sistema que usaste para poner el acelerometro al motor, no afecta como amortiguador a la hora de medir las vibraciones?

Gracias :)

  Are you sure? yes | no

Ariel Quezada wrote 06/19/2018 at 16:34 point

Es posible. Creo que al colocar el acelerómetro al motor, siempre se pierde algo de información. La mejor forma es usar pegamento, pero es permanente. Con el magneto hay atenuación, pero el acople es temporal. El empaque usado para el proyecto es artesanal. Se puede usar un mejor empaque (tal vez fabricado con una impresora 3D) y una mejor conexión con el cable USB.


  Are you sure? yes | no

Juan Sebastian Galvis wrote 05/02/2018 at 01:26 point

Hello Ariel, I hope everything is fine.

you did an incredible project and very well developed, I am currently doing a project of degree related to your project and it has been very useful, but I do not know where you found the information of the ADXL 335 sensor coupling to the engine, since I see that by means of a magnet but this does not affect the measurement of the sensor by its magnetic field? or do you calibrate it with this magnetic field?

  Are you sure? yes | no

steve wrote 05/03/2018 at 14:24 point

Juan, adxl is not effected by magnetic field.

  Are you sure? yes | no

Juan Sebastian Galvis wrote 05/03/2018 at 16:28 point

Thank you very much, have a nice day.

  Are you sure? yes | no wrote 04/12/2018 at 19:29 point

Hi Ariel,

Awesome work and great project! It may be worth to noticed here that I have designed 

3 AXIS USB ACCELEROMETER. I think it can be very useful for this project. It is compact and ready to use out of the box. What is more it has a set of commands to set sampling frequency and data range.

Please check it here:

  Are you sure? yes | no

Ariel Quezada wrote 04/13/2018 at 21:21 point

Hi, it looks very promissing in size and features. Only some modifications would be required in the Python program to work with the communication protocol.

  Are you sure? yes | no

Fabrice wrote 03/29/2018 at 22:03 point

Good evening Ariel! 

thank you very much for sharing your project. He's very interesting. I would like to know if it is possible to analyze instead the spectrum of a 220V AC signal

  Are you sure? yes | no

Ariel Quezada wrote 04/02/2018 at 12:07 point

Yes, it is possible. You need a current sensor an read that signal with the microcontroller. Then apply the FFT to the acquired data.

  Are you sure? yes | no

steve wrote 04/11/2018 at 15:49 point

you could indeed use a current transformer with a mv/A output as Ariel has suggested or a voltage transformer providing it  is not rectified or smoothed but the voltage needs shifting to make it dc so that’s not straightforward. Whatever you use, make sure the voltage can not exceed 5V for an Arduino, 3V3 for an STM32/ESP32 device or its a gonner. Using a CT on one phase of a 3 phase motor can give you an indication of broken rotor bars etc by looking at the 2X slip frequency side bands compared to the supply frequency peak. The other thing is you want to change the sampling frequency to say 200 samples per second so the fft is 0-100 hz rather than 0-2500 hz or your resolution will be crap.

  Are you sure? yes | no

steve wrote 03/19/2018 at 11:33 point

Guys, I was inspired by all the good work done by Ariel on this project and wanted to develop it further. Had I not come across his code, I simply would have not known where to start and I must give him enormous credit for what he achieved.

In my version, sampling speed and sample length can be set. Also the number of channels 1-4. The number of channels could be higher but we need to get the data transmission finished before the next set of samples is due so more channels could equal lower max sampling rates. The data can be displayed as twf or spectras in acceleration, velocity and demodulated acceleration. My code can be found here there is Arduino sketches for both STM32duino and ESP32 both of which have 12 bit ADCs. Although I haven’t included code for the Arduino UNOs etc. it would be easy to take my code and change the interrupt routines by looking at Ariel’s code. I included a sequence number with the data which loops from 0 to 127 if no packets have been dropped, the last sequence number received will be 127 as all sampling lengths are a power of 2 for fft purposes. Also the python code appends a time stamp to the sample on saving it. Additional fields can be added to the file to include machine and point information but I haven’t got there yet.

As a vibration analyst of over 25 years, I am working on providing open source software which would give the best information for machine health checks. I’d be very interested in discussing results with anyone who puts ( wants to put) this to real world usage. Steve.

  Are you sure? yes | no

Ariel Quezada wrote 03/19/2018 at 12:39 point

Hi Steve, great job. I am glad I helped you to get started. Best regards.

  Are you sure? yes | no

RalphDazzle wrote 06/08/2018 at 15:32 point

Hi Steve, I'm looking to put something like this into a real world application. I'm a maintenance technician in a factory and we're a bit behind the times in terms of condition monitoring and preventative maintenance. I've tinkered with IoT for home automation in the past and stumbled upon someones audio spectrum analyser which reminded me of some of the Fourier analysis assignments I had during my apprenticeship.

Ideally, I'm looking to take periodic vibration samples from bearing housings throughout the factory, send them over MQTT and have them stored into a database for later review. I've had some success with generating FFT data from a piezo disc by doing the calculations on the Ardunio UNO, trasmitting them to an ESP8266 and broadcasting that to MQTT. I could quite easily store those values in a database on a Raspberry Pi but I'm struggling to find a way to chart them effectively.

I'm definitely not a programmer but resources like this one and your own are proving to be a fantastic set of lessons!


  Are you sure? yes | no

Gaurav Pradeep Jumde wrote 03/14/2018 at 12:58 point

Hi Ariel, Thank you. I just want to know how to eliminate the problem of import serial in the program of and the problem of raw_input in

  Are you sure? yes | no

Ariel Quezada wrote 03/19/2018 at 12:38 point

Probably the problem is that pyserial is not installed. While online, try 

pip install pyserial or pip3 install pyserial from the console or cmd in windows.

  Are you sure? yes | no

Gaurav Pradeep Jumde wrote 03/13/2018 at 07:23 point

Can we use ARDUINO UNO instead of ARDUINO NANO??

  Are you sure? yes | no

Ariel Quezada wrote 03/14/2018 at 12:04 point

Yes. The Arduino UNO and the NANO use the same microcontroller. The program runs on both with no changes needed.

  Are you sure? yes | no

Gaurav Pradeep Jumde wrote 03/14/2018 at 16:01 point

but A6 and A7 pins are not available on ARDUINO UNO. so what to change in adxl335_chan_01.ino program

  Are you sure? yes | no

steve wrote 03/19/2018 at 21:28 point

In order to use the UNO, it is necessary to change the ADC pins as A6 and A7 are not available on the UNO.

I modified the ADC read code to use the following


You can replace A0 with whichever pin you want. You need to declare rdg as an int at the top of loop()

  Are you sure? yes | no

svarun52 wrote 01/26/2018 at 16:19 point

Hi ,this is very amazing project ,i'm trying this project but i am getting some warnings in    python 35 like this

Warning (from warnings module):
  File "C:\Users\csc\Desktop\VARUN\CreaTech\FFT-spectrum-analyzer-master\3_axis\Python_35\", line 199
MatplotlibDeprecationWarning: axes.hold is deprecated.
    See the API Changes document (
    for more details.

Warning (from warnings module):
  File "C:\Users\csc\Desktop\VARUN\CreaTech\FFT-spectrum-analyzer-master\3_axis\Python_35\", line 205
MatplotlibDeprecationWarning: axes.hold is deprecated.
    See the API Changes document (
    for more details.

Warning (from warnings module):
  File "C:\Users\csc\Desktop\VARUN\CreaTech\FFT-spectrum-analyzer-master\3_axis\Python_35\", line 212
MatplotlibDeprecationWarning: axes.hold is deprecated.
    See the API Changes document (
    for more details.

Warning (from warnings module):
  File "C:\Users\csc\Desktop\VARUN\CreaTech\FFT-spectrum-analyzer-master\3_axis\Python_35\", line 223
MatplotlibDeprecationWarning: axes.hold is deprecated.
    See the API Changes document (
    for more details.

Warning (from warnings module):
  File "C:\Users\csc\Desktop\VARUN\CreaTech\FFT-spectrum-analyzer-master\3_axis\Python_35\", line 230
MatplotlibDeprecationWarning: axes.hold is deprecated.
    See the API Changes document (
    for more details.

Warning (from warnings module):
  File "C:\Users\csc\Desktop\VARUN\CreaTech\FFT-spectrum-analyzer-master\3_axis\Python_35\", line 238
MatplotlibDeprecationWarning: axes.hold is deprecated.
    See the API Changes document (
    for more details.

can u plz help me in solving this problem

  Are you sure? yes | no

steve wrote 01/30/2018 at 14:42 point

Hi Svarun52, Im no Python expert myself - only started using it 3 weeks ago. As I had those same warnings, I simply commented out the offending lines because they dont do anything as the command is deprecated and that stopped the warnings.

  Are you sure? yes | no

Ariel Quezada wrote 02/09/2018 at 12:27 point

Matplot lib

deprecated the ax.hold() function. Commenting or deleting the lines containing this function will have no effect on the program and the Python interpreter will not issue those warnings.

The Python 3 program has been modified accordingly.

  Are you sure? yes | no

Ariel Quezada wrote 01/17/2018 at 12:08 point

Hi Steve, thank you for the suggestions. I plan to add the velocity component, but I was thinking about integrating the acceleration signal. I think I will test both forms. I will also check the Hilbert transform and the imperial units.
About the STM32F103, I thought about using it (I have a few around), but it did not fit in the film canister I am using. I plan to fabricate a container using a 3D printer, so the STM32F103 would be a good option.
Another option I was thinking of was the ESP32, that has Bluetooth and WiFi included.
There are many things to implement this year.
Thanks, and your help is welcome.

  Are you sure? yes | no

steve wrote 01/16/2018 at 23:16 point

hi, I’ve been running my own vibration analysis company for over 25 years and an very interested in this project. I’d like to make some suggestions. In order to fully assess machine condition, it would be useful if you had another two tabs with different plots. Firstly, convert the acceleration to velocity where velocity at each peak can be determined by (acceleration X 9806.65) divided by ( 2 X pi X frequency)  the gravity constant converts g’s to mm/sec/ sec. velocity is in mm/sec. There could also be an option to show in Ipswich for those who prefer imperial measurements. Secondly, apply a Hilbert Transform to the timewaveform prior to fft to give an envelope or demodulated spectra. This shows any bearing fault frequencies hidden within the twf and is the best tool in the box as far as I’m concerned.

I’d also like to suggest using an STM32F103 ‘blue pill’ which can be programmed using the Arduino IDE, has a processor speed of 72mhz and 12 bit adc’s For a very reasonable price on aliexpress. Plus, how about Bluetooth rather than usb wired connection? I’d very much like to help with this project. Steve.

  Are you sure? yes | no

Pavel Bára wrote 12/01/2017 at 04:09 point

Conversion to velocity

I try to add to your code calculation of actual and effective velocity in mm/s.
I use this simple code.

Velocity_Last = 0
Velocity_Suma = 0
for indice in X:
Velocity_Suma += np.power(Velocity_Last + (9.8 * canal_1[indice] * 0.2), 2)
        Velocity_Last += 9.8 * canal_1[indice] * 0.2
Velocity_Effective = np.sqrt(Velocity_Suma / datos_a_leer)

print (Velocity_Effective)                
message_string = "Velocity X: {0:2.3f}\n".format(Velocity_Effective)
self.show_message(self.text_message, message_string)

Do you think it will work?
I will make some comparative measurement in two weeks.

I have one more question.
Acceleration is possible to integrate to velocity.
Suitable method for this is Omega Arithmetic method.

I find implemetation of this method in matlab.
But I am not able to conver this to python.
Can you help me with this?

Thank you
Best regards

  Are you sure? yes | no

Ariel Quezada wrote 01/19/2018 at 12:50 point

Hi Pavel, I have just started thinking about obtaining velocity and displacement from

acceleration, and I can not help you with this right now.

Thank you for the links you provided, they are very interesting and useful. I had not
heard about the Omega Arithmetic before, but it seems very promising, and I will try to implement it.

Best regards.

  Are you sure? yes | no

Pavel Bára wrote 02/09/2018 at 05:35 point

Hi Ariel, Omega arithmetic is the same what describe Steve above "divided by ( 2 X pi X frequency)". There is a problem on low frequency (big fault). I try to implement "Omega arithmetic" to your code. It is works. I can send my code to you, if you are interested.

Best regards

  Are you sure? yes | no

steve wrote 03/19/2018 at 21:34 point

Pavel, when you convert acceleration to velocity you will always have very large values for the first few bins. I simply set them to zero - effectively a HP filter. If for any reason you want to double integrate the acceleration to displacement, the problem is even more accute.

  Are you sure? yes | no

Ariel Quezada wrote 02/09/2018 at 12:34 point

Hi Pavel, I am interested in your code, and would like you to send it to me.
Best regards,

  Are you sure? yes | no

Pavel Bára wrote 02/09/2018 at 12:38 point

Can you write me your e-mail here?

I would like to send to you me code.

  Are you sure? yes | no

RENEE wrote 10/26/2017 at 14:24 point

Hi Ariel, I am trying to reproduce something very similar to your project.I would like to use your arduino code (.ino) but I've found some issues. Is it possible to start the data aquisition from accelerometer sending a character in serial monitor in the Arduino IDE? I tried to send "INI" but it isn't worked. How can I start the accelerometer throu serial monitor in the arduino IDE?

Thank you!
Best regards!

  Are you sure? yes | no

olem_de wrote 04/19/2017 at 12:02 point

Hi Ariel. a last question: I want to use your script also on other PC but not every has a python installed. so i tried to create  EXE file but struggled. I have tried py2exe successless. Do you have experience with this tool ? 

regards Ole

  Are you sure? yes | no

olem_de wrote 04/09/2017 at 18:01 point


sorry i tried to compile your arduino code but i failed. Is there a way to use the Arduino IDE to compile? I am not familiar with that avr-gcc stuff and the IDE failed with a lot of error messages

regards Ole :-)

  Are you sure? yes | no

Ariel Quezada wrote 04/10/2017 at 12:43 point

Hi Ole, It is possible to compile using the Arduino IDE, but you have to use its structure (setup and loop). If you use the IDE, you can use the Serial class to manage the serial port. I wrote the program for Arduino IDE and it´s included with the project files. To configure the timer and ADC it writes directly in the configuration registers. Regards, Ariel.

  Are you sure? yes | no

olem_de wrote 04/10/2017 at 20:40 point

Hi Ariel.thx so much. compiling and downloading works, but the read out values are just 0-values. Now i am not quite sure if my breakout is working or not (although it is a new one). Are the external capacitors (3x3.3nF) necessary?

  Are you sure? yes | no

Ariel Quezada wrote 04/10/2017 at 21:27 point

Ole, did you connect the 3.3V to the Aref input in the Arduino? The capacitors (2X 3.3nF, 1X10nF) are used to limit the signal bandwidth, and avoid aliasing problems due to sampling. Probably you can skip them because the bandwidth is limited in the adxl335, but I prefer to be sure.

  Are you sure? yes | no

olem_de wrote 04/10/2017 at 21:32 point

Yes you are right i found out in the same minute as you answered my post - i have forgot to connect aref to 3.3v. 

thx again :-))

  Are you sure? yes | no

Ariel Quezada wrote 04/19/2017 at 21:17 point

Hi Ole. Sorry, I have no experience with py2exe. I think that the problem could be with the numerical libraries, Numpy and Scipy, that use compiled code for optimization. I would rather work with the Python interpreter and install the required modules.

Regards Ariel

  Are you sure? yes | no

karimabdular.1605 wrote 03/10/2017 at 06:27 point

Hello Ariel, I heve project about vibration Analyzer and I want to try make same this one. 
I have Question for you. Can you explain to me how to  upload your arduino program to the arduino boart. thanks

  Are you sure? yes | no

Ariel Quezada wrote 04/10/2017 at 12:51 point

Hi, I am sorry I didn´t see your message before. I did not use the Arduino IDE for previous versions, but I rewrote the program to work with the Arduino IDE (setup, loop and serial). The program is adxl335_3chan_01.ino and it is inculded with the project files. If you use the previous version (.c file) you have to compile it using GGG end download it using AVRDUDE.



  Are you sure? yes | no

karimabdular.1605 wrote 04/11/2017 at 06:04 point

Yes Ariel. thanks so much for your respon. Now i have a finish running your python program and uploading adxl335_3chan_01.ino to my Arduino nano. Your project is very cool. I have tested your vibration analyzer on drilling machine and I got the result is very well. But i heve Question about this project, I see the data graphic will update if I click button read serial data and is not real time update on the graphic. 

I need your help, can you explain to me how to make the graphic is realtime update the data. Thanks

  Are you sure? yes | no

Ariel Quezada wrote 04/11/2017 at 16:37 point

Hi, I don't think the system can run fast enough to be real time. Maybe it can run in continuous mode, starting a new reading immediately after the previous reading finishes, not waiting for a button press. You nedd a certain amout of data to run the FFT.

  Are you sure? yes | no

karimabdular.1605 wrote 04/11/2017 at 17:29 point

Yes Ariel, I understand, but just now I have to finish make the program run in continuous mode. in this case modified this line


while (estado_serial == True):
            global g_canal_1, g_canal_2, g_canal_3, datos_a_leer
            canal_1 = []
            canal_2 = []
            canal_3 = []
            buffer = ''
            paquete = ''
            valores = []

            valores_decod = []

            conta_datos_rx = 0;         #Received samples counter.

            print("Sending INI")
            message_string = "Sending INI \n"

            self.show_message(self.text_message, message_string


I add while loop to the program. 
After I run the program. I got the reading is update continuesly but if I try to save file the and press button save file, the python GUI is not responding.

  Are you sure? yes | no

Ariel Quezada wrote 04/12/2017 at 12:10 point

You created an infinite loop that continuously will read the serial port, but I never ends. You have to make a call to read_serial(), the function called when you press the button to read data. This function should be called after it finishes reading data. Use a flag (boolean) to control start and stop reading. You can use a button to start/stop the readings also.

  Are you sure? yes | no

jslee777 wrote 01/09/2017 at 11:47 point

I need your help.

I think there are some problems in these parts       
while x < len(valores):                
if valores[x] == 0x7D:                    
valores_decod.append(valores[x+1] ^ 0x20)
----------------------------------------------------------------- error
Traceback (most recent call last):
  File "/home/pi/FFT-spectrum-analyzer/", line 92, in 
    canal2 = (valores_decod[2] * 256) + valores_decod[3]
IndexError: list index out of range

I have been tried to use try - exception error. it works, but some data are missing
Please let me know how to solve this problem

  Are you sure? yes | no

Ariel Quezada wrote 01/09/2017 at 12:57 point

Hi, I think the problem is in the incoming data (communication channel or microcontroller). The list 'valores' is formed when you receive a 0x7E byte, that marks the end of a data block, so when you analyze a block of data, you should alwas have either a 0x5D or 0x5E after a 0x7D byte. If not, there is an error in the data block received. Which OS are you working with? Which UART to USB chip are you using? I had problems with data loss when using a CH340 and Debian Linux. Regards.

  Are you sure? yes | no

jslee777 wrote 01/11/2017 at 12:48 point

Thank you for your quick response. As you said, there are some data missing problems with CH340 and Debian Linux. After  I changed CH340 to FTDI, it works very well. 

I have one more question about
I am not sure. but, I think there is a infinite loop in this part (it while conta_datos_rx < datos_a_leer:). Do you have any idea?

  Are you sure? yes | no

Ariel Quezada wrote 01/11/2017 at 21:59 point

You are right, the "while conta_datos_rx < datos_a_leer:" will create an infinite loop if the total amount of data expected is not received or if it is not foratted correctly (not enought 0x7E markers). I think that a timeout should be added to this loop. This is one thing that has to be added to the program. Thank you for noticing it.

  Are you sure? yes | no

Ariel Quezada wrote 01/12/2017 at 21:37 point

Hi, I added a timeout to the loop "while (conta_datos_rx < datos_a_leer)". I am checking the elapsed time since the loop started, and if it is longer than 8 seconds (defined in t_timeout), the loop will terminate.

The while loop part is now:


    global t_timeout
     timeout_state = False
     t0 = time.time()       #Start loop time stamp.
     while ((conta_datos_rx < datos_a_leer) and (timeout_state == False)):


        #Check if t_timeout seconds have elapsed since time stamp t0

        if ((time.time() - t0) > t_timeout):
             timeout_state = True


I updated the program with this changes.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates