Announcement

Collapse
No announcement yet.

Raspberry Pi + Resin.io = Feed setup in under an 20 minutes

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Raspberry Pi + Resin.io = Feed setup in under an 20 minutes

    TL;DR
    • Get first Raspberry Pi configured, connected and submitting in 10 minutes
    • Second device in under 5 minutes
    • Changes in around 3 minutes
    • Remote management and control of all devices
    • Solution designed for 1 or many, many Raspberry Devices
    • Intended to solve my need to have Raspberry Pi's in various countries without regular physical access
    • Only requirement - ssh public key, git client, web browser and the hardware
    • Ease of setup - low


    Background

    About a year an half ago I wrote a post Raspberry Pi + Docker = Feed setup in under an hour.

    I decided to go this route because:
    • Docker was quick to share and setup.
    • Docker had become available on RPI.
    • Allow very quick, repeatable installs.
    • Main goal was to allow me to install many RPI's in various locations.


    It however had a few flaws:
    • It required some unix command line knowledge.
    • Images would have versions hard baked unless recreated.
    • Environment variables had to be hand written into docker-compose.yml file.
    • RPI's still required manual intervention (i.e. to change something, I needed physical access - which is difficult for RPI's I intended to install in other countries).

    A couple of weeks ago I stumbled across Resin.io. It seemed to resolve many of my issues.
    I am very happy with the results and thought I would share my project with everyone else.

    Resin.io has allowed me to:
    • Deploy first device in under 20 minutes.
    • Deploy subsequent devices in under 5 minutes.
    • Allow very quick, upgrades of software in around 2 minutes (on all devices).
    • Remote manage and control all devices (even if they are not inside my current network).


    Installation information to follow...
    Last edited by inodes; 2017-06-13, 03:50.

  • #2
    Prerequisites
    • Obviously a Raspberry Pi (2 or 3 is best).
    • A blank micro SD card (16GB preferred, class 10 preferred)
    • RTL-SDR Dongle
    • Access to a command line with git (could be Windows, Linux, Mac OS).
    • A small amount of time.
    • One or all of the following accounts: Flightradar24, Flightaware, Planefinder.


    What is going to happen?
    1. Create a Resin.io account with a application
    2. Download Resin.io image for your device, install, plugin.
    3. See device appear on Resin.io and add required variables.
    4. Clone my repo which contains basic Docker template, start up scripts.
    5. Set git remote of your new clone to your Resin.io account, push.
    6. Wait - and you're done.


    Hang on... Docker returns?
    Resin.io uses a Docker template to re-create the images whenever anything changes. This takes the hard work out of you getting involved. This also means that when there is a software change, it's very easy to trigger Resin.io to create a new image. Resin.io does all the heavy lifting, it downloads the new software, compiles it and puts it into a new Docker image which is downloaded to your device. So easy!!!!

    How hard is this?
    • Not at all!
    • Only need to copy a couple of git commands.
    • No Linux knowledge required.
    • Everything driven from Resin.io.

    Comment


    • #3
      Before Starting
      Working with Resin.io requires interaction between files on your computer and Resin.io using git.

      This requires:
      • ssh installed
      • git installed


      If you have Linux or MacOS, these are already inbuilt. If you have Windows, these do not come preinstalled and will require some installation. The following guide might help.

      If you already have these, skip to "Setting up Devices and Resin.io Account".

      The main goal of the above is to:
      • Ensure you have an ssh public key created (allows you to connect to Resin.io)
      • Have a git client that allows you to push files to Resin.io


      Setting up Devices and Resin.io Account
      1. Signup at Resin.io for an account at https://dashboard.resin.io/signup
      2. Create a new application in Resin.io for a Raspberry Pi (2 or 3 - this doesn't seem to matter).
      3. Click on your Application, then click "Download Resinos" to download the Resin.io OS. Follow these instructions.
        1. The image will require knowledge of either your WiFi password or a fixed connection (this is for your use only)
        2. A copy of your ssh public key.
        3. Resin.io's application https://etcher.io/ is best for creating images.
      4. Wait for your device to become available on Resin.io website.
      5. Once available:
        1. Click on the device.
        2. Select "Environment Variables" on the left of the Resin.io window.
        3. Insert your GPS co-ordinate variables (See http://www.whatsmygps.com/):
          • LAT = <latitude of your location>
          • LONG = <longtitude of your location>
        4. Insert the following Planefinder variable if known:
          • PF_SHARECODE = <Planefinder sharecode>
        5. Insert the following Flightradar24 variable if known:
          • FR24_KEY = <Flightradar24 key>
        6. Insert the following Flightaware variables if known:
          • PIAWARE_MAC = <your network MAC address for old devices>
          • PIAWARE_ID = <your feeder id>
          • PIAWARE_PASSWORD = <your Flightaware password>
        7. The following variables are optional:
          • GAIN = <gain used by dump1090>
          • PPM = <ppm used by dump1090>


      Resin.io allows for variables to be set per application and/or by device. The advantage in this is it allows you to have many devices in varied locations with varied accounts.

      EDIT:

      * PIAWARE_PASSWORD and PIAWARE_USER are deprecated
      * PIAWARE_MAC is deprecated and only used on old devices
      * PIAWARE_ID is the Feeder ID and replaces MAC
      Last edited by inodes; 2017-06-17, 23:37.

      Comment


      • #4
        Cloning My Code and Pushing to your Device(s)

        I've created everything you need code wise to get this working. You don't need to do anything except setup your accounts, and push the code.
        1. Open up a terminal (Linux/MacOS) or command prompt (Windows)
        2. Clone my repo from https://bitbucket.org/inodes/resin-docker-rtlsdr (type this verbatim) using git clone <myrepo>.
          Code:
          $ git clone https://inodes@bitbucket.org/inodes/resin-docker-rtlsdr.git
          Cloning into 'resin-docker-rtlsdr'...
          remote: Counting objects: 178, done.
          remote: Compressing objects: 100% (176/176), done.
          remote: Total 178 (delta 106), reused 0 (delta 0)
          Receiving objects: 100% (178/178), 21.84 KiB | 0 bytes/s, done.
          Resolving deltas: 100% (106/106), done.
        3. Change into the repo directory you've just cloned
          Code:
          $ cd resin-docker-rtlsdr/
        4. Copy the git remote command from your application in resin (this is in top right in Resin.io page)
        5. Paste the git remote command onto command line (your command will differ).
          Code:
          $ git remote add resin yourlogin@git.resin.io:yourlogin/yourproject.git
        6. Push to remote using the command
          Code:
          $ git push resin master
          ..... LOTS OF OUTPUT

        The above output is the build from scratch of everything required to run Flightradar24 and other utilities.
        The great thing about this is that if you have many devices, they are all updated.
        Last edited by inodes; 2017-06-13, 01:36.

        Comment


        • #5
          A few things to note
          Once your device is up and running, there are a few things to note.
          Resin.io allows you to see the status of each device and control it.

          Devices Page
          • Control your devices
          • See what your local IP address would be
          • See the most recent commit
          • Reboot and connect to your devices



          Environment Variables
          • This is where the secret sauce is. Set variables that can be used in scripts running on the device (e.g. the start.sh I have provided)
          • If you change the location of a device, just change the variable for LONG and LAT. The device automatically rebuilds using the new variables.



          Device Summary
          • See the current state of the device. Easy to see the output from the current Docker image.
          • See the ip - from here if you're on the local network, you can connect to the device as per usual (e.g. in my case, opening http://10.0.1.84:8080/ on my local network gives me the normal Flightradar24 client UI).



          Device Terminal
          • Connect to any device from any location, even if you're not on the local network.
          • Debug the application. You could for example change the scripts I provided completely, push again to resin and have a completely different result. It allows flexibility on scale.

          Last edited by inodes; 2017-06-13, 03:44.

          Comment


          • #6
            Thanks for this, it worked perfectly.

            Comment


            • #7
              Thanks inodes for sharing!
              --

              Comment

              Working...
              X