Creating a mobile P2000 receiver using a Raspberry Pi

In the Netherlands, the P2000 network is used by, amongst others, ambulances and fire brigades, to communicate about locations of emergencies. Formally, it is part of the broader C2000 network, which is used by the (military) police as well (but has an additional layer of encryption). What still amazes me is how easy it is to actually receive the messages yourself, too, using only a cheap Chinese 5-10 dollar USB DVB-T dongle. In this tutorial, I will show you how to build your own setup to receive P2000 messages in the Netherlands.

Requirements

Only a few things are required:

  • A cheap Chinese DVB-T stick + antenna (such as this one). Most important is that it has the RTL2832U chipset, so that we can use it with rtl_fm.
  • A Raspberry Pi (I used a Raspberry Pi 3). The RPi 3 has built-in Wi-Fi. In this tutorial, we will use it as a Wi-Fi hotspot, so use a USB Wi-Fi dongle if your RPi does not have it built in.
  • A power source for the Raspberry Pi. I used an Anker powerbank here so that it is really portable.

The setup

Our setup simply consists of two parts: the Raspberry Pi, which will function as the core component that processes the incoming P2000 messages, and the USB DVB-T dongle + antenna, which we will tune to the right frequencies to receive the messages themselves.

Step 1: Setting up the Raspberry Pi

First, let’s set up the Raspberry Pi. In my own setup, I downloaded Raspbian Jessie Lite, which I wrote to the RPi’s SD card using the following command:

Now, boot the RPi and make sure to properly secure it. That means, at least, that you should change the default password. If you are not sure what to do here, have look at this post which explains some easy security measures you can take.

Step 2: Installing rtl_sdr

Now, we will install the software we will use to work with the DVB-T dongle, rtl_sdr. Execute the following commands on your RPi to install it (source here):

As explained here, one additional step is to blacklist some drivers that the RPi has installed by default (normally, the DVB-T stick is used as a television antenna, and the Raspberry Pi will automatically try to use it as such). This can be done by executing the following commands:

This will open the raspi-blacklist.conf file in an editor. Now, add the following three lines to the file:

Press CTRL+O and CTRL+X to apply your changes and save the file. Now, reboot the RPi and check if the software runs properly:

Now, after the last command (rtl_test -t), you should get an output the looks like the following:

If you see a similar output after issuing the rtl_test command, you are good to go and can proceed to the next step! Otherwise, please use Google to troubleshoot the error message you are getting.

Step 3: Install multimon-ng to decode messages

Theoretically, we can now already receive P2000 messages. The thing is, we can not yet decode them so they would be worthless. Luckily, there is this article, which explains how to use a tool called multimon-ng to decode messages. Following the article, let’s install it:

Step 4: Test run!

Now that we have installed all the components, let’s try if it works! The command we will use to get the messages will consist of two parts: rtl_fm to actually receive the messages, which we will then pipe through to multimon-ng which automatically decodes the FLEX protocol for us.

In this case, we will use the parameters as suggested on this page, as they showed to ‘just work’ in the Amsterdam region.

If everything is right, your output should look a bit like the output above. As you can see, there are some ‘UNK‘ messages. I am not sure what they mean exactly, but for now let’s just ignore them. The others, like the ‘ALN‘ one here, show actual emergency messages sent to fire brigades, ambulances, etc.

Now that we have the messages, wouldn’t it be nice if to have a simple GUI through which we can see the messages?

Step 5: Displaying the messages

For this step, we will set up a really simple website through which we can see the messages. Let’s install Apache2 so that we can run a web server in the first place:

Now, let’s install php5 and browse to the root of the web server:

 

We now want a directory where we will store the messages we will display. That consists of two parts: creating a directory to store the messages in a file, and actually creating the file itself. The first can be done using the following command:

Now that we have the directory, we will simply pipe the output of the commands used earlier to a text file in this directory (I know it’s dirty, but it does the job for a proof of concept):

Now, each time a message comes in, it will be appended to the ‘messages.txt‘ file in ‘/var/www/html/files/‘. In the test run I did, it looked like the following after some time:

At my GitHub page, I published really simple source code that you can use as a starting point to view the message in a bootstrapped website. If you have properly configured your RPi as I did in this tutorial, and you use my GitHub example code, you should get the following if you browse to your RPi’s (local) IP address:

Step 6: Making it all portable

Wouldn’t it be great if we can make it portable? Let’s try.

In order to make this project fully portable, we need two things: a powerbank (such as the one I have), and a Wi-Fi hotspot running on the RPi to connect to when on the move (so that we can connect to it from a laptop and see the GUI we just set up). Skipping the first part (the powerbank), as it is obvious, let’s directly move on to setting up a hotspot.

Setting up the Wi-Fi hotspot is pretty easy. I would advise you to use the this tutorial, which explains it all pretty well.

After you successfully have a hotspot running on your RPi, simply take it all outside, go sit in a park, hook up the RPi to the powerbank, connect to the Wi-Fi hotspot and SSH into your RPi. Run the commands to sniff for P2000 messages and browse to its IP from your browser to see them. This is really all you need to see what’s happening in your neighborhood.

Step 6: Have fun! 🙂

3 Comments

  1. Goedemorgen Auke, rare vraag maar kan jij mij de beschrijving in de Nederlandse taal leveren van “Creating a mobile P2000 receiver using a Raspberry Pi” . Artikel klinkt wat ik zoek, vooral het gedeelte website, maar mijn kennis technisch Engels is laag. Nu kan je translaten maar het resultaat daarvan is ook niet best.
    Hoop dat je kan voldoen aan mijn verzoek waarvoor alvast dank, groet Ger

    1. Hoi Ger, ik probeer mijn blog 100% Engels te houden. Wat ik je aanraad is even op de volgende website te kijken: https://nl.oneguyoneblog.com/2016/08/09/p2000-ontvangen-decoderen-raspberry-pi/. Deze tutorial beschrijft de basisstappen in het Nederlands. In plaats van alleen de “ruwe” data weer te geven op je scherm kun je ze ook wegschrijven naar een bestand. De code die ik op mijn Github-pagina heb staan kun je gebruiken om dat bestand uit te lezen en in “website”-vorm te tonen. Voor het installeren van een webserver op je Raspberry Pi kun je bijvoorbeeld deze tutorial gebruiken: http://www.huubmons.nl/multimedia/raspberry-pi/21-raspberry-pi/78-raspberry-pi-webserver. Als je daarna de bestanden van mijn Github-pagina in je /var/www/ map zet (en zoals in mijn beschrijving de ruwe data naar een bestand wegschrijft) zou het moeten werken.

      Succes!

Leave a Comment

Your email address will not be published.