MATLAB Answers

0

How can I get values from arduino via bluetooth?

Asked by Keitaro Murakami on 8 Nov 2019 at 23:09
Latest activity Commented on by Etsuo Maeda on 11 Nov 2019 at 1:48
I want to send force sensor's value from arduino to MATLAB on windows via Bluetooth.
For the first step, I tried to send values like below. (this is arduino code)
#include <SoftwareSerial.h>
int TxD;
int RxD;
int data;
int count=0;
SoftwareSerial bluetooth(TxD, RxD);
void setup() {
Serial.begin(9600);
bluetooth.begin(9600);
}
void loop(){
bluetooth.println(count);
Serial.println(count);
count++;
delay(1000);
}
On the MATLAB side, I could connect to the arduino.
instrhwinfo('Bluetooth','DSD TECH HC-05');
bt = Bluetooth('DSD TECH HC-05',1);
fopen(bt);
However, I can't get values sent from arduino, though I tried these functions looking at this site https://www.mathworks.com/help/instrument/reading-and-writing-data-over-the-bluetooth-interface.html
fread(bt)
fscanf(bt)
How can I get values in real time?

  1 Comment

Can you execute the following demo properly using fwrite and fread functions?
What does it mean "I can't get values sent from arduino" in your question?
  1. You got incorrect data
  2. You could not get any data
  3. fread or fscanf showed errors
HTH

Sign in to comment.

Tags

0 Answers