Need cloud computing? Get started now

Dark background with blue code overlay
Blog
RSS

Tree-Tracker - Auditing a Log Harvest Using IOT Edge Connect and Node-red

Brian Apley

Written by

Brian Apley

January 05, 2021

Brian Apley

Written by

Brian Apley

Brian Apley

I’ve worked in the networking and technology field for more than 20 years helping companies overcome challenges in communicating with customers, distributors, employees, and supply chains. As principal Internet of Things (IoT) architect at Akamai, it’s only natural for me to turn to the technology solutions I use everyday to solve customer problems to track the progress of my own pet project: Blue Water Farm. 

At long last, Blue Water Farm is generating revenue! Around 20 acres of our land consists of dense, mature hardwood of oak, maple, and beech, and we were able to contract to sell 65 maple and 25 oak trees to a logging company. I won't be retiring from Akamai any time soon from this logging windfall, but it's nice to see some proceeds from our land, and clearing mature trees is a part of good responsible forest management. 

The log harvest underway... see the fallen trees laying in our field? The log harvest underway... see the fallen trees laying in our field?

The logging company marked the trees they want to harvest with spray paint around the tree trunk. This is good, as it lets us see which trees they were proposing to take before we agreed to sell them. However, as I was reviewing these marks, a problem occurred to me. How do I verify post-harvest that ONLY the marked trees were taken? After all, once the tree is gone, so is the mark. I trust my logging company, but how do I verify that extra trees weren't taken, when all I'll see is the remaining stump? 

Akamai IoT Edge Connect and Node-RED to the rescue! While I could have shopped for a commercial product to fulfill my need, or even simply dropped a bunch of Google Map pins as I walked in the woods, there are benefits to building my own solution:

  • I would like to avoid having to remove my gloves and operate my phone while in the woods. It’s cold this time of year, and currently deer-hunting season in Michigan, so I'm motivated to limit my time in the woods. Plus, I'd prefer to mark tree locations by shaking my phone and generating dramatic accelerometer readings, ideally, along different axes (X, Y, Z) to mark different tree species.

  • One big benefit of logging our woods is having the company blaze trails as they reach the trees being harvested. In addition to marking the trees, I want to record my track as I walk through the woods, mapping those new trails.

  • Once I complete the timber-cruise, I'll own a log of all the data, which I can then input into future logging projects, or work with in ways that I can't imagine today. This is a general tactic in the world of Big Data: Capture more than what you need and put it on the shelf should an interesting insight arrive in the future.

  • Message Queuing Telemetry Transport (MQTT) is a great protocol for this effort. Cell service in the woods is unsurprisingly weak and spotty. As I tested and implemented this solution, my MQTT connection never failed me, even when I was unable to load a simple web page.

Of course, the best reason for doing this myself is that it's fun! This project is a great demonstration of how to build a useful, relevant application using Edge Connect.

Project requirements

Simple diagram of tree tracker application Simple diagram of tree tracker application

As is the case with my previous demos, I am using Node-RED to build the client and analytics engine. Node-RED now has both iOS and Android ports, which allows for running a full Node-RED server on the device. This made writing a client-side mobile application for data collection a 10-minute effort.

Client flow

Below is the Node-RED flow used on the client. For clarity on the screen shot, I captured this on my iPad, though, in practice, I used my phone to run the collection tasks.

Node-REDclient flow Node-REDclient flow

Node-RED for iOS has some handset-specific nodes, which allow for access to the phone's location and gyroscope data. In the flow above, we are capturing that data, limiting its resolution to one message per second, and publishing the data to IoT Edge Connect via MQTT. 

A common approach in IoT applications such as this is to make the client as simple as possible. More code and complexity means more battery and network usage, and it increases the chance that something on the client-side will need an update. We want a client application that uses as few resources as possible, and won't cause an expensive field update should something need to be changed.

This client application meets those goals -- it's a simple data dump every second of the gyroscope (X, Y, Z movement) and location (latitude, longitude, and altitude).

Server flow

There are three things, for now, that I must do with this data in order to fulfill the needs of this solution:

  1. Log the inbound data from MQTT

  2. Analyze the data for those axis "shakes" so I can map the tree locations

  3. Map the data, including my walking track and the tree locations

Data logging

Data logging flow Data logging flow

I am performing some data pre-processing at the server prior to logging, namely combining both location and gyroscope feeds into a single message. This will allow me to associate axis "shakes" (marking trees) with specific latitude/longitude/altitude coordinates. Again, I could potentially do this on the client, but it's in my interest to keep the client lightweight.

Once combined, I write the data to a local log file, and also publish to Google Sheets for more robust storage and potential future analysis.

Data analysis and mapping

Analysis and mapping flow Analysis and mapping flow

I started this flow by reading the file I created in the data logging flow. I then replayed that data, looking for messages where the axis movement exceeded a threshold. When determining the appropriate threshold (to identify times that I was shaking my phone to mark a tree, as opposed to inadvertent shaking and movement), I was able to play with the values until I got an accurate mapping.

I then mapped both the overall track of movement through the woods, and specific tree locations. I used x-axis shakes to mark the location of maple trees, and y-axis shakes to mark oak trees. When I map these, I distinguish between oaks and maples via icon color.

Replay of the tree-tracker log file on the map Replay of the tree-tracker log file on the map

Results

I have not yet compared my analysis result to the post-harvest stumps in our woods. So far, I am very happy with the logging, as my family now has miles of trails where none existed, allowing us countless hours of recreation and enjoyment. Plus, we can move in and out of the woods easier, allowing us to remove old dead trees and fallen timber for firewood. These maintenance activities are good for forest health, and will allow more trees to grow even larger.

Aerial view of our new trail network Aerial view of our new trail network

Use cases such as my tree tacker are useful in showing the promise and power of connecting the physical and digital worlds. Through IoT Edge Connect, Akamai offers our customers a walk-up, plug-in experience, allowing you to build relevant applications, reliably, securely, and at scale. I will be using our land and Edge Connect for future applications to make my woods (and me) smarter.

Build your own

Even if you don't have a pending log harvest, using Edge Connect and Node-RED makes it easy to build something that is relevant to you or your customers.

Big lesson learned, loggers are different and wonderful people Big lesson learned, loggers are different and wonderful people


Brian Apley

Written by

Brian Apley

January 05, 2021

Brian Apley

Written by

Brian Apley