Composting is one of the main applications for a temperature and humidity sensor, which allows you to monitor the variables in a compost pile. There are also a number of other factors that can be monitored. The most important are gas ratio, temperature, moisture, and pH. The two gases that need to be monitored are carbon and nitrogen, with a desired ratio of 30:1 Carbon: Nitrogen. This ratio could be measured with a gas sensor. Temperature and humidity are measured with the HTU21D sensor. The ideal moisture level is between 40-60% humidity. If moisture is too low there will be no growth, but if it is too high there will be anaerobic bacteria and it will smell. The optimal temperature is between 40-50°C, which is easily measured with a sensor or standard thermometer. PH is a measure of the soil's acidity and it is important to keep it close to neutral (7) by maintaining a pH between 6 and 8. PH can be measured with a sensor but it involves taking a sample on a pH strip then reading it with a spectrometer to determine the color. An electronic pH sensor can be used, but it has a high cost (and an approximate reading can be easily achieved with test strips for cheaper). These range values should be used as a basic guide and starting point in composting. Achieving the optimal balance ultimately depends on the environment and type of biomaterial in the pile, so some experimentation will be needed with each compost mix.
Key Factors in Compost
- Carbon to Nitrogen Ratio: 30:1 C/N
- Time: 6-24 months
- Moisture: 40-60% (at low now growth, at high anaerobic, smells)
- Temperature: 40-50 C
- pH: 6-8
- Odor: odors can indicate a variety of different types of bacteria growing.
Building the Sensor
Arduinos are cheap and easy-to-use microcontrollers. They have a small amount of processing power, and can be used to send different signals across different pins, which can be in turn connected to a wide selection of sensors, switches, LEDs, etc. There are several different types of pins that can be utilized on the board. The most important are the power and ground pins. The power pins allow the user to give a steady supply of power at either 5V or 3.3V., to any part of the circuit. The ground pins allow any part of the circuit to be grounded, thus completing the circuit. The next set of pins is Analog, and these can be used to input or output an analog signal. These are useful when working with sensors that give a binary or hexadecimal readout. The last set of pins is Digital. They are the opposite of Analog pins, and allow a digital signal to be either inputted or outputted.
There are also several pins within the Digital pin section that have the ability to output a PWM signal. PWM stands for pulse width modulation, and alternates the power on-off cycle of the pin at an extremely fast rate. The amount of time the power is on is changed relative to the amount of time the power is off. This can be used for several different things, mainly fading LEDs and giving the proper pulsewidth signal to a motor or servo to change speed or position, respectively.
HTU21D Humidity and Temperature Sensor:
The HTU21D sensor has the ability to read temperature and humidity. There are four pins on the sensor chip – a power line (3.3V input), ground, SDA (Serial Data Line), and SCL (Serial Clock Line). SDA is used by the arduino to read data off the sensor. Reading the sensor uses I2C, and allows the microcontroller on the Arduino to read data from different addresses on the sensor. These different addresses correspond to the different values that can be read from the sensor – namely temperature and humidity. SCL, on the other hand, is used to synchronize the system clock for the microcontroller with the clock in the sensor. They are both set to 9600 baud. This makes sure that the microcontroller and the sensor operate at the same frequency.
Adafruit SD Card Arduino Shield:
This shield allows users to log temperature and humidity indefinitely, assuming there is enough space on the SD card and there is a constant source of power. The assembly with the Arduino is very easy, and requires very basic soldering knowledge. The only thing necessary before use is to solder on header pins. After that, it can simply be plugged in on top of the Arduino. The SD card can be removed at any time and plugged into a computer to view the data logs. The data is outputted in the form of a text file, where each line is each printed Serial line from the Serial Output Window.
The shield itself provides all the necessary connections to the Arduino, while still allowing all of the pins to be used. By adding headers to the shield, the pins can be extended through it and become usable again, above the shield. Plugging in the SD card is as simple as that – once the card is plugged in, the board will automatically recognize it, and the SD card integration code can be used to log data. If there is no SD card in the slot, however, the SD card integration code will not be able to run.
Sensors can be added to monitor variables such as gas (methane), air quality (carbon monoxide), pH and a number of other variables.
Currently the arduino is exposed and cannot be left in an exposed environment. This can easily be fixed by adding on a case with a hole for the wires and a battery pack that can easily be attached to the arduino. An alternative to a battery pack could be a solar panel. The case can either be built or purchased and prevents the arduino from shorting. An alternative solution is to leave the arduino inside and run longer wires into the garden.
Build your own case: http://tinyurl.com/q9hju6r
HTU21D Arduino Schematic
The power pin on the HTU21D is connected to the 3.3V pin on the Arduino, and ground is connected to the ground pin. SDA is connected to Analog Pin 4, and SCL is connected to Analog Pin 5.
Method to wire circuits
- Cut equal lengths of each color wire. The length is whatever you desire based on the application. Ideally you want to keep the Arduino Uno out of the elements, we recommend about a foot.
- Strip ends of the wire ¼ in
- Tin the ends of the wire by heating it with the soldering iron then coating it with a thin layer of solder
- Heat the the surface on the sensor and wire with soldering iron and apply solder to the join. Soldering iron can be cleaned by wiping on wet sponge to remove excess solder
- Insert the wire into the appropriate slot according to the circuit diagram
- Wrap any wire with exposed wire and/or solder in electrical tape to prevent shorting
- Download and install Arduino software onto computer http://arduino.cc/en/main/software
- Load code (With SD Card or Without SD Card)
- Click to compile and verify code
Plug in Arduino with the micro USB cable and click the upload button
- Hit the reset button on your Arduino (Circled in red)
- Congratulations! You can now run the sensor
Code (Integration with SD card data collection)
SD Card Readout Example
Here we have an example graph of collected data, followed by a table of the logged data.
|Temperature C||Temperature F||% Humidity|