
Issue with serial communication blocks from support package for arduino nano(CH340 clone)
8 views (last 30 days)
Show older comments
I'm using arduino nano(ch340) and implementing serial communication with the Raspberry Pi 4B. I'm using USB cable rather than onboard uart pins. I've been trying to send data through serial transmit block (from nano) but no results at all. You cannot use 'monitor and tune' so only been reading the data(in both Arduino ide's serial monitor and rasp pi's terminal) after uploading the model.
The output in serial monitor is gibberish (boxes) while in terminal(screen) it is not visible at all. I generated a model for rasp pi with serial read block from support package where data is zero and status port indicates 'data not available'. Tried all three modes for transmit block: write, print, println, but same results. I programmed a test program in arduino ide with serial.println function which was successfully displayed results in both terminal and display from rasp pi simulink model. I've successfully implemented basic test models like 'led blink' in simulink for arduino so my inference is that the problem is only with serial transmit block and its generated code.
My aim is to establish bidirectional serial communication between Raspberry pi and arduino nano, to exchange multiple values simultaneously(probably having different data types) in an array and separate them for their intended use.

0 Comments
Answers (1)
Sutanu Maiti
on 17 Mar 2025
Upon opening the port, a delay is mandated by Arduino specifications. To achieve this, an enabled subsystem with a step block is necessary. On certain Arduino boards connected to a device running Linux/MAC, the device may reset when the serial port is opened due to the DTR signal being asserted by the OS driver. Consequently, any bytes sent immediately may be misinterpreted by the board bootloader, requiring an additional 4-second delay.
Please make the change on your Raspberry Pi model as shown below:

0 Comments
See Also
Categories
Find more on Modeling in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!