Skip to content

16. System Integration

Date Task Status comments
16/05 Humidity control Done Using a fan over an absorbent card, i was able to achieve +90% humidity
16/05 Water sensor Done Tested a soil moisture sensor with an output LED to indicate when the device needs water
16/05 Design Ongoing Main bulk of design done, just some additional work on placing components - HCS, Water storage, pcb.
16/05 Printing Done Made a start with the belt printer, waiting on pla, 7 parts left to print with approx 4h each
17/05 Laser cutting Done Make a start with cutting the side panels
17/05 Print Done Continue with printing
18/05 Design Done Design a system that integrates water level sensor and humidity system
19/05 Programming Done Research projects that show input values and have I/O button controls
20/05 Electronics Ongoing Put together the electronics system to include all parts used in final project
21/05 Testing Ongoing Test the electronics, fault find, run embedded program

What will it do?

My final project will create the perfect environment for mushroom growth; regulating heat, moisture, ventilation and light.

Who has done what beforehand?

Open Ecotron , from Fab Lab Barcelona 2017, by Esteban Martín Gimenez

A device capable of generating a range of physical and chemical conditions applied to terrestrial or aquatic ecosystems. Its principle is to confine a biological system (natural or artificial, complex or simplified one) in a enclosure sealed in matter but not in energy, and simultaneously measure and control flows of matter and energy. For this purpose, the enclosures are equiped with many sensors to obtain precise real-time measurements and different actuators to control and modify the enclosure environmental conditions.

H.E.R.M.E.T, from Fab lab Ecostudio 2018, by Mathew Hotsko

A climate controlled chamber for something to be incubated. It has DHT11 Temperature and Humidity and Relay contolled switches for Light and Heat.

Cogus Home , from Fab Lab Aldeias do Xisto 2018, by João Milheiro

A microwatering system for Cogus Kits, a system that gives autonomy to the mushroom growth, considering environment variables (humidity, sunlight, C02, etc.).

What will you design?

I have designed the case, humidifying system and the electronics.

What materials and components will be used?

B.O.M

Part Fab inventor y/n Other Locations Quantity Cost
5V heat pad No robotshop.com 1 €5.75
5V Fan Yes Aliexpress 1 €0.34
Water sensor Yes Aliexpress 1 €1.05
DHT22 Yes Aliexpress 1 €1
Esp32c3 Yes Digikey.nl 1 €5.65
Neo pixel LED's Yes ledstripkoning.nl 10 €2.20
N-type mosfet Yes rs-online.nl 2 €0.70
Led Yes Digikey.nl 1 €0.30
Resistor Yes Digikey.nl 6 €0.30
Capacitor Yes Digikey.nl 1 €0.60
USBC-Plug Yes Digikey.nl 1 €2.50
PLA Yes ec3d.nl 1kg €19.99
TOTAL €40.38

Part and Process

Process Software Machine
Electronics Design Ki-Cad N/A
CNC Milling PCB Mods, UGS Lunyee 3018, Roland modela
3D Printing Prusa, Cura Prusa MK3S, Ender 3, SainSmart INFI 20
Laser cutter Fusion 360, Lightburn Brm 90130

How will it be evaluated?

To be successful my project must do the following:

  • Regulate temperature, giving heat when temperature drops below 18 degrees
  • Regulate humidity, giving optimal growing conditions of between 75-95% humidity
  • Warn user of low water level
  • Have a controllable light source
  • Circulate air
  • Have a user interface, where inside conditions can be read by the user
  • Grows mushrooms

Humidity control experiments

template shirt

One of the challenges of my project is humidity control. I have used an atomizer in previous weeks, but for a small container like the one I am making, trying to get a balance with PID control is going to be difficult. The atomizer will give off a huge amount of humidity in a very short period, for this reason I am experimenting with using a fan over an absorbent material to blow moisture off the material and into the container with hopefully more control. This will also support 2 functions, humidity and air circulation which are equally important for mushrooms.

Sponge

