This post should’ve been written one year ago, when I actually did this project. With another holiday project coming up, it feels necessary to at least post a summary of last years project.

In-door gardening seems to become popular, and rather than spending a lot of money on a nice-looking product like auk, I thought I would instead spend twice as much on my own beutiful rig:

concept

The goal is to monitor some herbs, measuring their soil moisture, and then water the plants with the goal of getting a good harvest. Of course, this can all be made much simpler and mechanical, but where is the fun in that?

The target architecture is as follows:

architecture

A microcontroller periodically measures moisture and reports a relative humidity to the cloud. In the cloud, there is an controller running that consumes these events and decides if the plant is too dry or not. If plan is too dry, the controller will send a message back to the microcontroller instructing it to water the plant. A console shows the current and historical state of the plants.

Hardware

  • ESP8266
  • Pump + Relay
  • Soil moisture sensor
  • Artifical light
  • Timer for artificial light

As a microcontroller I chose an ESP8266 using a NodeMCU-based board. This microcontroller has a WiFi chip builtin, which makes it easy to connect it to my home network and talk to the cloud serviec.

For watering the plants, I used a submersive pump mounted at the bottom of a plastic box. To control the pump on/off, I used a relay connected to the microntroller.

To measure the soil, I initially started off with a sensor from sparkfun, but it was not able to tell the difference from soaking wet to a little moist. I replaced that later with a capacity sensor from dfrobot that gave more accurate readings.

Finally, to ensure stable light conditions for the plants, I purchased an artifical light lamp and a timer that turns on and off at specific hours during the day.

Software

Microcontroller

The microcontroller is implemented using Arduino + PlatformIO, which works OK for hobby projects.

Messaging Layer

This is only needed to push data to/from cloud/devices. You can host this yourselv using the open source projects like Eclipse Hono and EnMasse, or use a commerical services as Bosch IoT Hub.

Greenhouse Backend

The cloud side of the greenhouse contains several components to handle event data and displaying graphs:

  • Console API - A GraphQL API for the console to pull event data.
  • Console - A single page application written in Svelte that uses the GraphQL API to retrieve data.
  • Controller - A Go-based server that subscribes to event data and sends commands back to an Eclipse Hono API to water the plants.
  • Hono Sink - A Go-based server that pulls data from an AMQP messaging service and stores it in an event store.
  • AMQP Event Store - A Go-based event store where all event data is stored.

The entire backend is written to run in Kubernetes.

Result

All in all, I’m pretty happy with the result, even though I suck at carpenting:

Mount

The whole thing in action:

Complete

Summary

All in all, this was a really fun project, and the basil plants did enjoy the extra care (and I was able to make lots of pesto!). Unfortunately, during our move to a new home, the entire thing got dismantled and I haven’t brought it up again. I am thinking about making a larger v2 of this now that we have more space.