Digital radio with a Raspberry Pi

Digital radio is transmitted in most Australian cities using the DAB+ standard. Off the shelf DAB+ radios are a bit expensive, but it’s possible to listen to DAB+ broadcasts using a computer and an inexpensive Software Defined Radio (SDR) dongle. A desktop or a laptop computer can be used, but something as basic as a Raspberry Pi works just fine. To find a dongle, search eBay or the like for ‘r820t’ and you’ll find a range of devices costing anywhere from about AUD$10 to as much as AUD$50. A ten dollar dongle is just fine for DAB.

This setup will work on a Raspberry Pi 2, but the new Raspberry Pi 3 is faster and has built-in wifi which makes setting it up a lot easier.

Things you need

  • SDR dongle and its antenna
  • Raspberry Pi 3
  • Power supply for the Pi
  • HDMI cable
  • Keyboard and mouse
  • 8GB or bigger micro SD card
  • Laptop or desktop computer to set up the SD card
  • TV or monitor with HDMI input

If you’re using a monitor rather than a TV, you may need headphones because many monitors will have a headphone socket but no speakers. Also, a short USB extension cable can be useful if you can’t get the keyboard, mouse and dongle to play nice with the closely spaced USB sockets on the Pi.

Overview

In summary, here’s what needs to be done. On a computer with access to the Internet and a micro SD card slot, download an Operating System for the Raspberry Pi and copy it to the micro SD card. Plug the card into the Raspberry Pi, configure the Pi, update its Operating System, install a bunch of software that the DAB+ receiver software needs, then download and build the DAB+ software.

The Details

Start by downloading the latest full version of the Raspbian Desktop from the raspberrypi.org web site. It’s a zip file, so once it’s downloaded, unzip it. I’m using my laptop running Korora 24 linux for this.

unzip 2016-05-27-raspbian-jessie.zip

This results in a file of about 4 gigabytes called 2016-05-27-raspbian-jessie.img which needs to be copied to the micro SD card.

Before you plug the micro SD card into your computer, run the df command to see what block devices are mounted. Then plug the card in and run df again. The extra device that’s listed is your card, possibly something like /dev/sdb1. Unmount the card if it auto-mounted.

umount /dev/sdb1

Use the dd command to copy the image file to the card. Recent versions of dd support the handy status=progress option which lets you easily keep tabs on how it’s going. It will take a few minutes to do and don’t forget to let the sync finish before you unplug the card.

sudo dd if=2016-05-27-raspbian-jessie.img of=/dev/sdb bs=4M status=progress && sync

Now the fun stuff begins. Plug the micro SD card into its slot on the Raspberry Pi, Connect the HDMI, keyboard, mouse and finally connect the power. With any luck, you’ll see the Pi booting up and it should go straight to a desktop. Click on the network icon at the top right of the screen, select your network and give it your network password to get connected. Open a terminal and:

sudo su -
raspi-config

Out of the box the raspbian OS is set up for a UK locale and keyboard, so I use the raspi-config tool to set my AU locale and US keyboard layout. Then select the ‘resize root file system’ option to maximise the use of the SD card, exit the tool and reboot.

Once it’s rebooted, update the Operating System.

sudo su -
apt-get update && apt-get dist-upgrade -y

Now install the stack of dependencies that the DAB+ software needs in order to build:

apt-get install -y vim qt5-default qt5-qmake libusb-1.0-0 libusb-1.0-0-dev \
portaudio19-dev faad libfaad-dev libsndfile1-dev \
sndfile-tools librtlsdr0 librtlsdr-dev libfftw3-3 libfftw3-dev

The SDR-J software

The DAB+ receiver software is the Open Source SDR-J project. It’s author, Jan van Katwijk, has a range of interesting software tools that you can read about on his site. We want the Raspberry Pi version of his DAB+ software.

git clone https://github.com/JvanKatwijk/dab-rpi
cd dab-rpi

There are quite a few README files. It may be useful to read a few of them.

The last piece of config is done by editing the dab-rpi.pro file.

vim dab-rpi.pro 

Just comment out the lines for sdrplay and airspy because they’re other (more expensive) SDR devices that we’re not setting up here.

Finally, it’s time to build the software.

qmake
make

