How to record an RF signal with GNURadio and transmit it using a CC1101

In this post, we are going to copy and send a 433 MHz signal. The signal source is a garage key fob, as these signals don’t have encryption and its modulation is simple (ASK).

In a previous post, we already achieved this. The advantage of the procedure we show in this post is that the full process is even more automatic!

Components

In addition to your laptop and an RTL-SDR dongle like this one, we used the following elements:

Raspberry Pi 3

We got the complete kit as this one, but you can just get the motherboard if you already have the power supply, MicroSD card and so on.

Raspberry Pi 3 kit

CC1101 Wireless Module

This is the key element in this experiment and, as you can check here, it’s also really cheap.

CC1101 Wireless Module

SmartRF Studio Software

This tool is extremelly helpful to set up the register values of the CC1101 module, to configure your test. You can download the official version, for free, here.

GNURadio software

This is an open source tool that we will use to create a flow-graph that will allow us to easily record our signal. It will let us filter and amplify the signal and store it as a .wav file. You can download it here. You can install it in Windows, Linux and Mac. Find the installation tutorial here.

Unfortunately, GNURadio is not avaiable for Raspbian. That’s why we need to use our PC to record the signal and then transmit it using the Pi and the CC1101.

Connections

The following image shows how to connect the CC1101 to the Pi:

CC1101 connected to the Raspberry Pi 3

Code

You can download all the code that we use in this project from our GitHub repository.

As mentioned earlier, we will use GNURadio in our PC to record a 433MHz RF signal and a CC1101 connected to Raspberry Pi 3 to transmit it. Therefore, let’s check the code we will run in each side.

Code to run in your PC:

Once you install GNURadio in your PC, you can open GNURadio Companion and open the provided flow-chart: RF_FobSignal_BTS.grc

In the following image, our flow-graph is shown. We have highlighted the main features of the GUI that you need to know for this project:

GNURadio GUI

You can change the parameters as you need, connect your RTL-SDR dongle to your PC and run it. Once it’s running, the following window will pop up:

RTL-SDR received signal in real time

This is what your RTL-SDR dongle is receiving in the time domain and in real time. You can adjust the offsets and parameters in the left column to get to see your signal better, if you need to.

The signal we are going to copy is transmitted from a garage door opener. At this point, we press the button and then close the previous windows. Then, your signal will be stored in the selected directory.

You can also generate a Python script from the flow-graph by clicking on the icon we pointed in the GNURadio image. By default, this script is saved as ” top_block_NoGUI.py ” in the same directory where your flow-graph is. Then you can copy it in the GNURadio installation folder (typicially, C:\Program Files\GNURadio-3.7\bin) and then run the available .bat named ” run_gr.bat “. A command prompt terminal will pop up and you can run your python script there to record your signal. This allows more flexibility in terms of automating the proccess.

Once you have your signal recorded, you can transfer it to the Rapsberry Pi using a USB drive, Filezilla or sending it through email.

Code to run in the Pi:

Save the following scripts in the same folder where your .wav file is:

  • OpenWave.py
  • lib_CC1101_Test_100.py
  • playbackTextFileCC.py

OpenWave.py is the script to convert the .wav file in a .txt file, so we can use those values to transmit the recorded signal. Open your terminal, cd to the directory where these files are and run:

python OpenWave.py name.wav data.txt

Replace name and data with your own. You probably won’t need to edit anything from the previous script.

lib_CC1101_Test_100.py is CC1101 Asynchronous Library where we have defined all the settings for the CC1101 to transmit our recorded signal. These are specific for a 433MHz garage door open signal. The best way to fill the different regiester values for another type os signal is:

  • Record your signal
  • Visualize the spectrum (for example, using HDSDR)
  • Get the bandwith, central frequency and investigate the modulation scheme
  • Open SmartRF Studio and fill in those values. In our case, it will be:
SmartRF Studio

We have highlighted the main configuration parameters you need to know. At the right side, you can find the corresponding register values you need to fill in the python library. In order to fully understand what each register is, you can check the available documentation provided here or just contact us 🙂

playbackTextFileCC.py is the script that runs the algorithm to transmit our signal through the CC1101, using the Pi. Here you may want to edit the selected frequency:

#Set Frequency
if sys.argv[2] == "315":
    CC._setFreq("FREQ_315")
if sys.argv[2] == "433":
    CC._setFreq("FREQ_433")

Depending on what you set up in the library.

Now in order to transmit the signal, in the terminal, type:

python playbackTextFileCC.py data.txt Freq

Replace data.txt with your own data file. In our case, Freq is either 433 or 315.

Then, if you have a receiver or, using your own RTL-SDR dongle with HDSDR, you can check the transmitted signal is correct.

Demo

In the following video, we show you all this process, so you can understand it easier:

Video Tutorial & Demo

We hope you enjoyed this tutorial and don’t hesitate to contact us for questions and comments! 🙂

Add a Comment

Your email address will not be published. Required fields are marked *