Build an aquaponic indoor farm – part 5 – Production management

This is a description of how we at Johannas Stadsodlingar (urban farms) and Concinnity together have built Johanna’s aquaponic pilot facility. We want to share how we did it and our thinking behind it. There is quite a lot to think about, so there will be several posts to cover most things.

Cultivation Management Platform

The digital systems we have built are based around the vision we set out with at the start of the project. We call it the Cultivation Managment Platform.

Cultivation Management Platform, Copyright 2019 Johannas Stadsodlingar AB. Some rights reserved. Creative Commons BY-SA-NC 3.0.

The CMP consists of four parts:

  • Water quality and nutrients tests
  • Water, air and automation sensors
  • Production management
  • Distributed ledger / block chain

In this part we will describe our work with the production management system.

Production management system – overview

With digital tracking, or production tracking, we collect data on how the cultivation itself is progressing. The main components of this system are a mobile app and a cloud-based service with which the app communicates. With the mobile app, we record every significant event during a plant’s path through the system, from seed to finished lettuce head! All data is stored in the cloud service and is accessible both from the app and from an administrative interface in the service.

Production management mobile app

Cultivation process as data

The cultivation process is organized in what we call batches, where one batch is one or more germination occasions of the same seed made at the same time. As a plant goes from seed to harvest, we generate and record four events that we call Seed, Seedling, Plant and Harvest. Each batch in turn consists of one or more ”containers” where the plants grow. At the start of a batch, the seeds are placed in substrates in trays with between 77 and 150 plants. These trays stand on a cultivation table, a shallow basin with a few centimeters of water. The tray is covered with a plastic hood for higher temperature and humidity. The first event, Seed, is recorded when we sow a tray.

IMG_0337

Anke moving seedlings from a tray to a raft

The germination period is about a week long, after which the tray is moved to another cultivation table where the seedlings can continue their growth for a few weeks. When this move is made, we register a Seedling event. How long the plants spend as seedlings depends on the type of plant.

When the seedlings have grown to the right size on the tray, it is time to move them out to the large cultivation basins. This is done by moving each individual plant to a raft. The rafts are just under a square meter in size, and hold 30 or 32 plants. The two different types of rafts have different sized holes where the plant is placed and are therefore suitable for different types of plants. For each raft, we register a Plant event. After a number of weeks on the rafts, again for different lengths of time depending on the type of plant, the finished plants are harvested. This is usually done the same day or the day before they are delivered to the customer. For each raft that is harvested, we create a Harvest event.

IMG_1937

A raft is being brought out for harvest

For each event, we record the time of the event, who does the registration, and the number of plants that are currently on the tray or raft. For example, some seeds have not germinated properly and we register the loss when we create the Seedling event. In the case of Seed and Plant events, we register the ID of the cultivation tray or raft used. You can also add a free text note. In addition, the following data is stored for the various events:

  • Seed: seed variety and supplier, ID of cultivation tray, number of seeds and any cultivation accessories used
  • Seedling: the number of seedlings
  • Plant: raft ID and the number of plants
  • Harvest: the number of plants harvested

Implementation

The production management system consists of two main parts; a mobile app and a server with which the app communicates via HTTP and where we store the data registered via the app. The app is built with the Flutter framework. Flutter makes it possible to create apps that use the same source code but can run on both Android and iOS-based phones and tablets. The cloud service is built with the Django framework, a framework for all types of HTTP-based backend solutions. In addition to Django, we also use PostgreSQL as a database and Hasura which provides a GraphQL API to the database.

In the next post we will have a look at our distributed ledger/block chain integration.

The text in this posted is licensed under Creative Commons BY-NC-SA International.

Build an aquaponic indoor farm – part 4 – water quality and nutrients testing

This is a description of how we at Johannas Stadsodlingar (urban farms) and Concinnity together have built Johanna’s aquaponic pilot facility. We want to share how we did it and our thinking behind it. There is quite a lot to think about, so there will be several posts to cover most things.

Cultivation Management Platform

The digital systems we have built are based around the vision we set out with at the start of the project. We call it the Cultivation Managment Platform.

Cultivation Management Platform, Copyright 2019 Johannas Stadsodlingar AB. Some rights reserved. Creative Commons BY-SA-NC 3.0.

The CMP consists of four parts:

  • Water quality and nutrients tests
  • Water, air and automation sensors
  • Production management
  • Distributed ledger / block chain

In this part we will describe our work with Water quality and nutrients tests.

