Hi, I’m trying to read data wiressely from an LSM9DS0 3-axis gyroscope using Arduino MEGA 2560 to MATLAB using the HC-06 bluetooth module.
This is the error I’m getting:
Warning: Unsuccessful read: A timeout occurred before the Terminator
was reached.
I’m using one computer that is connected to the Arduino MEGA 2560 with the Bluetooth HC-06 and LSM9DS0 wired to it.Then the other computer has MATLAB running code to read the gyroscope data wirelessly.
This is my MATLAB code:
%% Interfacting w/ HC-06 Bluetooth Module
% Pair with your bluetooth device before continuing
% Lists available Bluetooth devices
instrhwinfo(‘Bluetooth’);
% Create a bluetooth variable and open it at channel 1
device = Bluetooth(‘HC-06’, 1);
% Pair with device
fopen(device)
%% Write command to HC-06/Arduino
fwrite(device, ‘c’); % Prompts lists to do more commands
read = fscanf(device, ‘%d’)
fwrite(device, ‘h’); % Makes LED low
read = fscanf(device, ‘%d’)
fwrite(device, ‘a’); % Read from accl
%% Reading and Analyzing Values from HC-06
data = ;
for count = 1:10
read = fscanf(device, ‘%d’)
data = [data; read]
end
final = str2double(data);
% Matrix manipulation here
%% Clear Bluetooth Object when Finished
fclose(device);
clear(‘device’)