Hello everyone,
I'm currently working on my Arduino based project of real-time audio spectrum analyser. I wrote the code in Arduino IDE, which gets the data from sensor and sends data to Matlab in order like frequency1, magnitude1, frequency2, magnitude2,... Data from Arduino is sent in one line. The problem is, that I get the error:
Warning: The specified amount of data was not returned within the Timeout period for 'readline'.
'serialport' unable to read any data. For more information on possible reasons
Can anyone help? Here is the code:
s = serialport(arduinoPort, 115200);
frequencies = linspace(600, fs/2, fs/2);
magnitudes = zeros(1, fs/2);
while toc(start_time) < measurementDuration
data_str = string(data_str);
data = str2double(split(data_str, {',', ';'}));
frequencies = data(1:2:end);
magnitudes = data(2:2:end);
plot(frequencies, magnitudes, 'LineWidth', 2);
title('FFT - Magnitude');
xlabel('Frequency (Hz)');