Reading data on Matlab from serial device connected to raspberry pi

Hello everyone!
I will appreciate your help!
I am trying to read data on MatLab from a serial device that is connected to raspberry pi (the serial device is connected to raspberry pi and the pi is connected to a computer). The serial device is a conductivity probe that has a USB output. I tried the code below to read the data from the device, and I got an empty matrix. The conductivity probe sends data by a UART mode (it also has I2C mode, but the UART mode is the default). What should I do in order to get the data?
>> mypi = raspi
mypi =
raspi with properties:
DeviceAddress: '169.254.0.2'
Port: 18734
BoardName: 'Raspberry Pi 3 Model B+'
AvailableLEDs: {'led0'}
AvailableDigitalPins: [4,5,6,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27]
AvailableSPIChannels: {'CE0','CE1'}
AvailableI2CBuses: {'i2c-1'}
AvailableWebcams: {}
I2CBusSpeed: 100000
Supported peripherals
>> myserialdevice = serialdev(mypi,'/dev/ttyUSB0')
myserialdevice =
serialdev with properties:
Port: '/dev/ttyUSB0'
BaudRate: 115200
DataBits: 8
Parity: 'none'
StopBits: 1
Timeout: 10
>> serialData = read(myserialdevice,2)
serialData =
0×0 empty uint8 matrix

5 commentaires

I am confused. Is the device using its UART to emulate USB to talk to the raspberry pi? And what code are you running on the pi?
The pi is usually communicated with using serial over USB. When you open the serial port directly - that interferes with the USB connection.
Thank you Walter,
I am not sure if the device is using its UART to emulate USB. I just know that the meter has a USB output and the documentation says it has a UART mode. I am not running any code on the pi. I am just using the matlab support package. Do you mean the USB will not work as a serial port?
Hello
Did you find a solution for this problem Mr. Regelio Garcia ?
Hocine YAKOUBI
Hocine YAKOUBI le 6 Oct 2021
Modifié(e) : Hocine YAKOUBI le 6 Oct 2021
Hi,
I have the same problem( not realy I connected RX to TX so I use /dev/ttyAMA0), did you resolve it ?
Thanks
@@Osamah Makki @Hocine YAKOUBI Unfortunally, I was not able to solve this problem. I ended up colllecting data from the serial device directly through a regular computer and Matlab. Best!

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur MATLAB Support Package for Raspberry Pi Hardware dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by