1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Install dump1090-fa from base Raspbian image (ssh)

Discussion in 'Tutorials' started by James, Sep 21, 2018.

  1. James

    James Administrator Staff Member

    This is long and relatively easy tutorial on starting with a base Raspbian image and setting up dump1090-fa map ui and the ADSBx feeder.

    Some knowledge of ssh is expected. If you are on Windows, you should have a ssh client installed.

    PRO TIP: When you make a typo or a mistake in a command. Hit up arrow and you can see previous commands and make the correction using the arrows.

    You can follow this tutorial using a keyboard and a monitor hooked to the Pi as well.

    Throughout this tutorial I reboot the Pi to reload configs. There are faster ways than rebooting, but they require more typing. :D

    Let's get started!

    Pregame: Raspbian

    Download latest Raspbian and burn to SD card.
    https://www.raspberrypi.org/downloads/raspbian/

    Place SD card in Pi & hook mouse and keyboard. Power the Pi.

    Step 1: Enable SSH

    login: pi
    password: raspberry

    Let's change the password. You will be prompted for current password and should set a new one.

    Code:
    passwd
    
    The next code regenerates the ssh keys and creates the file to enable ssh. SSH let's you remotely access your Pi over a terminal session from another computer. It is very useful, you can stash your Pi somewhere and leave it feeding.

    Code:
    sudo apt install ssh
    sudo rm /etc/ssh/ssh_host*
    sudo dpkg-reconfigure openssh-server
    sudo touch /boot/ssh
    sudo raspi-config
    
    Use raspi-config to enable ssh and setup your network wifi if needed.

    Reboot the Pi.

    Code:
    sudo shutdown -r now
    
    At this point you can switch to your other PC and SSH into the Pi, if you want.

    If you don't know the IP of the Pi, then ifconfig

    SSH is defaulted to port 22.

    Step 2: Install dump-1090

    SHH in or just keep on going with the mouse and keyboard. If you SSH you can copy/paste commands. :D Tempting, right?

    Code:
    cd /home/pi
    sudo apt-get install libusb-1.0-0-dev libusb-1.0-0 build-essential cmake libncurses5-dev libtecla1 libtecla-dev pkg-config git wget socat
    git clone https://github.com/flightaware/dump1090.git
    cd dump1090
    make BLADERF=no
    

    If that works, you now have a compiled binary of dump1090-fa in /home/pi/dump1090.

    If it fails, then I missed a dependency and let me know below. To correct it, sudo apt install whatever dependency and run make BLADRF=no again.

    You may need to install "librtlsdr0" and "librtlsdr-dev".

    Code:
    sudo apt install librtlsdr0 librtlsdr-dev
    
    OPTIONAL
    From here you have a 2 choices, you can build a .deb installer package or you can leave everything as is and setup a nginx to serve from this directory.

    If you want to do the installer, you might as well compile with bladeRF support.

    Code:
    sudo apt install
    sudo apt-get install librtlsdr-dev debhelper dh-systemd libbladerf-dev
    dpkg-buildpackage -b
    
    If building the package fails and barks out some errors about dependencies, then sudo apt install <dependencies>.

    Upon success it will dump a few deb packages in the directory above. This guide does not use the package, so let's go to Step 3: NGINX. If you choose to install by package then the location of dump1090 html will change and these instructions will not be exact.

    The usual sudo dpkg -i filename.deb will install. If you do this, you are on your own from here on out. The concepts are the same but you'll have to use the .deb locations for public_html in the nginx config.



    Step 3: NGINX

    Code:
    sudo apt install nginx
    sudo nano /etc/nginx/sites-available/default
    
    In that file change the default port, and change the root. There is a lot of stuff commented out; leave it unless you know what you are doing.

    Code:
            listen 8080 default_server;
            listen [::]:8080 default_server;
    

    We should also add a location alias the dump1090 json we are going to write to the ram drive.

    Code:
      root /home/pi/dump1090/public_html;
            location /data {
                 alias /var/run/dump1090;
            }
    
    The /var/run/dump1090 is explained more later; it is to be nice to the SD card.

    Let's create that /var/run/dump1090 and change ownership so dump1090 can write to it.

    I execute dump1090 as root - so the www-data ownership is not really important. Linux guys will complain and not want to run dump1090 as root as that's like running something as Administrator in windows.

    But let's keep it easy, shall we? No need to give device permissions and complicate an already long guide. It's a Pi, it's fine. Chill.

    Post some udev rules as comments or however you want to do it.

    Moving on ...

    Code:
    sudo mkdir /var/run/dump1090
    sudo chown -R www-data /var/run/dump1090
    
    Here is the full config.

    Code:
    # Default server configuration
    #
    server {
            listen 8080 default_server;
            listen [::]:8080 default_server;
    
            # SSL configuration
            #
            # listen 443 ssl default_server;
            # listen [::]:443 ssl default_server;
            #
            # Note: You should disable gzip for SSL traffic.
            # See: https://bugs.debian.org/773332
            #
            # Read up on ssl_ciphers to ensure a secure configuration.
            # See: https://bugs.debian.org/765782
            #
            # Self signed certs generated by the ssl-cert package
            # Don't use them in a production server!
            #
            # include snippets/snakeoil.conf;
    
            root /home/pi/dump1090/public_html;
            location /data {
                 alias /var/run/dump1090;
            }
            # Add index.php to the list if you are using PHP
            index index.html index.htm index.nginx-debian.html;
     
            server_name _;
    
            location / {
                    # First attempt to serve request as file, then
                    # as directory, then fall back to displaying a 404.
                    try_files $uri $uri/ =404;
            }
    
            # pass PHP scripts to FastCGI server
            #
            #location ~ \.php$ {
            #       include snippets/fastcgi-php.conf;
            #
            #       # With php-fpm (or other unix sockets):
            #       fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
            #       # With php-cgi (or other tcp sockets):
            #       fastcgi_pass 127.0.0.1:9000;
            #}
    
            # deny access to .htaccess files, if Apache's document root
            # concurs with nginx's one
            #
            #location ~ /\.ht {
            #       deny all;
            #}
    }
    

    Save the config.

    CTRL+O to write it out
    CTRL+X to exit nano

    Let's reload NGNIX config.

    Code:
    sudo systemctl reload nginx
    
    Now you should be able to go to the <IP>:8080 of your Pi in a web browser on your network and see the dump1090 map. Nothing will load because we haven't started dump1090 or plugged in the SDR.

    If you don't know the IP of your Pi. You can check it.

    Code:
    ifconfig
    
    Let's get some planes now.

    STEP 4. Getting some planes.

    Plug in your SDR and connect the antenna to the Pi USB port.

    Code:
    cd /home/pi
    lsusb
    
    You should see something like this.

    Code:
    [email protected]:~ $ lsusb
    Bus 001 Device 005: ID 0bda:2838 Realtek Semiconductor Corp. RTL2838 DVB-T
    Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
    Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    
    If you see a RTL .. then you are good to go and it detected the USB SDR. If not, unplug it, plug it back in and try again.

    Replace yourlat and yourlon with the lat/long of your location.

    Let's not burn up the SD card. That's why earlier we configured NGINX to look for the json from dump1090 in /var/run/dump1090. :D

    Now, we are going to tell dump1090 to write the json where nginx can serve it.

    Code:
    cd /home/pi/dump1090
    sudo ./dump1090 --aggressive --dcfilter --quiet --modeac --net --enable-agc --write-json /var/run/dump1090 --lat yourlat --lon yourlon
    
    You should see something like this.

    Code:
    [email protected]:~/dump1090 $ sudo ./dump1090 --dcfilter --quiet --modeac --net --enable-agc --write-json /var/run/dump1090 --lat yourlat --lon yourlon
    Fri Sep 21 03:10:58 2018 UTC  dump1090-fa 3.6.3 starting up.
    rtlsdr: using device #0: Generic RTL2832U OEM (Realtek, RTL2838UHIDIR, SN 00000001)
    Detached kernel driver
    Found Rafael Micro R820T tuner
    rtlsdr: tuner gain set to 49.6 dB
    rtlsdr: enabling digital AGC
    
    

    Point a web browser to <ipaddress>:8080 on your network and you should see planes!


    STEP 5: START AT BOOT AND FEED ADSBx

    We are going to create a bash script to start dump1090 and we will setup the ADSBx feeder scripts.

    Code:
    cd /home/pi
    git clone https://github.com/adsbxchange/dump1090-fa-tutorial.git
    
    That should download the bash script. Let's make it executable.

    Code:
    cd dump1090-fa-tutorial
    chmod +x start_dump1090.sh
    
    Now let's edit the latitude and longitude in the startup script.

    Code:
    nano start_dump1090.sh
    
    Change the --lat 0 and --lon 0 to your feeder latitude and longitude. Be sure you have the latitude and longitude correct for the hemisphere!

    Example:
    Barcelona
    --lat 41.369 --lon 2.165
    Seatle
    --lat 47.58 --lon -122.318

    Once you are done, save and close nano with:

    CTRL+O
    CTRL+X

    Now we can add start script to rc.local.


    Code:
    sudo nano /etc/rc.local
    
    Add the following to the end of rc.local but before exit 0.

    Code:
    /home/pi/dump1090-fa-tutorial/start_dump1090.sh &
    
    
    Finally ADSBx

    Code:
    git clone https://github.com/adsbxchange/adsb-exchange.git
    cd adsb-exchange
    chmod +x setup.sh
    sudo ./setup.sh
    
    Fill in all the information and off you go feeding ADSBx after a quick reboot.

    Code:
    sudo shutdown -r now
    
     
    Last edited: Dec 1, 2018
    Fung Sai Hou likes this.
  2. Fung Sai Hou

    Fung Sai Hou New Member

    James,

    Your tutorial is very detail. Thank you for the great works.

    For those new feeders who want to feed to ADSBx, this is the best solution.

    Regards.
     
  3. a6adac1e

    a6adac1e New Member

    Registered just to say thank you so much for the detailed instructions. This should be pinned. I'm a complete ADS-B noob, and having ordered the newest Raspberry Pi 3 B+, I was unable to use the "easy" pre-built image. This seems to have worked like a charm!

    Only a couple of small issues I've encountered:
    • Before "make BLADERF=no" would work I had to install "librtlsdr0" and "librtlsdr-dev".
    • Typo in "sudo systemctrl reload nginx" should be "sudo systemctl reload nginx"
     
    Fung Sai Hou likes this.
  4. James

    James Administrator Staff Member

    Thanks. I will make the edits now.
     
    Fung Sai Hou and a6adac1e like this.
  5. James

    James Administrator Staff Member

    Changed made. Don't forget to setup the ADSBx feeder! :D

    Code:
    git clone https://github.com/adsbxchange/adsb-exchange.git
    cd adsb-exchange
    chmod +x setup.sh
    sudo ./setup.sh
    
     
    Fung Sai Hou likes this.
  6. a6adac1e

    a6adac1e New Member

    I have, thank you! Now I just need to figure out how to confirm that my feed is getting there... the custom feeds thing is confusing.

    This setup isn't also feeding to FlightAware, is it? They're not seeing my PiAware on their claim page.
     
    Fung Sai Hou likes this.
  7. James

    James Administrator Staff Member

    Correct. It is not feeding FlightAware. FlightAware doesn't do anything for anyone. If you insist on feeding them - just install piaware feeder. DO NOT INSTALL thier dump1090 or anything else. Just install the feeder.

    https://flightaware.com/adsb/piaware/install

    Step 2 ONLY. DO NOT DO STEP 3.

    You will see your Pi feeder show up on the ADSBx MLAT coverage map in an hour or so.

    A custom port is simply sending to a port other than the anonymous 30005 port for beast data. Easy way to do it is to change TCP:feed.adsbexchange.com:30005 in adsbexchange-netcat_maint.sh to the custom port you picked instead of 30005.

    Then reboot the Pi.
     
    Last edited: Dec 1, 2018
  8. James

    James Administrator Staff Member

    The alternative is to install FlightAware 3.6.3 image then install ADSBx using the script method.

    As long as you understand that ADSBx is not FlightAware. ADSBx does not have some "Enterprise Account" or time to stroke you, or whatever FlightAware does for feeders offering '$89.95 a month value'. ADSBx is not FlightAware.

    Code:
    git clone https://github.com/adsbxchange/adsb-exchange.git
    cd adsb-exchange
    chmod +x setup.sh
    sudo ./setup.sh
    
     
    Last edited: Dec 1, 2018
  9. a6adac1e

    a6adac1e New Member

    Yeap, understood. Thank again. By the way, thought I had spotted another typo while going through the setup screens, just found it in the setup.sh:

    Code:
    "\nEnter your recivers atitude."
    Should be:

    Code:
    "\nEnter your receivers altitude."
    Cheers!
     
  10. James

    James Administrator Staff Member

    Yeah that needs changed on github ... I have to figure out how to do that and commit it. I hope someone puts 'sassy' ...
     
    Jhonny Monclair likes this.