Watch a great deal of compiler output streaming past for a few minutes. Once it’s finished (hopefully without major errors)…

cd linux-bin
./dab-rpi-0.997

You should see a bunch of text stream past in the console, then a GUI should open that you can navigate with a mouse.

Select dabstick as your input source, select your audio device, select your channel group and click Start. I used the Wikipedia DAB+ page to work out that the channel group I need for Canberra is 10B. If you exit the app via the Quit button, it will write a config file to ~/.dab-rpi.ini with your settings so that the next time you run it you won’t need to set it up again.

Tip: To route the audio to the Raspberry Pi’s 3.5mm headphone socket instead of HDMI, do this before you start dab-rpi.

amixer cset numid=3 1

24 thoughts on “Digital radio with a Raspberry Pi

  1. |Hi Michael
    Thank you for your article on setting up a DAB radio with the RPi.
    I have been trying to compile the DAB software following the process as outlined in your tutorial. After following all the steps, it all fails due to an error
    “src/input/sdrplay-exp/sdrplay.h:38:27: fatal error: mirsdrapi-rsp.h: No such file or directory
    #include “mirsdrapi-rsp.h” ”
    ^
    I have located this line 38 in the file sdrplay.h, and it is commented out anyway.

    I have tried to ” apt-get mirsdrapi-rsp “, but this results in
    ” E: Unable to locate package mirsdrapi-rsp ”

    The entire output is
    root@raspberrypi:~/dab-rpi# qmake
    root@raspberrypi:~/dab-rpi# make
    g++ -c -pipe -flto -ffast-math -O2 -Wall -W -D_REENTRANT
    -fPIE -DMOT_BASICS__ -DMSC_DATA__ -DGUI_1 -DHAVE_DABSTICK
    -DHAVE_SDRPLAY -DHAVE_RTL_TCP -DQT_NO_DEBUG -DQT_WIDGETS_LIB
    -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/linux-g++
    -I. -I. -I. -Isrc -Iincludes -Iincludes/ofdm -Iincludes/backend -Iincludes/backend/audio
    -Iincludes/backend/data -Iincludes/backend/data/journaline -Iincludes/output -Iincludes/various
    -Isrc/input -Isrc/input/rawfiles -Isrc/input/wavfiles -isystem /usr/local/include -Igui_1
    -I/home/jan/rtl-sdr/include -Isrc/input/dabstick-osmo -Isrc/input/sdrplay-exp -Isrc/input/rtl_tcp
    -isystem /usr/include/arm-linux-gnueabihf/qt5 -isystem /usr/include/arm-linux-gnueabihf/qt5/QtWidgets
    -isystem /usr/include/arm-linux-gnueabihf/qt5/QtNetwork -isystem
    /usr/include/arm-linux-gnueabihf/qt5/QtGui -isystem
    /usr/include/arm-linux-gnueabihf/qt5/QtCore -I. -I. -o gui.o gui_1/gui.cpp
    In file included from gui_1/gui.cpp:47:0:
    src/input/sdrplay-exp/sdrplay.h:38:27: fatal error: mirsdrapi-rsp.h: No such file or directory
    #include “mirsdrapi-rsp.h”
    ^
    compilation terminated.
    Makefile:1154: recipe for target ‘gui.o’ failed
    make: *** [gui.o] Error 1
    root@raspberrypi:~/dab-rpi#

    Do you have any suggestions that might help?

  2. Harry,

    Are you actually using an sdrplay as your receiver? If not, you need to comment it out of the config.

    If you are, I must confess that I don’t have one and have not tested it.


    MC

  3. Many thanks Michael for your interest. I commented out all the references to SDRPLAY, but the make failed again with a similar error but a different file, in a line that has been commented out. I will press on trying to sort it out.
    With regards, Harry

  4. Hi Michael,

    Thanks for publishing this article. After following your procedure above without errors, I’ve run into an issue with a compiler dependency and the make ends here:

    gcc -c -pipe -flto -ffast-math -O2 -Wall -W -D_REENTRANT -fPIE -DMOT_BASICS__ -DMSC_DATA__ -DSSE_AVAILABLE -DGUI_1 -DHAVE_DABSTICK -DHAVE_RTL_TCP -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/linux-g++ -I. -I. -I. -Isrc -Iincludes -Iincludes/ofdm -Iincludes/backend -Iincludes/backend/audio -Iincludes/backend/data -Iincludes/backend/data/journaline -Iincludes/output -Iincludes/various -Isrc/input -Isrc/input/rawfiles -Isrc/input/wavfiles -isystem /usr/local/include -Igui_1 -I/home/jan/rtl-sdr/include -Isrc/input/dabstick-osmo -Isrc/input/rtl_tcp -isystem /usr/include/arm-linux-gnueabihf/qt5 -isystem /usr/include/arm-linux-gnueabihf/qt5/QtWidgets -isystem /usr/include/arm-linux-gnueabihf/qt5/QtNetwork -isystem /usr/include/arm-linux-gnueabihf/qt5/QtGui -isystem /usr/include/arm-linux-gnueabihf/qt5/QtCore -I. -I. -o spiral-sse.o src/backend/spiral-code/spiral-sse.c
    src/backend/spiral-code/spiral-sse.c:23:23: fatal error: emmintrin.h: No such file or directory
    #include
    ^
    compilation terminated.

    I searched from root for “emmintrin.h” and don’t have it. It looks like it should have been included with gcc. Anyway, I’ll work through this but thought you would appreciate the feedback.

    Thanks and Regards,
    Dean.

    1. Thanks Dean. That does look like something that ought to be there without you explicitly asking for it. I haven’t encountered this problem, but I suggest that you could try re-running the dependency install steps starting with ‘apt-get update && apt-get dist-upgrade -y’. Keep an eye out for errors during this process in case one or more packages fail to install due to transient package mirror problems and the like.


      MC

  5. Hey Dean
    after e few tries I`ve got the following message
    MakeFile:1138: recipe for target spiral-sse.o’ failed.
    make: ***[spiral-sse.0] Error 1

    what could that mean?

    greetings
    Koen

  6. Hi All,

    One of my ham radio buddies Craig had a look at this for me and the problem is with latest version of the dab-rpi.pro file in the repository. A line has been added as follows to allow for x86 builds of the project:

    # Uncomment this when compiling on/for a machine with sse support
    #CONFIG += NO_SSE_SUPPORT

    You will need to uncomment (remove the #) and then save. The file is read only so sudo vi rpi.pro is the way to go to edit this file. Once this is done, the project will build successfully. I also found the only way I could get audio routed to the analogue (3.5mm jack socket) output was to change the default audio path to force 3.5mm in raspi-config. In the DAB MainWindow, select the “default” audio path and you should hear something. I haven’t tested the routing to HDMI audio yet but expect that would work with the raspi-config default which is HDMI out of the box.

    The receiver is running nicely now and I’m listening to ABC Jazz on Band III/1/9C here is Sydney at this moment. Thanks to Jan van Katwijk for creating this software and to all other contributors with code embedded. Thanks also to Michael for putting this blog together.

    Dean.

  7. Hey Dean,

    have another problem i tried to compile and get error.
    -lQt5Network -lQt5Gui -lQt5Core -lGLESv2 -lpthread
    /tmp/ccGajB7h.ltrans4.ltrans.o: In function `viterbi::deconvolve(short*, unsigned char*)’:
    ccGajB7h.ltrans4.o:(.text+0x100): undefined reference to `FULL_SPIRAL_sse’
    collect2: error: ld returned 1 exit status
    Makefile:311: recipe for target ‘linux-bin/dab-rpi-0.997’ failed
    make: *** [linux-bin/dab-rpi-0.997] Error 1

    1. Get the same make error.

      ccGajB7h.ltrans4.o:(.text+0x100): undefined reference to `FULL_SPIRAL_sse’

      Any ideas?

      1. After trying to make it a lot of times I found myself with the same error over and over.
        So starting with a clean slate is importand, remove the dab-rpi directory.
        use the git command to download again.
        edit the dab-rpi.pro and look for:

        “# Uncomment this when compiling on/for a machine withOUT sse support
        #CONFIG += NO_SSE_SUPPORT”
        remove the # before config.
        also comment out the things as stated in the tutorial.
        now make it again and it should work.

  8. I had that problem with emmintrin.h errors as above. Tried the suggested options. No joy.
    Searching for the names in the messages, I read a note somewhere that the pi doesn’t have sse support. I don’t even know what it is! Looking at the config I noticed that there is a command as follows in the windows section. I copied this into the end of the Linux section of the config. Tried again.
    CONFIG += NO_SSE_SUPPORT
    The error doesn’t appear anymore. The program now works – not sure about all that gain stuff, but I receive DAB. Thanks for the tutorial, Hope this helps someone….All I need now is a good signal to my pi….

  9. Thank you for all the information. I was able to compile with uncommenting the NO SSE line. There is an option to compile with a simple TCP server. Can anyone tell me what kind of audio client and instructions on how to use this ??
    I would like to send the audio to a windows pc.

  10. I have the software running using a € 10 dabstick in a RI3. Most trouble came with installing QT on de RPI. I cross compiled QT 5.7 on a Debian VM using the manuals on https://wiki.qt.io/RaspberryPi2EGLFS and https://github.com/AlbrechtL/dab-rpi which is in fact a fork of the JvanKatwijk version but with a nice new interface! Compiling I commented out sdrplay and airspy in the dap-rpi.pro. I cross compiled dap-rpi on my linux VM.

    Playing DAB+ with 64 KBps streams works fine without stuttering, but somehow 48 KBps streams are not handled in a correct way (somehow not all streams are min 64 kBPS in the Netherlands). Stuttering occurs and a MONO indicator occurs on the screen. I suppose this is a software issue.

  11. Hey folks,
    i had some issues compiling dab-rpi. These are my settings which made it work perfectly on a raspi 3, with raspbian Pixel 2017-01-11.

    1. In addition to the installations above you will need:
    sudo apt-get install libsamplerate0-dev

    2. At the top of dab-rpi.pro uncomment:
    CONFIG += NO_SSE_SUPPORT

    3. Scroll down a few pages. These are my compilation settins:
    CONFIG += dabstick
    #CONFIG += sdrplay-exp
    #CONFIG += sdrplay
    CONFIG += rtl_tcp
    #CONFIG += airspy
    CONFIG += gui_1
    DESTDIR = ./linux-bin
    INCLUDEPATH += /usr/local/include
    LIBS += -lfftw3f -lusb-1.0 -ldl #
    LIBS += -lportaudio
    LIBS += -lz
    LIBS += -lsndfile
    LIBS += -lsamplerate
    LIBS += -lfaad

  12. I had it working but then before backup of sd card crashed unrecoverable (with airspy and SSE change).
    Now tried again fresh (newest raspberry with apt-get upgrade && dist-upgrade -y and newest sdr-j and no luck anymore. Installed air-spy first. uncommented dabstick, sdrplay (and sdrplay-exp)

    In compiling I get this error: “In file included from includes/output/audiosink.h:34:0,
    from src/backend/dab-virtual.cpp:31:
    includes/output/audio-base.h:32:24: fatal error: samplerate.h: Bestand of map bestaat niet
    #include
    ^
    compilation terminated.
    Makefile:892: recept voor doel ‘dab-virtual.o’ is mislukt
    make: *** [dab-virtual.o] Fout 1″

    compiler also give a lot of ” warning: extra tokens at end of #endif directive
    #endif;”

    What do I wrong or did something else brake with a new raspberry version or compiler?

  13. Hi @all and thanks for Michael,

    i tried to clone the dab-rpi repository on git today and i realised , that it’s gone ?!??? I i thought i was reading the page only a few days ago -and now that?!
    What happened and where can i get the code from now??
    thanks in advance

    Udo

      1. I did not know about this site. Contains very useful information on my software.

        Since there were too many versions to maintain, i.e. dab-rpi, sdr-j-dab, eti-dab, and I was preparing a “command line only” version, there was a slight reorganization:
        There is a Qt-DAB version with configuration options for including or excluding showing (and computing) a spectrum and constellation. An option here is to send the output to a TCP port, and the source-tree contains a small program (soundClient) that can be used to listen to the PCM data stream.
        The Windows distribution contains an executable for soundClient.

        There is a command line only version, one not depending on Qt. One needs C++11 (and some libraries of course) to compile that.

        There is a (limited) ETI version (ETI is an intermediate file format for the content of the DAB frames)

        J

        1. qt-dab with airspy works very well. Looks much more stable on windows 10. Not tried it yet on raspberry.

Comments are closed.