Difference between revisions of "Bluetooth Strain Gauge"

From Training Technology Lab Wiki
Jump to navigation Jump to search
m
 
(7 intermediate revisions by the same user not shown)
Line 5: Line 5:
 
In terminal  
 
In terminal  
 
(you may have to manually switch on your bluetooth connection)  
 
(you may have to manually switch on your bluetooth connection)  
  <nowiki> hcitool scan <\nowiki>
+
 
 +
* Scan for devices:
 +
  hcitool scan
 +
 
 +
Look for the MAC-ADDRESS and copy it into the following <MAC>
 +
This will bind the device to the name /dev/rfcomm1:
 +
 
 +
  (sudo) rfcomm bind /dev/rfcomm1 <MAC>
 +
 
 +
Afterwards, check if it has been bound:
 +
rfcomm -a
 +
 
 +
It now appears as a serial connection, and you can use the 'cat' command to view the output:
 +
cat /dev/rfcomm1
 +
 
 +
To pipe the data into a file (directory is where you are standing):
 +
cat /dev/rfcomm1 > datafile.dat
 +
 
 +
 
 +
You can also use fopen() and fscanf() to read in data into MATLAB:
 +
example:
 +
instrreset;
 +
s = serial('/dev/rfcomm1', 'BaudRate', 115200);
 +
fopen(s);
 +
data = fscanf(s); %read data into array
 +
disp(data);
 +
fclose(s);
 +
 
 +
To remove the binding:
 +
rfcomm release /dev/rfcomm1

Latest revision as of 12:27, 22 November 2017

Notes for setting up the Bluetooth strain gauge (RN42-0452) with e.g. MATLAB:

In terminal (you may have to manually switch on your bluetooth connection)

  • Scan for devices:
 hcitool scan

Look for the MAC-ADDRESS and copy it into the following <MAC> This will bind the device to the name /dev/rfcomm1:

(sudo) rfcomm bind /dev/rfcomm1 <MAC>

Afterwards, check if it has been bound:

rfcomm -a

It now appears as a serial connection, and you can use the 'cat' command to view the output:

cat /dev/rfcomm1

To pipe the data into a file (directory is where you are standing):

cat /dev/rfcomm1 > datafile.dat


You can also use fopen() and fscanf() to read in data into MATLAB: example:

instrreset;
s = serial('/dev/rfcomm1', 'BaudRate', 115200);
fopen(s);
data = fscanf(s); %read data into array
disp(data);
fclose(s);

To remove the binding:

rfcomm release /dev/rfcomm1