필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
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
Jayaram Theegala
Jayaram Theegala 2019년 1월 3일
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 2019년 1월 4일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

shivam sahil
shivam sahil 2019년 1월 4일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Support Package for Arduino Hardware에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by