How to read data from arduino bluetooth?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
kintali narendra
am 21 Sep. 2016
Kommentiert: Walter Roberson
am 23 Sep. 2016
I am successful in sending data from matlab to arduino via Bluetooth, but I am unable to read the data sent by Arduino-bluetooth(JY-MCU).
% serial communication between matlab and bluetooth
delete(instrfind);
b = Bluetooth('BTslave',1);
fopen(b); %write and read function
fwrite(b,'K');
A = fread(b,5)
fclose(b);
clear('b');
I am able to read 5 values but they are just random values not the right values.
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 21 Sep. 2016
Watch out for the default on fread() being 'double' . If the bluetooth device is sending data in some other datatype you need to adjust your fread() to know that.
6 Kommentare
Walter Roberson
am 23 Sep. 2016
Earlier I indicated that the default for fread was double. That was incorrect: the default is uint8=>double . Each character of the printable values was being interpreted as a separate value, but you needed a group of printable values to be read together as a single value.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Arduino Hardware finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!