SparkFun Forums 

Where electronics enthusiasts find answers.

General project discussion / help
Did you make a robotic coffee pot which implements HTCPCP and decafs unauthorized users? Show it off here!
By ammarbabikir
#194327
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')
By Valen
#194390
I don't know what that matlab code does exactly. Other than what the comments say. So I can't help in that regard. But your information is lacking in several areas.

0: Please write that code in between code-tags. That shortens your message and makes it easier to read.

1:
How are the 1st computer, Arduino MEga 2560, the LSM9DS0 3-axis gyroscope and the Bluetooth HC-06 module connected? Only summing them up does not equate to a schematic. Drawings please! And that goes for both sides of the wireless link. Your description does not mention how the 2nd computer is attached to the bluetooth module. Only that it somehow has a wireless link.

2:
What code is running on the Arduino Mega 2560? That error message does not seem to be generated by that matlab code. (I don't see it written in it anywat. But what do I know, might be an internal matlab error message) Always post your entire code. Especially why you are dealing with 'networking' components.