In a nutshell, the controller takes in two temperature readings, 1 Humidity reading and 1 Co2 reading and triggers a set of four relays connected to mains power.
Intended to be connected to the mains are two heating pads, a sonic humidifier and an air pump (although the choice isn't limited to these of course).
Step 1: Items
-LCD Keypad shield.
- 7-12 volt power supply.
- USB cable (socket that connects to USB on Arduino).
-Box To house the whole thing.
- 4x solid state 5v- 240v relays.
- Mains Power board with four sockets.
- Jiffy box to house inline socket/screws to connect Sensors.
-Thermistors 10k x2
-Resistor 10k x2
-HS1100 humidity reader
- 555 timer (cmos type)
- resistors: 576k, 49.9k, 1k and 909k
- Jiffy Box
- Digital divide by ten Chip
-MG811 C02 sensor (I got a breakout board with op-amp amplifier built in. You can make it yourself, it is a high precision op amp set up as non-inverting with gain around 10).
- Jiffy Box
- 2 x heating pads
- Sonic Humidifier
- Aquarium Tubing
- Air Pump (aquarium)
- Plastic lunchbox (airtight)
- HEPA Filter for Vacuum cleaner.
- Plastic tub
- Aquarium Air pump
- Aquarium Tubing
- Plastic Lunchbox (airtight)
- HEPA Filter for Vacuum cleaner
- Hot Glue gun
- Soldering Iron
- Home brew larger.
Step 2: Thermistors
On a breadboard solder on a 10k ohm resistor, one end will connect to the Arduino ground, the other to Analog input 1 and to one of the thermistor wires.
The other end of the thermistor wire connects to +5v from the Arduino.
Do this for another Thermistor and connect it to Analog input 2 instead.
Basically it is a voltage divider with the thermistor defining the Voltage going to the Arduino analog input. One analog divider for each thermistor.
I added the circuitry in a separate jiffy box where the thermistor leads could be screwed into inline screws protruding from the box.
To test this sensor, use a multimeter to look at the voltage change as you put your finger on the Thermistor.
Step 3: Humidity Reader
The datasheet shows how to hook up the sensor using a 555 timer (must use CMOS type).
I used this circuit to send data pulses to the Arduino. At first I found the pulses were too close together and did not give high enough discrimination, so at the output of the 555 I put a digital divide by ten chip. This made it so the pulses wavelength was in the hundreds of microseconds rather than the tens of microseconds.
Please find attached the datasheet which has the circuit diagram using the 555 timer.
I used the same style inline screws as described with the Thermistor step as a go between for this sensor and the Arduino.
To Test this, hook up the output to a speaker supply power (6volts will do) and breath on the sensor, you should hear a drop in frequency.
Step 4: Co2 Sensor
I later found that the power supply I was running it with was faulty and the heating element in the Co2 sensor was running on overdrive.
Basically the circuit has the sensor hooked up to a non-inverting op-amp with roughly a gain of ten, and the heating element is supplied by a 6 volt voltage regulator. The set up is shown on the datasheet attached with pinouts of the sensor which is self explanatory, what isn't self explanatory is the graph on the datasheet which gives a totally inacurate picture of the expected output of the sensor.
Give it a test by placing a Multimeter on the sensor and breathing on it, it should change reading.
Step 5: Connect the Arduino
The Keypad shield goes just on top of the Arduino.
Solder onto the shield the separate Thermistor voltage dividers inputs to Analog 1 and Analog 2, Analog 3 takes in the Co2 input.
Solder to digital 2 the Humidity input.
Solder on the power supply, I recommend 7 volts supply as the C02 reader needs 6 volts at least. I soldered the power supply onto the go between board and then soldered from there to the Arduino.
I fed the 6 volts to power the humidity sensor and C02 sensor directly(as the C02 board had a voltage regulator), but used the 5volt reference voltage from the Arduino for the temperature sensor voltage divider.
Step 6: Mains Relays and connection to Powerboard
Solder the four Mains relays to some Veraboard.
My relays had marked on them "+" "-" and two load pins. The - pins are connected to Arduino ground, each + is connected to the arduino digital pins 3, 11 ,12 ,13.
The load is what switches the mains active signal, and I used this to switch each individual active within the powerboard.
Opening up the power board I removed the copper strip connecting the actives, and cut them into four separate peices. Soldered onto each peice was one of four wires which were soldered back onto one of the load pins of each of the relays.
The active wire from the mains was then connected to the other load on the relay.
I put hot glue where normally the gromit would go on the powerboard outlet, and I also put hot glue around the mains wires near the relays, just to give it some extra strength.
Step 7: The Code
...please note the original lcd4bit library has a lot of unnecessary delays in it which slows the code down A LOT, these should be removed (look in the cpp library file for clues).
In brief the code (in order of how it appears in the attached code) does:
- #defines M and C values for the linear and log equations required to translate the bit values for the inputs. i.e. y=mx+c and y= Mlog(x)+C
-#defines sizes for averaging array, sampling times, histerisis levels, Pins, EEProm storage size.
-defines variables, trigger values etc.
-Read in sensor values every "SENSOR_INTERVAL" milliseconds.
-Puts the new values in an array and averages this array.
-Performs calculations on the averages to give a 'proper' value i.e. centigrade (apologies to my american cousins but I am metric), ppm (co2), Relative Humidity.
-Prints updates of new temp, humidity and Co2 levels to LCD shield.
-Stores values to eeprom every "EE_PROM_INTERVAL" milliseconds.
-Trigger relays if bellow/above trigger, every "INTERVAL" milliseconds.
-Keypad code that implements a rudimentary menu system allowing triggering values to be changed and EEPROM values to be dumped to serial.
-Funtions to help with averaging and key selection.
I have tried to give an explanation within the code as to what each section does, by all means go in and take a look. If you are more inclined to shy away from reading the code, please note the main things to note are the #define statements for manipulating intervals for reading,triggering and averaging and the #define statements for calibrating M and C values.
These are all situated at the top of the code so take a look and have fun fiddling.
Please note that the code uses the EEprom library for reading writing eeprom values, the lcd4bit library (modified, delays are removed and the pinouts changed) for the lcd shield, and stdlib for converting int into char for writing to the LCD display.
Step 8: House the project
Just a couple of notes here, make sure whatever you do that there is no chance that any of the mains power will ever in any way come into contact with any other wires. For me this involved having the mains veraboard as far away as possible within the project housing and to tie up all the wiring, and a dash of hot glue here and there to hold down the wiring. Basically keep it neat and tidy.
For the front panel I made a stencil of the LCD/Keypad shield of the arduino and drilled/cut to get the front panel to fit, and then with some nuts and bolts bolted on the keypad shield onto the front. You can also see that I drilled holes for the buttons.
Step 9: The Humidifier
To keep the C02 levels low you would add a fan.
...But what to add to keep the humidity up?? A humidifier and here's how I made mine.
First I got a small tub and drilled a number of holes in the top cover, and one bigger hole in the center. Next you thread the sonic humidifier wiring through and seat the humidifier on the bottom.
In one of the holes I attached some aquarium tubing.
On the other end of this tubing was an air pump held within a airtight tub. The lid of the tub had a hole cut out and was covered by a HEPA filter. The reason for the HEPA filter is so that air going into feed the mushrooms isn't contaminated with bacteria and other fungi.
This system of air filtration is also used for the air supply when the co2 gets too low.
After putting water in the tub, turn it on and watch.
Step 10: Humidity Calibration
After some investigation I did find that I could get two readings (two is all you need) to calibrate.
First get a a plastic lunch bag and in it put a mug of salt which you have dampened just enough to make it feel like wet sand. Put the humidity reader in with it and wait for about 12 hours. From what I understand the humidity should be at 75% inside the bag.
Read off the serial out on the Arduino to find what value you are getting
Average this value over a number of readings. Write this value down, this is your X1 val, your Y1 value is 75.
Next go take a shower (take your computer with you), make sure it is a cold morning, after having a shower make sure there is a fine mist and take a number of readings with
Average this value and write it down, this is your X2, your Y2 value is 100.
Alternatively the last step can be done using the humidifier inside a large bag with the humidity reader inside it.
Now remember your algebra! Solve these two equations:
Y1 = m*X1 + C
Y2 = m*X2 + C
...and hope that m is as big as possible!
Using the M and C values fill out the portion of the code:
#define HUMIDITY_C 680
#define HUMIDITY_M 1.6
Step 11: Temperature Calibration
to output values.
Average those values to get your X value, your Y value comes from the temperature reading off the digital multimeter.
Your first set of readings comes from under your arm, your second set from normal room temperature.
Once again solve th equations to get M and C
Y1 = M*X1 +C
Y2 = M*X2 +C
Update M and C values in the code:
#define TEMPERATURE_M 13.31
#define TEMPERATURE_C 188.1
Step 12: C02 Calibration
The way I went about this was to look at the current value of C02 ppm in the world today (yes it is going up!), it's around 400ppm. Assuming that it is a bit higher if you live in the city (my one is relatively clean) I assumed normal outside Co2 levels to be 500 ppm.
So I opened my window and after allowing the Co2 sensor to heat up I took a number of
I averaged these out, and set my X1 value to equal this, my Y1 = 500.
The datasheet showed that the sensor maxed out at 10000ppm, so for my second reading I got some bicarb and vinegar put that in a plastic bag with the sensor and sealed it up and set the reaction off.
After a minute or so It reached its lowest reading using
so I used this value as my X2, my Y2 I set to 10000.
Now I solved to find M and C: (or use excell :) )
y1 = MLogn(x1) + C
y2 = MLogn(x2) + C
And plugged these values back into the program:
#define Carbon_M -83.45
#define Carbon_C 768.62
By the way for this step I am not convinced about my assumptions made about X2 and Y2 values (or Y1 values for that matter :) ), if anyone has some suggestions I am open to them.
Step 13: Test it out
Hook up the gear and see how it performs, have fun fiddling with the histerisis, the averaging array size, the trigger temps, placing of the sensors and heaters humidifier etc.
A quick starter:
In normal display mode (where the temps hum co2 are shown) the only button that does anything is the right button which pushes the last days readings to serial tx.
To the far right of the display appear asterixes if the relays are triggered.
Press button 1 to go into configure mode, here you can adjust the triggering for temperature, relative humidity levels and C02 relays. Right scrolls through the different values, up/down lowers and raises the values.
Left button does nothing, my shield had a problem with the left button so I didn't program it in :).