DEV Community

Cover image for Technology Choices in Monitoring a Greenhouse
Ross
Ross

Posted on • Edited on

Technology Choices in Monitoring a Greenhouse

Introduction

I've started to put together a telemetry setup for my greenhouse. I've been thinking about it for a while but ultimately I've left this a bit late. It's summer, although the constant Scottish rain begs to differ.

I've only recently installed a proper greenhouse and inspired by m'colleague Neil Galls Pirragor Series, I've gotten started. I'm not doing some fancy Rust cross cross compiling, resulting in installing a new OS like Neil. I've opted to move my complications somewhere else, by growing chillies instead of tomatoes in various varieties. Needing many more individual plants and finer grained plant care. This means monitoring of temperature and humidity is the most important concern with some further thought needed in automating the upkeep of the individual plants of which there are over 20.

Straight off the bat, off the shelf Rasberry Pi is a good choice for rapid development. Python is already available so I got started.

Need Input!

I need humidity and temperature monitored, hopefully at different points in the greenhouse and compared to outside. Internally I'll be using AM2302 humidity/temperature sensor and the Adafruit Python Drivers for it which makes it as easy as

humidity, temp = Adafruit_DHT.read_retry(sensor, pin)
Enter fullscreen mode Exit fullscreen mode

And rather than weather-proofing sensors and thinking about wiring it up, I'll just use a weather REST API in the form of OpenWeatherMap and I get things like cloud cover and barometric pressure for free.

Problems?

I've noticed that randomly the AM2302 outputs a humidity of 3303.6 and a temperature of 70~ and the values had to be sanitised but otherwise, all good.

Those who cannot remember the past are condemned to repeat it!

A grandiose way of saying we need to store the data for comparison. Originally I stuck it all in a CSV file and tried -using Pygal- to write my own charts, which was time consuming and ultimately inflexible.

I need better control over the data which means a database. All of my data is going to be tied to a specific time so a time-series database is what I'm looking for. I installed InfluxDB on my Rasberry Pi, no hassle and with the help of the influxdb Python library, started to write my data there:

    db_client = InfluxDBClient('localhost', 8086, 'root', 'root', 'TelemetryHistory')
    record_entry = [
        {
            "measurement": "am2302",
            "tags": {
                "update": "whole",
                "device": "am2302",
                "location": "gh1"
            },
            "fields": {
                "temp": float(temp_reading),
                "humidity": float(humidity_reading)
            }
        }
    ]
    write_success = db_client.write_points(record_entry)
Enter fullscreen mode Exit fullscreen mode

InfluxDB, bullet point review:

  • quick to install
  • very quick to get started being schemaless
  • very quick to learn
  • perfect for analytic data, with good visualisation with Grafana
  • it has other benefits I wont use (efficient eviction, high throughput)

Then, using Grafana on my laptop, I could connect to the database on my Rasperry Pi and view whatever selected, filtered, calculated data I wanted with the ability to draw very flexible, zoomable, pretty graphs. Granted of my room at this point but pretty nonetheless.

Grafana

Next up!

I need to come up with a battery/solar panel configuration that will properly power all of this.

Top comments (0)