Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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 Commenti
Jayaram Theegala
Jayaram Theegala il 3 Gen 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 il 4 Gen 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.

Accedi per commentare.

Risposta accettata

shivam sahil
shivam sahil il 4 Gen 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.

Più risposte (0)

Categorie

Scopri di più su MATLAB Support Package for Arduino Hardware in Help Center e File Exchange

Prodotti


Release

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by