Scrambled bluetooth object serial data (arduino to matlab)

2 次查看(过去 30 天)
Hi,
My bluetooth serial data from arduino to matlab is totally scrambled (when I test the data over 3rd party bluetooth scanners it looks correct, so it appears matlab is parsing the serial data incorrectly).
The arduino code is simply:
void setup() {
Bluetooth.begin(9600);
Serial.begin(9600);
}
void loop() {
int sensorValue = analogRead(A0);
Serial.println(sensorValue);
Bluetooth.println(sensorValue);
delay(10);
}
My matlab bluetooth object (b) looks like this:
Bluetooth Object : Bluetooth-DSD TECH HC-05:1
Communication Settings
RemoteName: DSD TECH HC-05
RemoteID: btspp://001403066A62
Channel: 1
Terminator: 'CR'
Communication State
Status: open
RecordStatus: off
Read/Write State
TransferStatus: idle
BytesAvailable: 512
ValuesReceived: 5113
ValuesSent: 0
I successfully connect and open:
b = Bluetooth('DSD TECH HC-05',1);
fopen(b);
but I can't read correct values! I've tried:
fscanf fgets fread
any help would be much appreciated!! Thank you in advance!

回答(1 个)

Troy Mcan
Troy Mcan 2018-7-11
Circling back here- can anyone offer any guidance? Thank you.

类别

Help CenterFile Exchange 中查找有关 MATLAB Support Package for Arduino Hardware 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by