Acuity Brands Logo      DGLogik is now part of Acuity Brands, Inc.   Learn More >>

Using a Raspberry Pi, BeagleBone or DGBox as a DSA Server

DSA, Raspberry Pi, and DGLux5 

We installed DSA and DGLux5 on our Raspberry Pi 2. Watch the video below to see how we did it!

Distributed Services Architecture (DSA) is an open-source platform that facilitates communication among devices, logic, and applications in the IoT. You can download it here.

UPDATE: You can use these same steps, with a few modifications, to install DSA on DGBox or BeagleBone.

See the bottom of this post for more information.

Prerequisites

If you want to follow along with the video, you will need:

  • A Raspberry Pi
  • A Mac, Windows, or Linux computer—we used a Mac.
  • A micro SD card—we used 4 GB.
  • A network cable and an Internet connection
  • A micro USB power adapter
  • A keyboard that connects to your Raspberry Pi via USB (only needed briefly)
  • A monitor that connects to your Raspberry Pi via HDMI (only needed briefly)

If the Raspbian OS is not already installed on your micro SD card, you will also need:

Important notes

All of the steps and command line commands can be found below the video.

The video does not include steps to expand your SD card’s file system. You will probably need to do this. You do it after installing Raspbian and before installing DSA. See the steps below the video.

Using a Raspberry Pi as a DSA Server: Video

Steps

These steps cover the following:

Install Raspbian

There are several ways to install Raspbian on a micro SD card. We downloaded the Jessie Lite ZIP file here and then followed the Mac instructions here. You could also install Raspbian from Windows or Linux, and you could use NOOBS.

To install Raspbian on your micro SD card from a Mac:

  1. Insert the micro SD card in a memory card reader.
  2. Connect the memory card reader to your computer.
  3. Unzip the Jessie Lite ZIP file.
  4. Go to About this Mac, and select System Report.
  5. Select the memory card reader under Hardware.
  6. Make note of the BSD name. It is probably something like disk2, disk3, or disk4.
  7. Open Disk Utility, select the volume that represents your SD card, and click Unmount.
  8. Open the command line, and run this command:
    sudo dd bs=1m if=<installationFileName>.img of=/dev/disk2

    As needed, replace the installation file name and the BSD name of the disk.

  9. When prompted, enter your password.
  10. Wait while the Raspbian OS installs. This can take 10 to 30 minutes.
  11. Eject the volume, and remove the SD card.
  12. Insert the SD card in the Raspberry Pi.

Enable SSH and get IP address

To enable SSH and get the Raspberry Pi’s IP address:

  1. Connect a network cable, USB keyboard, and HDMI monitor to the Raspberry Pi.
  2. Connect the micro USB power cable to the Raspberry Pi.

    The Raspberry Pi boots up, and a command line interface appears on the monitor.

  3. When prompted, enter the default credentials:
    • username: pi
    • password: raspberry
  4. Enter this command:
    sudo raspi-config
  5. Use the arrow keys to select Advanced Options.
  6. Use the arrow keys to select SSH.
  7. When prompted, select Enable.
  8. When prompted, select OK.
  9. Use the arrow keys to select Finish.

    SSH access is now enabled.

  10. Enter this command:
    hostname -I
  11. Make note of the IP address of your Raspberry Pi.

Connect to the Raspberry Pi using SSH

To connect to the Raspberry Pi from a Mac on your network:

  1. Open the command line, and run this command:
    ssh pi@10.x.x.x

    Note: if you are recreating a server that you have created before, you will receive a warning that says Remote Host Identification Has Changed. If this happens, you can enter these two commands:

    ssh-keygen -R 10.x.x.x
    
    ssh pi@10.x.x.x
    
  2. When prompted, type yes, and then enter your Raspberry Pi’s password.

Expand the SD card’s file system

To make the entire SD card writeable:

  1. Enter this command:
    sudo raspi-config
    
  2. Use the arrow keys to select Expand Filesystem.
  3. Use the arrow keys to select Finish.
  4. When prompted, accept the request to reboot.
  5. When prompted, enter the username and password for your Raspberry Pi.

Install DSA

