Scrambled bluetooth object serial data (arduino to matlab)

2 views (last 30 days)
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!

Answers (1)

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

Categories

Find more on MATLAB Support Package for Arduino Hardware in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!