Writing Code for Agriculture

Modern agriculture is surprisingly technical, but I hadn’t personally had any interactions there until recently.

Right now, we’re working on a small project to automate agricultural measurements. Measurements that are usually taken manually.

The first problem we’re starting with is soil moisture balance.

If you’ve ever asked yourself the question, “how much and how often should I water this plant?” Well keeping tabs on soil moisture balance for the particular thing you’re growing is the answer.

As it turns out, doing that in practice requires quite a few data sources to come together. There’s constants that go along with soil types, the type of plant, the local climate, the efficiency of the irrigation system, and the effects of rain and irrigation events to take into account.

It’s a mildly interesting set of concepts and minor accounting problems that has been kinda fun to learn, or as we’ve been calling it — “LaCroix learning”.


To solve this problem in a meaningful way, we started with understanding the calculations and the concepts behind the problem. So I had to sit down and understand all the concepts and inputs behind soil moisture balance.

Once I had a good understanding of that, I set up a node server and SQLite database.

I wrote some controllers that fetched data from external sources, some controllers for saving and reading from our own database, and some for transforming, sorting, and synchronizing.

Once the controllers are done, it’s time to make it accessible to clients. This is traditionally done with REST conventions, but nowadays, GraphQL ends up being a more flexible alternative. It standardizes the patterns for querying and modifying data, so I can focus on writing good controllers.

After I built a simple data server, it was time to visualize this data. Lately I’ve taken a liking to a library called Apexcharts that has done a great job making animated charts that have a well designed standard interface.

I used Vuetify as the component framework for the menus, the form elements, and the frame of the application.

We’re on track to add in layers of authentication to allow farmers to view the data for their particular fields and also forecast future soil moisture balance numbers using historical data sources.

This is a work in progress. More to come.

Let's get started

Just let us know the basics and we'll send you a Slack invite to discuss with the whole team.

What are we going to be talking about?