Mushroom Fruiting Chamber Controller
by BrianS184 in Circuits > Arduino
17137 Views, 213 Favorites, 0 Comments
Mushroom Fruiting Chamber Controller
Growing your own gourmet mushrooms at home can be a satisfying hobby, you can purchase 'ready to fruit' kits, or make your own, and depending on where you live you can have enough natural humidity to grow/fruit mushrooms in your kitchen. Where I live is not humid enough to do this, so I needed to make a Fruiting Chamber (FC) where I could supply my mycelium blocks the right conditions to make lovely edible mushrooms.
My experience with Arduino allowed me to realise how effective an arduino controlled, automated 'tub' Fruiting Chamber could be - especially when I searched AliExpress and found the tiny little 5V donut foggers. To fruit mushrooms, you need high Relative Humidity (RH), and Fresh Air Exchange (FAE), so a box, a fogger, and a fan, with a little arduino controller on the side, plus a year or two of tweaking led me to this current version I'd like to share with you all in my very first Instructable.
I have been running this chamber for a couple of years, upgrading slightly along the way, but with a very messy prototype controller that was not at all photogenic - so I made a new tidier one for this instructable.
Supplies
You will need the following Parts:
- 60-100L (16-26 gallon?) Tote/Tub plastic storage container with lid for the main Fruiting Chamber
- Lunchbox (2L / 67oz) type lunchbox for the controller box
- 5V donut fogger - get spares when you order these! they have a lifespan, so have spares ready.
- 5V fan
- Arduino nano
- Arduino nano Terminal Block (optional, but quite nice)
- DS18B20 temperature sensor, and 4.7kΩ resistor
- Potentiometer, size isn't really important
- 2-channel or 4-channel relay block (only 2x channels used, but leaves room for expansion getting the 4ch unit)
- USB plugs and sockets to cut up - I sacrificed a couple rather useless 4-port hubs for their parts
- Terminal blocks, wires, and header wires
- Plywood (I used 4mm) to mount the components
- A few small woodscrews to mount the components to the plywood
- 16mm glands (x2) for the wires coming in and going out of the controller box
- A couple small (M6) bolts/nuts to secure the lunchbox to the main tub
- A basic Temperature/Humidity display is handy to check periodically, but optional
I got most of the electronic bits from AliExpress, you may have better options in your country.
The Tools you will need are:
- A drill, drill bits. Those stepper bits are great for cutting the right sized holes into the lunchbox
- Hole Saw
- Glue Gun
- Wire Strippers (I use a craft knife and side cutters)
- Craft knife, and side cutters
- Small flat blade screwdriver
- Soldering Iron, and solder (possibly optional, I needed this to put new wires on the USB plugs and sockets)
The program to load into the Arduino can be found here:
Prepare Controller Box
Mounting the components onto plywood makes it a whole lot easier to work out of the lunchbox, so I recommend you do this - you can always ignore my advice and chuck everything loose into the box like I did with my prototype though!
I cut the plywood to the rough rectangular size I needed for my lunchbox, then cut the corners off, and rounded off with a rough file (rasp). This really doesn't need to be pretty, it just has to fit into the bottom of the lunchbox.
I then drilled the holes for the cable glands into the lunchbox side. I opted for input wires on the right, and outputs (USB sockets) on the left. These plastic boxes love to crack when being drilled. I used a stepper drillbit with a piece of scrap wood behind the plastic to support it when drilling. Sometimes it was safe to hold the wood with my hands, sometimes I needed to clamp the wood to do it. Take your time to figure out the best way for you to do this.
Mounting the components on the plywood took has to take into consideration where the wires need to go, and you might notice that I moved my arduino UP a bit from these early photos in the final one because I realised that I couldn't plug the USB serial monitor cable into the arduino when it was low. If you copy what I've done you shouldn't have to make the same mistakes I did...
I chose to use USB connectors for everything because the foggers come with a standard USB cable, and it's easy to keep everything the same. You can hard wire everything if you want, or you can use connectors that you like to use. I put new wires onto the upcycled USB hub plugs and sockets by taking the sockets apart and soldering on the new wires. The USB wire colours should be standard, so red should be +5V, and the black 0V/negative.
Wire It Up
I made this version to show the wiring in the most obvious way I could think of. It is certainly not optimal, I could have saved quite a few wires, but I did it for people new to electronics to hopefully easily understand how it all works.
This whole unit is all 5V, if you know what you are doing, you can use the relay outputs to power anything upto 250V/10A, but you really want/need electrician qualifications to do that legally, and this works with a small Fruiting Chamber with all 5V gear.
The whole box is powered by the male USB plug. I plug this into an old phone charger transformer, something bigger than 5V/0.6A output should be all you need, I'm using a 1500mA (1.5A) output one because that is what I had.
The +5V and 0V cables come into the controller box on the right and into a little terminal/connector block. The + and - voltages are split to either end of the box to the + and - terminal 'bus'. This was a tidying feature to illustrate which components need to be wired to what, you can certainly poke many wires into one terminal to save on this part! The wires I used are solid core 'bell wires' that I have hundreds of metres of, so use for everything. The white wire is negative, the wire with the red stripe is positive (+5V)
Looking at the +5V bus, there are +5V wires going to:
- The Arduino Vin terminal
- The Temperature Sensor Vcc terminal
- The Potentiometer
- Relay1 middle terminal
- Relay2 middle terminal
- The +5V on the 3rd USB socket
The 0V bus has 0V (white) wires going to:
- The Arduino GND terminal
- The Temperature Sensor GND terminal
- The Potentiometer
- 3x 0V of the USB sockets
The Relay block gets power from the Arduino - Jumper wires that fit onto the pins of the relay block go into the Arduino terminals in the following way:
- Red wire (+5V) VCC on relay block to 5V on Arduino
- Black wire (0V) GND on relay block to GND on Arduino
- Green wire (signal) IS1 (relay1) on relay block to D3 on Arduino
- Blue wire (signal) IS2 (relay2) on relay block to D2 on Arduino
The temperature sensor has a signal wire (yellow) that goes into the D4 terminal on the Arduino. There is a 4.7kΩ resistor between + and signal terminals on the temperature sensor side of the connector block.
The pot has the variable voltage signal (black wire on my one unfortunately) going to pin A0 on the Arduino.
The +5V wires for the Fan and Foggers connect to the NO (top) output terminals of the relays - FAN +5V on relay1, RH/Fogger +5V on relay2.
Setup and Test Arduino
Download the .ino file from the supplies section of the Instructable, or this step, or copy and paste the below code into your Arduino IDE program. There is a bit of learning to do if you haven't programmed an Arduino before, I strongly suggest doing some tutorials and watching some basic youtube videos on this if you haven't done it before.
All going well, you have to install the Arduino IDE software on your PC, install a few libraries (this part can be painful, advice for edits/detail here welcome!), successfully compile the code on your PC, then upload the code to your Arduino once you've figured those settings out with the example sketches, eg found the correct COM port, Processor, Programmer. I do think some practise with the example sketches, eg blink is well worth doing to get used to this stuff if you haven't done it before.
When the code is uploaded onto the Arduino, I recommend you use the Serial Monitor to check everything out, including warming/cooling the temperature sensor to see how the Tpv, and Tx signals vary, and adjusting the potentiometer to see how the potValue changes, and how both of these combine to change the RH ON time. You can do this with a laptop or PC, and even your phone if you get the right adapter cables and run a 'Serial Monitor' app. At the time of writing I use one called 'Serial Monitor v4.8.4, developed by CSA.
The extra 5V 'always ON' USB socket we added can be used to check that the fan and fogger run when given power - this is handy to manually check. The foggers have a little sponge at the bottom which takes a little bit of time to wet, so let it float in a tub of water for a few minutes before testing, but it should look like the video below when running.
The relay board has handy LED indicator lights that I labelled with pencil to show when one or the other, or none are on. It's pretty straight forward, the fan LED should be ON when the fan is running, NO LED should be ON when neither the fan nor fogger are ON, and the fogger LED should be ON when the fogger is ON.
Here is the code if you want to copy and paste it instead of downloading the .ino file:
/*
Fresh air and RH relay cycling for mushroom fruiting chamber 20/1/2020
A basic program to run two different relays with a delay in between, the fan relay with a set run time, the RH relay ON time dependent on potentiometer postion and temperature.
Programmer: Arduino as ISP, Board: Arduino Uno (Actually a Nano, depends on firmware on nano board as to what it needs to be programmed as)
Uses a potentiometer to change percent RH time bias along with Temperature change using DS18B20
DS18B20 Temperature sensor with digital signal input into pin4
Potentiometer analogue signal into pin A0
Fan relay as Output on pin D2
RH relay as Output on pin D3
*/
#include <OneWire.h> //library dependencies are a pain, you have to install these before trying to compiling and uploading the code
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 4 //sensor data pin 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
int Tsignal = 4; //This is the DS180BS20 Temperature signal input pin on the Arduino
float Tx; //This is the temperature bias factor for percent humidify 0.05-1.0
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 2&3 as outputs, Tsignal (pin4) as input
pinMode(Tsignal, INPUT); //Sets the T pin as an input
pinMode(2, OUTPUT); //D2 fan
pinMode(3, OUTPUT); //D3 RH
Serial.begin(9600); //Start Serial
sensors.begin(); //DS28B20 sensor initiate
}
// the loop function runs over and over again forever
void loop() {
sensors.requestTemperatures();
float Tpv = sensors.getTempCByIndex(1); // measure T
Serial.println("freshair & delay & RH ver1.5");
Serial.print("Tpv = ");
Serial.print(Tpv,1); //Print the temperature value to Serial
int potValue = analogRead(A0); //get the pot position to determine humidity percent run time
Serial.print(" pot = ");
Serial.print(potValue); //Print the potValue% value to Serial
if (Tpv < 16) // Tx is temperature bias, so if Tpv is less than 16, Tx =0.05 5%
{Tx = 0.05;}
else if (Tpv>21) // if Tpv is greater than 21, Tx=100%
{Tx = 1.0;}
else
{Tx = 1-(21-Tpv)*0.2;} // Tpv between 16 and 21deg gives a Tx changing by 20% each degree C
Serial.print(" Tx = ");
Serial.println(Tx); //Print the Tx value to Serial
// CHANGE "cycle_time", and "percent_fan" below to alter the pulse period and ON width //
float cycle_time = 300; //cycle time in seconds (300s)
float percent_fan = 20; //percentage on for fan (20)
float percent_humidify = Tx*potValue*(75/1023.0); //maximum of 75% run time, fan is 20%, want minimum of 5% nothing
float percent_none = 100 - percent_fan - percent_humidify; //percentage nothing (calculated)
//working
float cycle_ms = cycle_time*1000; // convert s to ms
float fanON_time = cycle_ms*percent_fan*0.01;
float none_time = cycle_ms*percent_none*0.01;
float RH_time = cycle_ms*percent_humidify*0.01;
Serial.print("cycle time(s) :"); //debug serial printing
Serial.print(cycle_time);
Serial.print(" RH run % :");
Serial.print(percent_humidify);
Serial.print(" fan run % :");
Serial.print(percent_fan);
Serial.print(" idle % :");
Serial.println(percent_none);
Serial.print("fanON ");
Serial.println(fanON_time/1000);
digitalWrite(2, LOW); // FAN ON. For 4-ch relay LOW is ON, HIGH is OFF on NO connection to make LED indicate correctly
digitalWrite(3, HIGH); //
delay(fanON_time); // wait fanON Time with FAN ON
//
Serial.print("nothing ");
Serial.println(none_time/4000 );
digitalWrite(2, HIGH); // // FAN OFF
digitalWrite(3, HIGH); // // RH OFF
delay(none_time/4); // wait none (delay) time/4
Serial.print("RH ON ");
Serial.println(RH_time/4000);
digitalWrite(2, HIGH); //
digitalWrite(3, LOW); // RH ON
delay(RH_time/4); // wait RH time/4
//
Serial.print("nothing ");
Serial.println(none_time/4000);
digitalWrite(2, HIGH); //
digitalWrite(3, HIGH); //
delay(none_time/4); // wait none time/4
Serial.print("RH ON ");
Serial.println(RH_time/4000);
digitalWrite(2, HIGH); //
digitalWrite(3, LOW); //
delay(RH_time/4); // wait RH time/4
//
Serial.print("nothing ");
Serial.println(none_time/4000);
digitalWrite(2, HIGH); //
digitalWrite(3, HIGH); //
delay(none_time/4); // wait time/4
Serial.print("RH ON ");
Serial.println(RH_time/4000);
digitalWrite(2, HIGH); //
digitalWrite(3, LOW); //
delay(RH_time/4); // wait OFF time/4
//
Serial.print("nothing ");
Serial.println(none_time/4000);
digitalWrite(2, HIGH); //
digitalWrite(3, HIGH); //
delay(none_time/4); // wait time/4
Serial.print("RH ON ");
Serial.println(RH_time/4000);
digitalWrite(2, HIGH); //
digitalWrite(3, LOW); //
delay(RH_time/4); // wait OFF time/4
}
Setup Main Fruiting Chamber Tub
The main Fruiting Chamber (FC) tub design I've used is quite simple.
The Fan is at the top one end, blowing fresh air IN. The exhaust port is at the other end at the bottom - this was a modification I made after advice I read about the CO2 you are wanting to get rid of being heavier than air, so an exhaust at the bottom naturally lets that heavier CO2 out even when the fan isn't running.
When mushrooms are fruiting they do release spores, more so if you let the fruit mature beyond the optimal eating stage. Not passing the spores through the fan is a good idea for extending the life of the fan, but consideration of where you exhaust the FC to is also important. You could put a flexible hose on the outlet and direct the exhaust air/spores outside or into a filter of some sort. I have my exhaust port near an open window so the spores (if any) go outside.
I drilled my two port holes in the tub with holesaws and wood supporting the plastic as the cutter went around. Again, this plastic loves to crack, I haven't had trouble when supporting the back of the plastic with wood at the back and running the holesaw bits in the normal direction (some people swear by running them backwards and melting the plastic instead of cutting it you have less risk of cracking, but I think correct support is more important).
I bolted the controller to the FC with a couple of M6 bolts/machine screws with just the rounded head inside the FC for easier cleaning - the thread goes through the controller and is secured with nuts in the controller box.
I have had trouble with fungus gnats, so have hot-glued in some fine mesh screen at the fan and exhaust ports to try and reduce their ability to get in. sealing where the fogger and temperature cable go into the tub is also a point to seal up. I made a very small slot in the tub to run the wires through, but this could be improved upon.
Fruit Some Mushrooms!
This tub is quite automated, all you need to do is put in your mature blocks/jars/buckets, keep the fogger water reservoir topped up (I use an old plastic water bottle to squirt more water in), and watch in amazement as the fungi convert straw, sawdust, chaff, or other materials into delicious edible mushrooms for you to enjoy!