I first tried with a sponge clipped to the side of the bottom of a bottle filled with water and surprisingly, the sponge just didn't take up the water enough to have any moisture blown from it.

Cardboard

In the photos I have a piece of corrugated cardboard cut at the ends with one side soaked in a beaker of water. I have placed a 5V fan underneath and i have my dht22 sensor taped to the side of the container, these are both being powered by my micro controller, which is running a web server displaying the humidity and temperature.

The results are actually better than expected, the first few attempts I was getting to around 60% humidity before the fan fell and ruining the experiment. With some better tac adhesive a ran the experiment again. Starting at 54% humidity, I was able to achieve 70% humidity in 10 minutes and 80% around 50 minutes (maybe even sooner as I wasn't constantly monitoring). The container used for the experiment is considerable bigger than my final project, so it will take even less time for my design.

I think I will use this method for my final project and design a case to hold the cardboard keeping the electric parts isolated and in a separate area to the water container.

sanded
seatfixing
hinge1
hinge2

Water indicator

This week I tested the MH-Sensor-Series soil moisture sensor. I was able to use my onboard LED as an indicator for when there was little moisture present. This works well and I think will be sufficient for what i need, i just need to design a holder and make a container for the water.

From testing this water indicator out, I soon realized it was not the ideal component for my project, it started to corrode and you actually some particles falling away in the water due to electrolysis. For that reason I have upgraded to a capacitive soil moisture sensor. I tested it out this week and here ae the results.

Code

int led_pin =5;

int sensor_pin =20;

void setup() {

  pinMode(led_pin, OUTPUT);

  pinMode(sensor_pin, INPUT);

}

void loop() {

  if(digitalRead(sensor_pin) == HIGH){

    digitalWrite(led_pin,
HIGH);

  }

 else {

    digitalWrite(led_pin, LOW);

    delay(1000);

  }

}

Output control

I want have the web server as my UI so that the user can interact with the device, for this I am using a htpp protocol. I have used some example code found here, making some changes as I am using a different sensor, I asked chat gpt for a hand in updating the code which you can find below. This is working well, I have connected a fan to test the GPIO and i can control that using the ON/OFF buttons on the web server.

Code

#include <Arduino.h>
#include <WiFi.h>
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include "SPIFFS.h"
#include <Arduino_JSON.h>
#include <DHT.h> // Include the DHT sensor library

// Replace with your network credentials
const char* ssid = "iPhone pepe";
const char* password = "01212021";

// Set LED GPIO
const int ledPin = 2;
// Stores LED state
String ledState;

// Create AsyncWebServer object on port 80
AsyncWebServer server(80);

// Create an Event Source on /events
AsyncEventSource events("/events");

// Json Variable to Hold Sensor Readings
JSONVar readings;

// Timer variables
unsigned long lastTime = 0;
unsigned long timerDelay = 10000;

// Create a DHT object
#define DHT_PIN 10 // Pin connected to the DHT22 sensor
#define DHT_TYPE DHT22
DHT dht(DHT_PIN, DHT_TYPE);

// Init DHT sensor
void initDHT() {
  dht.begin();
}

String getTemperature() {
  float temperature = dht.readTemperature();
  // Read temperature as Fahrenheit (isFahrenheit = true)
  // float temperature = 1.8 * bme.readTemperature() + 32;
  Serial.println(temperature);
  return String(temperature);
}

String getHumidity() {
  float humidity = dht.readHumidity();
  Serial.println(humidity);
  return String(humidity);
}

// Replaces placeholder with LED state value
String processor(const String& var) {
  Serial.println(var);
  if (var == "STATE") {
    if (digitalRead(ledPin)) {
      ledState = "ON";
    } else {
      ledState = "OFF";
    }
    Serial.print(ledState);
    return ledState;
  } else if (var == "TEMPERATURE") {
    return getTemperature();
  } else if (var == "HUMIDITY") {
    return getHumidity();
  }
  return String();
}

void setup() {
  // Serial port for debugging purposes
  Serial.begin(115200);
  pinMode(ledPin, OUTPUT);
  initDHT();

  // Initialize SPIFFS
  if (!SPIFFS.begin()) {
    Serial.println("An Error has occurred while mounting SPIFFS");
    return;
  }

  // Connect to Wi-Fi
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi..");
  }

  // Print ESP32 Local IP Address
  Serial.println(WiFi.localIP());

  // Route for root / web page
  server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
    request->send(SPIFFS, "/index.html", String(), false, processor);
  });

  // Route to load style.css file
  server.on("/style.css", HTTP_GET, [](AsyncWebServerRequest *request) {
    request->send(SPIFFS, "/style.css", "text/css");
  });

  // Route to set GPIO to HIGH
  server.on("/on", HTTP_GET, [](AsyncWebServerRequest *request) {
    digitalWrite(ledPin, HIGH);
    request->send(SPIFFS, "/index.html", String(), false, processor);
  });

  // Route to set GPIO to LOW
  server.on("/off", HTTP_GET, [](AsyncWebServerRequest *request) {
    digitalWrite(ledPin, LOW);
    request->send(SPIFFS, "/index.html", String(), false, processor);
  });

  server.on("/temperature", HTTP_GET, [](AsyncWebServerRequest *request) {
    request->send_P(200, "text/plain", getTemperature().c_str());
  });

  // Start server
  server.begin();
}

