Software

GrowSense is open source and available for anyone to use and contribute to. Follow this guide to use it in a garden or farm, or for development purposes.

Get the code

All source code is stored in the GitHub repository

Setup

Auto Clone and Setup

The automatic clone and setup script is recommended for most situations.

Use either wget or curl (depending on what is installed on your system) to download and launch the setup scripts.

wget
  • wget -O - https://raw.githubusercontent.com/GreenSense/Index/master/setup-from-github.sh | sh
  • cd GreenSense/Index
curl
  • curl https://raw.githubusercontent.com/GreenSense/Index/master/setup-from-github.sh | sh -s
  • cd GreenSense/Index

Manual Clone and Setup:

The code can be manually cloned and initialized if necessary.

Note: The automatic setup script above is recommended for most situations.

Remote Setup

The GreenSense source code and projects can be configured remotely on a networked garden computer.

Follow the networking guides to set up a networked garden computer with remote SSH access.

Once connected remotely via SSH to the garden computer you can continue with the guide below.

Prepare System

Open a command terminal on a linux computer (if you don't already have one open):

  • ALT+CTRL+T

Upgrade General System Software

  • Upgrade the general linux system software:
  • sudo apt update && sudo apt -y upgrade

Note: This may take a long time to complete.

The garden computer is now upgraded with the latest linux system software but the computer needs to be rebooted.

Reboot

Reboot the computer so upgrades can take effect:

  • sudo reboot

Enter the password when prompted and press ENTER

If you're using SSH to connect to the garden computer then the SSH connection will be closed as it reboots

If you're working on the computer that the hardware is attached to then just wait for it to reboot, then open a new terminal window once it has.

If you're working via SSH then ping the garden computer to see when it comes back online:

  • ping [hostname]
  • ping garden

There may be no response for some time, just wait as the garden computer reboots.

Once the ping command starts returning results then the garden computer is back online.

When you see a similar output press CTRL+C to exit back to the terminal prompt.

If working remotely via SSH then log back in to the garden computer:

  • ssh j@[hostname]
  • ssh j@garden

Enter your password when prompted and press ENTER.

Note: The number at the top right after "LTS" indicates the kernel header version. If the number is 4.* or above then the kernel headers are up to date should support docker.

Prepare Source Code

Create a workspace directory for the source code to be cloned into:

  • mkdir workspace

Move to the workspace directory:

  • cd workspace

Set up the GrowSense index from the GitHub repository:

wget

  • wget -O - https://raw.githubusercontent.com/GreenSense/Index/master/setup-from-github.sh | sh

curl

  • curl https://raw.githubusercontent.com/GreenSense/Index/master/setup-from-github.sh | sh -s

Notes:

  • This command will take a long time to run because it installs a lot of software including mono, platform.io, docker, etc. and downloads libraries required for the GreenSense projects.
  • After running this command you no longer need to run the prepare.sh or init.sh scripts as they're run automatically by the setup-from-github.sh script.

Move into the GreenSense index base directory:

  • cd GreenSense/Index

Use this terminal for commands provided throughout the walkthroughs.

Make sure the working directory is ~/workspace/GreenSense/Index unless shown otherwise.

Edit Source Code

The source code can be edited by anyone who has permissions to the GitHub repository. Use the discussion page to request permissions.

Set up the source code:

  • curl https://raw.githubusercontent.com/GreenSense/Index/master/setup-from-github.sh | sh -s
  • cd GreenSense/Index

Switch to the 'dev' branch:

  • git checkout dev

Pull any new changes:

  • git pull origin dev

Edit the code:

  • Use your favorite editor to open and edit files

Commit the code:

  • git commit -am "[Comment]"

Push the code:

  • git push origin dev

View the test results:

Continuous Integration, Testing, and Deployment

Summary

The GreenSense projects are set up with continuous integration, testing, and deployment.

Continuous integration is configured for the following projects:

Process

When code is pushed to the 'dev' branch of any GreenSense project repository the following automated processes are triggered automatically:

Automated Software Tests

  1. Travis CI detects the change to the 'dev' branch and:
    1. Clones the code
    2. Prepares and initializes the project
    3. Builds the code (if applicable)
    4. Runs automated software tests
    5. If tests pass (for software only components):
      1. Code is graduated (merged) into the 'master' branch
      2. The version build number is incremented (if applicable)
      3. The new version build number is pushed to the GitHub repository
      4. Detects the change to the 'master' branch and re-runs tests to double-check the master branch is stable
      5. Creates and pushes an updated nuget package (if applicable, such as with the MQTT bridge and GitDeploy utilities)

Automated Hardware Tests

  1. Jenkins detects the change to the 'dev' branch:
    1. Clones the code
    2. Prepares and initializes the project
    3. Builds the code sketch and automated test suite
    4. Runs automated hardware tests
    5. If tests pass (for hardware based projects):
      1. Code is graduated (merged) into the 'master' branch
      2. The version build number is incremented
      3. The new version build number is pushed to the GitHub repository
      4. Detects the change to the 'master' branch and re-runs tests to double-check the master branch is stable

Automatic Deployment/Update

  1. The GreenSense updater (GitDeployer) application runs on the garden computer to automatically update GreenSense devices (ie. the monitor and irrigator) by doing the following:
    1. Clone/pull the 'master' branch and check for changes
    2. If no changes are found:
      1. Wait a while before checking for changes again and repeating the process
    3. If changes are found in the 'master' branch
      1. Pull the latest updates from the GitHub repository
      2. Re-initialize the project
      3. Rebuild the sketch
      4. Upload the sketch via USB to the arduino in the monitor/irrigator device
      5. Wait a while before checking for changes again and repeating the process