Software apps and online services
Hand tools and fabrication machines
Mushroom growing is becoming an increasing trend as people become aware that growing their own food is very important. Mushrooms, on the other hand, need specific conditions for successful growth. As part of this project, we've created an automated chamber for fruitingmushroomsnamed ShroomBox. It enables remote monitoring and control over the fruiting process for people with a tight schedule.
This simplifies the cultivation process and achieves a better yield in less time. We've made our own PCB, 3D printed certain parts, wrote a program for an ESP32 microcontroller, and created a mobile application for remote control using Blynk IoT Platform. The chamber allows the automatic regulation of light, temperature, humidity, and carbon dioxide levels.
You can find all 3D parts, PCB schematics, and firmware in the attachments.
Here are listed all sensors used in ShroomBox:
- Temperature and humidity in mushroom chamber: SHT30 (I2C bus)
- Temperature of the room (outside chamber): DS18B20 (OneWire bus)
- Temperature of heating pads: DS18B20 (OneWire bus)
- Substrate moisture: SEN0193 (analog)
- CO2 level: SCD30 (I2C bus)
Here are listed all actuators used in ShroomBox (all operate at 12 VDC):
- Heating pads x2
- Ultrasonic humidifier
- LED strip
Heating pads raise the temperature in the chamber, an ultrasonic humidifier maintains adequate relative humidity in the air. The fan takes care of the regulation of oxygen or carbon dioxide. LED lighting provides light in intervals.
We can regulate the power of each actuator using PWM.Mechanical part
The base of the chamber is a plastic storage box. There is a cutout for the installation of a fan and two holes for airflow. The airflow covers and the fan enclosure are designed so that we can install micro-filters. All the enclosures are 3D printed. The chamber must be as sterile as possible to prevent mycelial infections. That’s why there are all cables led inwards through the glands.
On the cover of the chamber LED lighting is installed. The cable length is selected so that the lid can be easily opened and placed next to the chamber. At the bottom of the box is an aluminum table slightly raised off the ground. Two heating pads and a temperature sensor are installed on the underside of the table. You can place a container or bag with mushrooms on top of this mini table. All cables are long enough to allow the table to be placed outside the box when we clean the chamber.
There is a water tank on the outside of the box with a lid leading the evaporated water into the interior of the chamber. An ultrasonic humidifier is floating in the tank. At first, moisture flowed into the chamber through a 10 mm diameter pipe, however, the flow was too low and there were problems with condensation dripping on the humidifier. The current version is still not the best due to poor sealing between the tank and the chamber.
The control box enclosure is also 3D printed. On the right side, there is a EURO connector for the power supply (230 VAC) and main ON/OFF switch. Mini OLED display on the front panel shows current temperature, humidity, and CO2 levels, together with wifi signal strength. Two buttons next to the display are not used yet but can be used to switch between screens or control the box. On the right side, we placed a button to reset the wifi credentials when we want to connect ShroomBox to another wifi network.
A 12 VDC 20A power supply powers the PCB. 20A is overkill, but why not?
The heart of the circuit is ESP32 microcontroller development board. There is DC/DC step-down converter module to reduce the voltage from 12 VDC to 5 VDC.
Due to better efficiency than linear regulators, it also eliminates the use of the heat sink. Sensors are powered via 3.3 V from ESP32 development board. For the protection of the circuit against the current overload, there are two SMD fuses on the 3.3 and 12 V power supply part. The buttons are connected via an RC filter.
Sensor SEN0193 and the photo-resistor have an analog output, so they are connected to ADC pin of ESP32 via RC filter. The DS18B20 temperature sensors are digital and factory-calibrated. The SHT30 sensor is also factory-calibrated.
To control 12 VDC actuators with PWM, MOSFET transistors with low internal resistance are used. This helps to reduce losses and overheating. Transistors are controlled with a logic level directly via ESP32. Of course, current limiting resistors are used. Two transistors that control the heating pads have left enough space for the heat sink. During testing, we then discovered that it was not coming to overheating and heat sinks are not necessary.
On the supply wires for the heating pads, there are tubular glass fuses. The wiring of the chamber was done in such a way that it is for the user as unobtrusive and aesthetic as possible. Sensors in the chamber are set up to show values as realistically as possible. The CO2 sensor is located in the lower half of the chamber, as this CO2 is heavier and stays at the bottom of the chamber. The temperature and humidity sensor in the chamber is mounted on the wall, which is furthest from the moisture outlet and withdrawn from heat sources (heaters, power supply, circuit, etc). Some problems represent an ambient temperature sensor, as despite the installation outside of the chamber it still senses the effect of chamber temperature. It would make sense to use some kind of thermal insulation here.Firmware
We used PlatformIO software to program the microcontroller. It is available as an extension for the Visual Studio Code environment. it uses a customized version of the C ++ programming language.
Because the chamber connects to the web or mobile application we chose the Blynk Edgent template as the basis of the program. The program initializes all sensors at startup and stops any active outputs to prevent unforeseen operations. Then check if the data is already written in the flash memory to connect to a local WiFi network. If the data is entered, it establishes a connection, otherwise, it goes into access point mode after a certain amount of time. In this mode, the user via the Blynk app or local web address connects to the microcontroller and enters the SSID and password of the WiFi network. The user can also reset WiFi credentials at any time with a long press of the button on the case. When it is connected to the network, the program enters the main loop, where it constantly checks which mode it works, which settings it must take into account, and sends data to the application at specific intervals.
The program waits for commands from the Blynk application via function with callback calls. These are performed every time the user changes a specific setting in the application.
The program has three modes of operation. In OFF mode, the operation is stopped, outputs are off, but measurement data are still being sent to the app. PWM values (in percentage) for each actuator can be set in MAN (manual) mode. This method is suitable to test performance and find appropriate parameters.
In AUTO (automatic) mode, the program runs automatically the regulation of temperature, light, carbon dioxide, and relative humidity according to the set parameters. Because mushroom growth is usually divided into two stages, the user can define values for each of them. When the user assesses that one phase is over, you can switch to the second phase. The user can also set the time interval for lights to be ON.
An example of simple hysteresis control for CO2 level.
int reg_co2(float measured_co2, float desired_co2, float hyst)
int flag = 0;
if (measured_co2 <= (desired_co2 - hyst / 2.0)) // Lower limit
fan_auto_pwm = 0;
fan_status = 0;
flag = 0;
else if (measured_co2 >= (desired_co2 + hyst / 2.0)) // Upper limit
fan_auto_pwm = fan_auto_set_pwm;
fan_status = 1;
flag = 1;
flag = 1; // When inside hysteresis, set flag to 1 so humidifier does n't turn on when fan is on
ledcWrite(FAN, fan_auto_pwm); // 60% duty cycle
For temperature regulation CO2 and moisture we use hysteresis where we set the target set point value and hysteresis width (half hysteresis) in each direction from the target value). In the future PID control would also be appropriate. During testing, we found that concurrent operation of fan and humidifier is not the most appropriate because the pressure in the chamber prevents the inflow of moisture, so we are regulating CO2 set a higher priority. When there is a suitable level of CO2 in the chamber, moisture production is included.
We decided to use the Blynk IoT platform because we needed to develop a PoC in a very short time. We also wanted a great UI and cross-platform application. Blynk is really easy to use and provides great documentation for all the components.
We used the free version of Blynk, so we needed to improvise a bit to get satisfying results. We created two tabs: HOME and AUTO settings.
In the HOME tab, the user can switch the device on / off, choose from automatic or manual mode, and select the growth phase (more on that later).
Users can take a look at current device status, and state of each actuator, analyze sensor values and manage the device in manual mode. We also added some charts to visualize data.
In the AUTO SETTINGS tab, the user can set some parameters for each growth phase. This way, the user doesn't need to adjust or memorize parameters, but just flip the switch and enter a new phase. We also added terminal for advanced users, where we can set up PWM values of actuators when working in automatic mode.
Here is an example of how to use the terminal.
int space1, space2;
String buf = param.asStr();
space1 = buf.indexOf(' ');
space2 = buf.indexOf(' ', space1 + 1);
param1 = buf.substring(space1, space2).toFloat();
// Set co2 hysteresis
terminal.print("CO2 hysteresis was set to +-");
hyst_co2 = param1;
terminal.print("CO2 hysteresis is set to +-");
We have provided certain inputs/outputs on the controller in advance. Such an example is an analog input for connecting a light sensor. Currently, the chamber works well in colder rooms as it allows heating, but no cooling, which is one of the additional options for improvements in the future.
We also need to improve humidification, because the ultrasonic humidifier is not reliable.