An aquaponic farm is an ecosystem with many ”moving parts” and you need continuous, precise monitoring of it with the help of both manual and automated systems. On top of that it’s important for us to acquire as much knowledge as possible about the ins and outs of how the system actually works, like how long time different plants take from seed to harvest, how much the fish grow and so on. We use our CMP to achieve these goals with the help of modern technology in combination with our knowledge on plant and fish cultivation.

Water quality and nutrients tests

To get an understanding of an aquaponics system and to be sure that ”everything’s all right” we need to make regular tests of the water to be able to discover any problems that might arise and to analyze how the water quality affects the system as a whole.

When the system was started and the bacterial culture for the nitification process was built up, we took measurements every day to get good control and understanding of the growth process. Now, when the system is up and running in a stable manner, we measure most indicators once a week.

We had initially planned to use a system for data collection and analysis that we have worked with before, Avo Flow by Akvo Foundation. Akvo Flow consists of an Android based app for data collection with a web based backend for admin and visualization tools, along with an integration with photo-metric and other water quality sensor systems called Akvo Caddisfly. However we realized that the amount of reagent chemicals needed was larger than what was advisable in our fairly small pilot system.

Thus we chose to use a combination of photometric and other sensors from different suppliers. One of the down sides of this is that these other components have very poor or totally lacking digital integration, so we now have a large spreadsheet instead for all the data we collect this way.

IndicatorSensorComment
AlkalinityeXact iDip, ITS
AmmoniumeXact iDip, ITS
PhosphateeXact iDip, ITS;
Checker, Hanna Instruments
eXact iDip can only be used up to 3 ppm
HardnesseXact iDip, ITS
IronChecker, Hanna Instruments
PotassiumPhotometer Potassium, Hanna
Instruments
Dissolved oxygenHandy Polaris 2, OxyguardPortable reference meter
NitrateeXact iDip, ITS
NitriteeXact iDip, ITS
pHpH-Checker, Hanna
Instruments
Portable reference meter
Water quality and nutrients tests

Digital monitoring – Water, air and automation sensors

The system we developed for collection, storage and presentation of real-time data consists of two main parts. The system that collects the data is called Aquasensor and the system for storage and display of the data is called Aquadata.

An overview of the digital monitoring system, Aquasensor and Aquadata

Critical indicators as well as indicators that are relatively easy to measure are automatically measured every minute by the sensors. These sensors are connected to Aquasensor which is a tailor-made program written in the programming language Python. Aquasensor communicates with the sensors and collects raw data which is converted into measured values and then, via a buffer program, Grafsy, sends this data to the storage part of the system. The following are the most important indicators we measure:

IndicatorSensorComment / unit of measure
Electricity usageElectricity meter with pulse output1 pulse/Wh (1000 pulses/kWh)
LightTSL2561Lux
Air: temperatureSensirion SCD30°C
Air: humiditySensirion SCD30%
Air: CO2Sensirion SCD30ppm
Sensor hub, CPU-usageThe Linux operating system
Sensor hub, mains electricity230-volts relayon/off
Sensor hub, network packetsThe Linux operating system
Sensor hub, SMS signal strength3G-modem, Huawei E303% or dBm
Water: electric conductivitySensorex CS150TCmS/cm
Water flowXKC-Y25 inductive detectoron/off
Water intakeWater meter with pulse output53 pulses/liter
Water: dissolved oxygenVernier Optical DOmg/l
Water: level measurementUltra sound sensor, JSN-SR04T and a float switchcm
Water: pHSensorex pH2000
Water: temperatureDallas DS18B20°C
Drum filter cleaning230-volts relayon/off
Weather: humidityUSB-connected electronic weather station%
Weather: temperatureUSB-connected electronic weather station°C
Weather: air pressureUSB-connected electronic weather stationhPa
Indicators and equipment for automated sensors

The storage and display system, Aquadata, is based on the two open source software systems Graphite och Grafana.

System architecture of Aquasensor and Aquadata.

Graphite was originally a tool for monitoring computers. It has a database that is tailored for storing time series and is therefore well suited for other time-oriented data, such as sensor data from our aquaponics.

Grafana is a tool for visualizing data, with enormous flexibility in terms of the ability to combine information into larger dashboards. Several graphs can thus coexist on one screen and each graph can contain several different types of data, combined in a logical way.

Screenshot 2021-01-10 at 15.36.20

Grafana dashboard with data from Johanna’s pilot site

System implementation – Aquasensor

