FM Reception with RTL-SDR Radio on Raspberry Pi Hardware with Simulink
This example shows how to implement an FM mono receiver using a Raspberry Pi® and an RTL-SDR radio. You will learn how to receive FM signals using the RTL-SDR and process the FM signals on the Raspberry Pi hardware using Simulink®.
For an introduction on implementation of an FM broadcast receiver in Simulink, see the FM Broadcast Receiver in Simulink example.
Required Hardware and Software
To run this example, you need the following hardware and corresponding software:
RTL-SDR radio and Communications Toolbox Support Package for RTL-SDR Radio
Raspberry Pi and Raspberry Pi Blockset
Hardware Setup
Plug the RTL-SDR radio to the Raspberry Pi hardware and then connect an antenna to the RTL-SDR radio. Connect the Raspberry Pi hardware into an available USB port in your host computer. If your Raspberry Pi hardware is not connected to an Ethernet network, follow the instructions in Configure Network Settings of Raspberry Pi Hardware (Raspberry Pi Blockset).
Open the Model
The FM receiver model uses the RTL-SDR Receiver block to receive radio signals using an RTL-SDR radio and the sends the FM signals to the FM Broadcast Demodulator Baseband block. The FM demodulator block demodulates the received signal and generates the mono audio. The FM demodulator block then sends the mono signals to the ALSA Audio Playback block optimized for the Raspberry Pi hardware.

Configure Model to Run on Raspberry Pi Hardware
To configure the model to run on the Raspberry Pi hardware, follow these steps:
1. In the model, set simulation stop time to 'inf' to run the simulation until you explicitly pause or stop the model.
2. In the Simulink model, click Tools > Run on Target Hardware> Options....
3. When the Configuration Parameters page opens up, set the Target hardware parameter to Raspberry Pi. Review the other parameters on that page. If you performed a Firmware Update, Board information will be automatically populated with the IP address, user name and password of your Raspberry Pi hardware. Also, notice the TCP/IP port edit box under Signal monitoring and parameter tuning. The default value of TCP/IP port is 17725. Simulink uses this TCP/IP port to communicate with Raspberry Pi hardware. Leave the TCP/IP port parameter at its default value. Click OK when you are done.

4. In the Simulink model, click the Deploy to Hardware button on the toolbar or press Ctrl+B.

5. The model will now run on the Raspberry Pi hardware. A system command window will open that shows the messages coming from the model running on Raspberry Pi hardware.
6. Connect speakers to the audio output of the Raspberry Pi hardware to listen to the radio.
7. Stop the model running on the Raspberry Pi hardware by executing the following on the MATLAB® command line
h = raspberrypi; stopModel(h,'FMReceiverRaspberryPiSimulinkExample');
Run the Model on Raspberry Pi Hardware
Raspberry Pi® Blockset generates a Linux® executable for each Simulink model you run on the Raspberry Pi hardware.
1. To run/stop a Simulink model, you use the run and stop methods of the raspberrypi communication object. First, create a communication object to the Raspberry Pi hardware:
rpi = raspberrypi;
This command generates a Raspberry Pi object that is your gateway to communicating with your Raspberry Pi hardware from MATLAB command line.
2. Execute the following on the MATLAB command line to stop the Simulink model you ran in previous section:
stopModel(rpi, 'FMReceiverRaspberryPiSimulinkExample')
3. To run a previously built Simulink model on your board, you use runModel method. In order to run the FMReceiverRaspberryPiSimulinkExample model, execute the following on the MATLAB command line:
runModel(rpi, 'FMReceiverRaspberryPiSimulinkExample')