Among the infinite simulation solutions in the Simulink environment there is clearly the possibility to analyze different flight systems. In particular, in this article, I discuss my experience on an avionics box made up of two boards, an Arduino Due and a Raspberry Pi, which together with several specially designed circuits allows you to remotely manage and pilot a UAV. In addition, an autopilot is also developed through Simulink that allows the aircraft to carry out its full autonomy


A microcontroller is a digital device created as an alternative to the microprocessor to expand its possibilities in embedded systems. The device has several components, in addition to the processor and memory are added several peripherals such as hardware for UART, I2C and SPI communication and several GPIO pins. The latter are also used for the management of external sensors.


In order to use the microcontroller it is necessary to load a firmware, that is software containing all the necessary applications. In particular, in this context, an Arduino DUE and a Raspberry Pi 3 are used. Furthermore, the Raspberry is much more than a microprocessor, it is rather a single-board computer but in this case it is used in a more similar way to use of a microcontroller.

These devices interact with flight control actuators and various sensors. In particular, there are:

  • Pitot tube
  • Accelerometer
  • Gyroscope
  • Temperature sensor
  • GPS
  • Barometric altimeter

Simulink is model-based design and simulation software developed by Mathworks. It is widely used in engineering and industry to design and simulate different systems before transferring them to hardware. The system allows to model the system starting from the concept and the sequence of blocks in a multi-domain environment in order to be able to simulate it and finally generate the code that satisfies the model.

Among the various features of Simulink there is the possibility to face different challenges in the programming of microcontrols. In particular, it is possible to follow two different workflows:

  • Reading and writing data from sensors
  • Development of algorithms that will run autonomously on the device
With Simulink support package for Arduino, you develop the algorithm in Simulink and deploy to the Arduino using automatic code generation. Processing is then done on the Arduino.
Credits: MATLAB

Inside the avionics box the various devices are integrated on the basis of a model developed in the Simulink environment. In particular, the autopilot is developed entirely by the Flight Team in the Simulink environment and is based on the implementation of control loops which, having acquired the state of the UAV, generate the commands to be exercised on the aerodynamic surfaces. Added to this is the ability to control the flight from the ground station by assigning waypoints or flight parameters, such as speed, course and altitude.

SASA Flight Team

In support of this information is added a very interesting experience that I carried out thanks to the Sapienza Flight Team. They invited me to their lab to participate in flight computer optimization. Inside the avionics box there are an Arduino DUE and a Raspberry Pi 3 that communicate with each other by analyzing the data, filtering them and checking the flight dynamics.

The team is managed on a student initiative in the Aerospace Engineering department of the University of Rome La Sapienza. They have participated in several important competitions reaching excellent positions. The aim of the project is precisely to put into practice the knowledge acquired in the academic field by transferring it to a practical project. This leads to face various problems more similar to those faced by the industrial world, leading to greater preparation and awareness. Currently the team has the goal of completing the construction of a UAV, or a remotely piloted aircraft capable of autonomously performing specific missions.

Kalman filter

Sensor data is read by Arduino and stored for telemetry. Furthermore, in order to use the autopilot correctly, a strong cleaning and filtering is carried out in order to guarantee a correct view of the state of the aircraft. This is accomplished by means of a Kalman filter. This estimator is developed in the Simulink environment in a thesis work and is implemented on Raspberry Pi 3.

The Kalman filter is a very efficient recursive filter that allows you to evaluate the state of a dynamic system starting from a series of measurements subject to noise. Among the noise sources we find quantization noise, the presence of low frequency noise in the electronic components and the deviations of the individual sensors.

The Kalman estimator allows to report a certain gain inside the system by realizing a feedback on the model to improve the state estimation using the error itself. In particular, under suitable conditions, the Kalman algorithm is what makes this gain excellent.

During the first day of testing in which I participated, it was necessary to trace the source of some communication problems between the microcontrollers. Following some hardware problems we restarted from the serial communication between Arduino and Raspberry. In particular, an example of a very simple communication model to implement on Arduino could be the following:


The simplest message to send is a constant and in this way it was possible to carry out some tests looking for the best encoding to send the data into the filtering system. We then proceeded by increasing the complexity of the algorithm more and more by increasing the constant every turn of the loop until we were able to simulate the sensor data.

The first tests were carried out by interfacing directly with the two devices. A serial chat was created between the Arduino serial monitor and the Raspberry Pi using minicom on the latter.

minicom --device /dev/ttyS0 --baudrate 115200

And implementing a simple serial chat on Arduino:

String mex = "";
String mex1 = "";
int number = 10;
void setup() {
void loop() {
  // Serial1.print(number)
  if (Serial.available()) {
    mex = Serial.readString();
  if (Serial1.available()) {
    mex1 = Serial1.readString();

At first, simple text messages in ASCII encoding were tested and then moved to using the write command, optimizing the data sequence for the entire model developed in Simulink.