void loop() {
  // Your loop code here, if needed
}

Including Soil Sensor

From here I used the code from the soil sensor and added the relevant point to the code above, including the setup and void loop. Now I have the humidity/temperature readings on screen with an ON/OFF button to eventually control an LED strip as a light source. Then with the loop function I will have an LED that illuminates when water level is low.

Code

#include <Arduino.h>
#include <WiFi.h>
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include "SPIFFS.h"
#include <Arduino_JSON.h>
#include <DHT.h> // Include the DHT sensor library

// Replace with your network credentials
const char* ssid = "SSID";
const char* password = "PASSWORD";

// Set LED GPIO
const int ledPin = 2;
// Stores LED state
String ledState;

int led_pin =5;

int sensor_pin =20;


// Create AsyncWebServer object on port 80
AsyncWebServer server(80);

// Create an Event Source on /events
AsyncEventSource events("/events");

// Json Variable to Hold Sensor Readings
JSONVar readings;

// Timer variables
unsigned long lastTime = 0;
unsigned long timerDelay = 10000;

// Create a DHT object
#define DHT_PIN 10 // Pin connected to the DHT22 sensor
#define DHT_TYPE DHT22
DHT dht(DHT_PIN, DHT_TYPE);

// Init DHT sensor
void initDHT() {
  dht.begin();
}

String getTemperature() {
  float temperature = dht.readTemperature();
  // Read temperature as Fahrenheit (isFahrenheit = true)
  // float temperature = 1.8 * bme.readTemperature() + 32;
  Serial.println(temperature);
  return String(temperature);
}

String getHumidity() {
  float humidity = dht.readHumidity();
  Serial.println(humidity);
  return String(humidity);
}

// Replaces placeholder with LED state value
String processor(const String& var) {
  Serial.println(var);
  if (var == "STATE") {
    if (digitalRead(ledPin)) {
      ledState = "ON";
    } else {
      ledState = "OFF";
    }
    Serial.print(ledState);
    return ledState;
  } else if (var == "TEMPERATURE") {
    return getTemperature();
  } else if (var == "HUMIDITY") {
    return getHumidity();
  }
  return String();
}

