Archive for May, 2015

Receive your own ads-b signals and display them on a map like does.

Required hardware: tv-usb-receiver with rtl2832u chipset (like this offer with rafael r820t2 tuner); router tplink tl-mr3020; small portable charging device. – In this blog entry you find a photography of a similar setup.

Software: openwrt (14.07 barrier braker)  with libsdr and dump1090 (both available as openwrt packages).


  • Install openwrt on tl-mr3020 as decribed by openwrt wiki here.
  • Connect with telnet to and set a root password with passwd.
  • Change network settings to enable (preferably wired) internet access; (login as root with ssh and/or use the web interface); you might want to disable the dhcp server on interface “LAN”. – Configuration files are in /etc/config/.
    (In case you get locked out: power off; power on again; while led blinks quickly move the switch on the router; blinking gets faster and you are in safe mode with telnet login and default ip; run mount_root and repair settings with command uci)
  • Install packages (as described here and here): opkg update; opkg install librtlsdr; opkg install dump1090
    The router has only 4MB onboard flash storage; 640k is configured as writable overlay; librtlsdr (+dependencies) and dump1090 increased used overlay space from 216k to 364k.
  • run dump1090 without arguments to check if the tv-stick gets recognized

Configuration as wireless access point serving data only from (no internet access using this accesspoint):

  • Enable wifi in web interface (open accesspoint without password in my case)
  • define a new “interface “WIFI” inside the web interface. Use the physical settings tab of interface “WIFI” and of interface “LAN” to ensure that only eth0 is bound to “LAN” and only wireless is bound to “WIFI”
  • use setting network / firewall, create a new zone wifi with input: accept, output: accept, forward; reject (no masquerading, no clamping); add interface “WIFI” to this zone; do not allow interzone forwarding:
    Clients of the access point are not allowed to get  internet access and they cannot access the lan zone.
  • Enable the dhcp server on interface “WIFI”, use advanced dhcp server settings to send empty dhcp options 3 and 6 by writing 3 instead of 3, into the first dhcp-options field and 6 into the second option-field. This tells the client that this access point does not offer a default gateway or a dns server: that is, no internet access through this access point (reference).
  • Connect your mobile phone to the access point using dhcp and enable internet access by mobile data.
    The mobile browser should have access to (openwrt config page) and to any internet page.

Display ads-b messages of airplanes in reach of your antenna:

  • simple terminal view: connect by ssh to the router and run
    dump1090 –interactive
  • browser view:
    first connect with ssh and run
    dump1090 –net –quiet &
    then open with your browser
    and use ssh to stop dump1090 with command killall dump1090
  • the cpu load on the router seen by command top is about 60%. So cpu power seems to be sufficient.

Refinement: move openwrt web interface to port 8088 and run dump1090 on port 80:

  • ssh into the router and run
    sed “s,:80′,:8088′,g” /etc/config/uhttpd
    if the output is correct run sed with option -i (=edit in place)
    sed -i “s,:80′,:8088′,g” /etc/config/uhttpd
  • to create a shell script called dump which starts dump1090 with options run (inside /root directory)
    echo “#!/bin/sh” >dump
    echo “#” >dump
    echo “dump1090 –net –quiet –net-http-port 80 &” >dump
    chmod +x dump
  • now dump1090 can be started after ssh login as root by running
    and the webpage produced by tcpdump1090 is available at

Some screenshots of output of dump1090 can be found on this page (written in german).

Using the buttons of the router:

The current states of all buttons can be shown with
cat /sys/kernel/debug/gpio
3 way switch positions:

  • cat /sys/kernel/debug/gpio |grep gpio-18 |sed ‘s,^.*in *,,’
    lo = middle, hi = left or right
  • cat /sys/kernel/debug/gpio |grep gpio-20 |sed ‘s,^.*in *,,’
    lo = left, hi = right or middle

and to monitor the button change events the directory /etc/hotplug.d/button has to be created. Then any script inside this directory gets sourced by the script /sbin/hotplug-call. The environment variables $BUTTON, $ACTION and $SEEN are set

  • $ACTION: pressed, released
  • $BUTTON:
    wps: push button with led,
    BTN_0: switch: released = middle position, pressed = left or right
    BTN_1: switch: released =left, pushed = middle or right
    fast switching from left to right: no event for BTN_0 (remains pressed)
  • $SLEEP: seconds since last action for this button

Example script to monitor button events:

  • mkdir /etc/hotplug.d/button
  • echo ‘echo button $BUTTON with action $ACTION and seen $SEEN>>/tmp/buttons.log’ >
  • tail -f /tmp/buttons.log

Scripts to toggle wifi with wps button and to start and stop programs (reference)

  • /etc/hotplug.d/button/
  • /usr/sbin/BTN_0_pressed and /usr/sbin/BTN_1_pressed
  • /usr/sbin/
  • /usr/sbin/
  • /usr/sbin/
  • /usr/sbin/
  • all scripts have to be made executable with chmod +x
    and the suffix .txt should be removed
  • to attach the handler scripts to hardware buttons wps/left/middle/right
    (left: triggered by quickly moving the mode switch from right to left
    right: triggered by quickly moving the mode switch from left to right
    middle: triggered by moving the mode switch to the middle)
    uci add system button
    uci set system.@button[-1].button=wps
    uci set system.@button[-1].action=released
    uci set system.@button[-1]
    uci set system.@button[-1].min=1
    uci set system.@button[-1].max=3
    uci commit system


  • Install rtl-sdr package from this source: download to your computer, then copy it per scp to the router. Install it with opkg install rtl-……_ar71xx.ipk
    • look at the bottom of this page to stream the signal of the tv-receiver with rtl_tcp
    • rtl_tcp -a -n 8 -b 8
  • as receiver osmocom fft analyzer can be used (osx install requires macports: port install gr-osmosdr +full; port install gr-fosphor; port install Gqrx)
    osmocom_fft -W -s 2000000 -f 144000000 -a ‘rtl_tcp=’
    optionally with -W or -S or -F
    (sample rate 2 MHz gives 30% cpu load on the router)
    Tested with wired connection.
  • fm radio receiver gqrx runs with
    Device settings:
    device: rtl_sdr spectrum server
    device string (as displayed by rtl_test): rtl_tcp=
    sample rate: 1500000 (automatically set by gqrc)
    bandwidth: 0 MHz
    LNB LO: 0 MHz
    (Reboot router if transmission does not work properly)
    Receiver options: WFM (stereo)
    Input controls LNA gain: sensitivity of tuner
    Audio: Gain 0 dB
    Wired connection
  • fm radio receiver sdr# on windows 8.1:
    wireless connection
    sample rate 1.024 MSPS
    start rtl_tcp to listen on wireless interface
    rtl_tcp -a -n 8 -b 8