Aquasensor runs on RaspberryPi computers, we call them the ”Pies” or sensor hubs. We currently have two of them that collect data from different parts of the cultivation. Every full minute, data is collected from the sensors. Aquasensor uses a supporting software, Grafsy, to temporarily store the collected information. In turn, Grafsy sends data to the Aquadata storage system. Grafsy ensures that all information is delivered and data from several hours of measurements can be stored if communication with Aquadata is temporarily interrupted. A sensor hub can also have a ”sub-hub” which is an Arduino computer with sensors. Some sensors are easier to communicate with from an Arduino. Since power outages can occur, the Pies have backup power in the form of battery packs. They are of the same type that you can use to charge your mobile phone. In this way, Aquasensor can continue to monitor the cultivation even if the power goes out. If reserve power is available to the router, Aquasensor can continue to send data even during power outages, if the router does not work, the information is buffered in Grafsy until communication is re-established.

IMG_2481

Aquasensor connected to an electronic weather station (which uses wireless communication to get data from sensors on the roof).

System implementation – Aquadata

Aquadata is a system built around the open source software Graphite and Grafana. Graphite stores all information from the sensors and Grafana presents data in graphs that can be collected in dashboards. With these two systems as a base, we have built a cloud service that enables storage of sensor data over the Internet and access to the information in the same way.

Data and time series

Data collected by Aquasensor is sent to Aquadata. There it is stored in Graphite, a database that is tailored for storage of so-called time series, i.e. data containing a timestamp. When Aquasensor sends data from a sensor, it is in the form: ”name timestamp data”.

The configuration of the storage is automatic, when a measured value enters Aquadata, it is automatically added to the named series. If the name does not exist, it is created in the database and the information is added there as a first entry.

Example

Aquasensor sends the following data:

johannas.husby1.sensor.luft.co2.stickling 2020-12-14T02:16:00+02:00 348

The name of the measured value, johannas.husby1.sensor.luft.co2.stickling, contains a lot of information that specifies the kind of data we’re sending. The name is is made up of sub-names in a hierarchical structure. The first two parts of the name, johannas.husby1 is the facility we send data from. Then follows what type of data it is, sensor.luft.co2, i.e. carbon dioxide, and finally the name, stickling, of the sensor from which the measured value comes, in this case the sensor in the seedling room. Using this type of hierarchical names you can build logical structures for your data which in turn makes it easy to find the right information when it is to be presented in graphs.

The next part of the data is the timestamp, 2020-12-14T02:16:00+02:00. Most measurements are made every full minute, with the exception of EC (electric conductivity; measured by running a weak current through the water) which is made on the half minute so as not to interfere with the pH that is easily affected by it.

The last part of the measurement is the measured value, i.e. the data itself, 348. The unit is specified when creating the visualizations and is not part of the value, but is in most cases obvious. In the case of carbon dioxide content, it is ppm, parts per million.

Graphs and dashboards

The collected data is presented by Grafana, an open-source software for visualizing data. With Grafana, we have built dashboards, information panels where we collect information that ”fits together”. We currently have three main panels, Water, Cultivation Rooms and Tech infra, technical infrastructure. The water panel shows the values for temperature, oxygen content, pH and electrical conductivity. The Tech infra dashboard shows more ”physical” measurement values such as electricity consumption (and that we have electricity at all!), the system’s water level (to be able to alert if we get a major leak) and monitoring of the drum filter whose activity is indirectly an indication that the system is OK. The Cultivation Room panel shows the measurements we take in the seedling room, such as temperature, humidity and carbon dioxide content.

Grafana dashboards @ Johannas

Grafana dashboards on TV screens at the pilot site

Alterts

Aquasensor and Aquadata have two integrated alerting systems. On is SMS-based and sends an SMS to a list of telephone numbers in the event of an alarm condition. The second system is an integration with the cloud service PagerDuty, which can be configured to send alarms via: email, SMS and phone calls.

Digital security

Our monitoring system is explicitly not to be used to control the aquaponics. We are of the firm opinion that in the future it may be very difficult to protect ourselves from external actors who want to disrupt and/or destroy our computer systems, or to exercise digital blackmail by, for example, breaking into our system, encrypting the computer disks and request money to unlock data again. In systems that operate critical infrastructure, such as our fish farming, this should not be possible and our control systems are air-gapped, i.e. have no digital access from the internet or other external networks. This means that the data flow in our monitoring systems only goes in one direction: from the sensors to the local data server and on to the cloud service.

In the next post we will take a look at the Production managment system.

The text in this posted is licensed under Creative Commons BY-NC-SA International.