void setup() {
  // Serial port for debugging purposes
  Serial.begin(115200);
  pinMode(ledPin, OUTPUT);
  initDHT();
  pinMode(led_pin, OUTPUT);
  pinMode(sensor_pin, INPUT);

  // Initialize SPIFFS
  if (!SPIFFS.begin()) {
    Serial.println("An Error has occurred while mounting SPIFFS");
    return;
  }

  // Connect to Wi-Fi
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi..");
  }

  // Print ESP32 Local IP Address
  Serial.println(WiFi.localIP());

  // Route for root / web page
  server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
    request->send(SPIFFS, "/index.html", String(), false, processor);
  });

  // Route to load style.css file
  server.on("/style.css", HTTP_GET, [](AsyncWebServerRequest *request) {
    request->send(SPIFFS, "/style.css", "text/css");
  });

  // Route to set GPIO to HIGH
  server.on("/on", HTTP_GET, [](AsyncWebServerRequest *request) {
    digitalWrite(ledPin, HIGH);
    request->send(SPIFFS, "/index.html", String(), false, processor);
  });

  // Route to set GPIO to LOW
  server.on("/off", HTTP_GET, [](AsyncWebServerRequest *request) {
    digitalWrite(ledPin, LOW);
    request->send(SPIFFS, "/index.html", String(), false, processor);
  });

  server.on("/temperature", HTTP_GET, [](AsyncWebServerRequest *request) {
    request->send_P(200, "text/plain", getTemperature().c_str());
  });

  // Start server
  server.begin();
}

void loop() {
  if(digitalRead(sensor_pin) == HIGH){

    digitalWrite(led_pin,
HIGH);

  }

 else {

    digitalWrite(led_pin, LOW);

    delay(1000);

 }

}

RGB LED's

I want to use an LED strip in my final project, RGB LED lights in mushroom cultivation offer adjustable light spectrums, allowing optimization of blue light for pinning and fruiting stages. They are energy-efficient and customizable for experimentation with different lighting conditions. I am yet to test one out, so this week I got my hands on a strip of 10 WS2812 RGB LEDs. Each LED requires around 60mA of current, so a strip of 10 will require 600mA. For this I have enough capacity with a 3A Rated usb cable. The strip uses a one wire protocol for data in an out, each LED has it's own driver built in so that they can be individually controlled, for that each LED will have a location on the strip, in my strip of 10 for example, i can target one led after the other by defining the amount [10] and sending data to required LED starting from 0 to 9.

Libraries

To program the LED's I downloaded FastLED from the arduino IDE, once i had that installed I tested some examples selecting the WS2812 RGB.

Connections

Connecting is pretty self explanatory:

  • 5v to 5v
  • GND to GND
  • DO to output pin

Testing

I first tested some of the examples in the library, but then to piece it together with my project I wanted the strip to react with the web server GPIO's ON/OFF. This went well, so the next spiral, can I get it to turn red when there is no water present? The answer was yes, but there was a problem, the ON function would over ride the red function, I needed the light to stay red regardless if the output was selected. I ask chat GPT and that problem is no more. Now I have a RGB LED that react with a button on my web server as well as turning red to warn you when the system is out of water.

One issue i have is the flickering, I have a small capacitor of 100uf connected on my pcb, that will need to be increased to deal with the current draw of the LED's.

Note

After some research on what light source to use, I found out that RED light can have a negative affect on mushroom development, inhibiting mycelium growth and disrupting the fruiting. A warning light for more water, in this use case, should not be RED.

Design

I started with creating the box and then worked backwards from there, dividing into smaller pieces, adding and subtracting until there was around 30 pieces that are now all separate components. The main framework is hollow so that cable routing can be internally hidden. Knowing there will be water and electricity I have made sure to separate the two, water in the bottom compartment and the micro-controller in the top. I am happy with the results, just a few more pieces and i can start fixing it together.

template shirt
sanded
seatfixing
hinge1
hinge2
sanded
seatfixing
hinge1
hinge2
sanded
seatfixing
hinge1
hinge2
sanded
seatfixing
hinge1
hinge2

What questions need to be answered?

  • PCB: I need more capacitance and therefore I will need a new board for my final project.

  • Printing: I still have around 5 parts left to print before I can start assembly and testing.

  • Programming: Now I have controllable outputs on a local web server, can I set up a remote protocol?

  • Water delivery: Where and how can a user add water. I have an idea to use a side panel as a pull out trey, but i need to design build and test the idea.

  • Sensor: So far I have been using the DHT22, but here is some concern it won't last, so I have another stainless steel I2C sensor that I want to test.