Filter löschen
Filter löschen

How to recieve data serially from my arduino to raspberry pi via matlab?

1 Ansicht (letzte 30 Tage)
here is my code.
After complete configuration:
mypi=raspi();
myserialdevice = serialdev(mypi,'/dev/ttyAMA0',9600);
output = read(myserialdevice,100,'uint16')
output =
0×0 empty uint16 matrix
Even though I can see 10 recieved in my serial monitor of Arduino IDE. Also is there any way to make sure whether the connected port of arduino is correct or not? Because while trying at the first place also and creating myserialdevice, I got no error without even connecting my arduino to my pi.
  2 Kommentare
Jayaram Theegala
Jayaram Theegala am 3 Jan. 2019
Can you make sure that the Tx and Rx GPIO pins of Raspberry Pi and Arduino are connected correctly. Also, Raspberry Pi hardware uses +3.3 V as HIGH voltage for serial communcation,so don't directly connect to devices that use higher voltages.
To answer your second question, an error won't be thrown because even when you don't have Arduino connected, this state is same as the state when Arduino is indeed connected but not sending any data.
shivam sahil
shivam sahil am 4 Jan. 2019
Hi! Actually I was serially printing the data, I got it sorted by using char funciton, the data printed was just ASCII characters, now to solve it, I just added char in front of output and it is showing the data properly now.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

shivam sahil
shivam sahil am 4 Jan. 2019
Hey peeps, I found the answer to this question. Actually the values printed here are ASCII codes of actual characters. In case you want to see the exact output, you can use this:
char(output)
Hope this helps you all.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB Support Package for Arduino Hardware finden Sie in Help Center und File Exchange

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by