MATLAB Answers

What is the best way to send and recive data from arduino to raspberry pi using simulink?

9 views (last 30 days)
Kay Levinson
Kay Levinson on 31 Mar 2020
Answered: Ameer Hamza on 31 Mar 2020
Hello,
I have a Raspberry Pi 4 B and an Arduino Due and I want to use the Arduino to read data from several sensors and give commands to several servo motors, all connected to the Arduino.
All the data from the sensors need to be sent to the Raspberri Pi which in turn will send new servo commands that the Arduino then needs to execute.
What is the best way to do that using simulink?
Thanks in advance,
Kay

Accepted Answer

Ameer Hamza
Ameer Hamza on 31 Mar 2020
"Best" is a subjective term.
Probably the easiest way is to use serial communication between Arduino and raspberry pi. The advantage of this method is that Simulink provides blocks for serial communication for both boards.
Now the most robust approach I can think of is to use the Robot Operating System (ROS). On raspberry pi, run a ROS server and run an ROS node on Arduino. The disadvantage is that Simulink does not provide any support to deploy an ROS node on Arduino, and you will need to write your own S-functions to make it work with Simulink. Simulink does provide support to deploy an ROS node on raspberry pi. The main advantage of this approach is that ROS will handle the communication protocols and consistency itself. However, I would suggest going down this path only if you already a bit of knowledge about ROS and its Arduino libraries. I do have a file exchange submission on deploying a ROS node on Arduino. If you decide to use this method, that will be helpful.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!