To install DSA on your Raspberry Pi that is running Raspbian:

  1. Connect to your Raspberry Pi using SSH:
    ssh pi@10.x.x.x
    
  2. Enter these commands:
    sudo su
    mkdir -p /opt/dsa
    cd /opt/dsa
    export DGLUX_SERVER_BUILD=$(curl 'https://dsa.s3.amazonaws.com/dists/dists.json' --silent | grep "latest" | awk '{gsub("\"", " "); print $3}')
    wget https://dsa.s3.amazonaws.com/dists/dglux_server/${DGLUX_SERVER_BUILD}/dglux_server.zip -O dglux_server.zip
    unzip dglux_server.zip -d dglux-server
    wget https://gsdview.appspot.com/dart-archive/channels/stable/release/1.14.2/sdk/dartsdk-linux-arm-release.zip -O dart-sdk.zip
    unzip dart-sdk.zip
    cd /opt/dsa/dglux-server
    wget --no-check-certificate https://github.com/IOT-DSA/dists/raw/gh-pages/helpers/wrapper.sh -O bin/daemon.sh && chmod +x bin/daemon.sh
    nano /etc/init.d/dsa
  3. Paste this entire script into the window that opens:
    #! /bin/sh
    ### BEGIN INIT INFO
    # Provides: dsa
    # Required-Start: $remote_fs $syslog
    # Required-Stop: $remote_fs $syslog
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: DSA + DGLux5 Server
    # Description: This file starts and stops DGLux5 server
    #
    ### END INIT INFO
    
    case "$1" in
     start)
       /opt/dsa/dglux-server/bin/daemon.sh start
       ;;
     stop)
       /opt/dsa/dglux-server/bin/daemon.sh stop
       sleep 1
       ;;
     restart)
       /opt/dsa/dglux-server/bin/daemon.sh restart
       ;;
     *)
       echo "Usage: dsa {start|stop|restart}" >&2
       exit 3
       ;;
    esac
  4. Press Ctrl+X to save the file.
  5. When prompted, press Y to save changes, and then press Enter to accept the file name.
  6. Enter these commands:
    sudo chmod +x /etc/init.d/dsa
    sudo update-rc.d dsa defaults

Start DSA and DGLux5

  1. Enter this command over your SSH connection:
    service dsa start
  2. Wait 1 to 3 minutes while the service starts. This delay happens only the first time.
  3. Open your web browser, and go to the following:
    10.x.x.x:8080
  4. Log in to DGLux5 with the following credentials:

    username: dgSuper

    password: dglux1234

  5. Use the dialog to request a license or submit license information.

Change DGLux5 to port 80 (optional)

This lets you type only the IP address in your browser when you access DGLux5 in the future.

  1. Enter these commands over your SSH connection:
    cd /opt/dsa/dglux-server
    nano server.json
  2. Use the arrow and delete keys to change the following:

    Change 8080 to 80.

    Change 8443 to 443.

  3. Press Ctrl+X to save the file.
  4. When prompted, press Y to save changes, and then press Enter to accept the file name.
  5. Wait 1 to 3 mintues while the port changes.
  6. In your web browser, go to the following:
    10.x.x.x

Stop DSA

To stop the DSA service, enter this command over your SSH connection:

service dsa stop

A note about static IP

If you power down your Raspberry Pi and then start it up again later, DSA should start up on boot, but the IP address might change. To prevent this, you can try giving your Raspberry Pi a static IP, or you can get the hostname again by using hostname -I.

BeagleBone and DGBox

Installing DSA on a BeagleBone or a DGBox is similar to installing on a Raspberry Pi. With a BeagleBone, you use the same installation commands. With a DGBox, you must get and unzip a different version of the Dart SDK.

Connect via SSH

If you are using a BeagleBone, connect to the BeagleBone via SSH.

If you are using a DGBox:

  • First, connect the DGBox by following these steps.
  • Then, connect to the DGBox via SSH. From a Mac, you can do this by entering the command ssh This email address is being protected from spambots. You need JavaScript enabled to view it..2.1 and the DGBox password. From Windows, you can download an SSH client if you do not already have one installed.

Install DSA

If you are using a BeagleBone, follow the same steps above to install DSA.

If you are using a DGBox, follow the steps above to install DSA, but in step 2, replace these commands:

wget https://gsdview.appspot.com/dart-archive/channels/stable/release/1.14.2/sdk/dartsdk-linux-arm-release.zip -O dart-sdk.zip
unzip dart-sdk.zip

with these commands:

wget --no-check-certificate https://github.com/IOT-DSA/dart-sdk-builds/raw/gh-pages/dreamplug.zip -O sdk.zip
unzip sdk.zip -d dart-sdk

To access the DSA and DGLux5 that you just installed on a BeagleBone or DGBox, go to port 8080. For example, on a DGBox this would be http://192.168.2.1:8080.

Use runtime managers

After you install DSA on a BeagleBone or DGBox, you should enable runtime managers. This saves memory usage and other resources. 
 
To set runtime managers to true:
  1. Enter cd /opt/dsa/dglux-server.
  2. Enter nano server.json.
  3. Change the following to true:
    • useRuntimeManager
    • useDartRuntimeManager
    • useJavaRuntimeManager
  4. Press Ctrl+X to save the file.
  5. When prompted, press Y to save changes, and then press Enter to accept the file name.

Join the conversation

Share your DSA ideas for Raspberry Pi, BeagleBone, and DGBox in the Google Plus community and on Slack!

Contact Us        Blog