Humidity Sensor

    The sensor I chose to use for reading the humidity in my Greenhouse was a DHT11 sensor that I bought off eBay for about $3. Using an Arduino I easily found some DHT11 libraries that allowed for easy function calls in order to setup and read data from the sensor. Beyond that all I did was place it into a kitty-litter container.

  

    To allow for it be hung I extended the wire out through the handle of the container and supported the connection with lots of hot glue. I wanted it to be hung not quite at the top of the Greenhouse but slightly lower because the air near the top of my Greenhouse is very saturated due to poor circulation. It needed to be protected on its topside for when the saturated air condenses and rains out water. 

    And here is the code that I used to visually display the temperature and humidity values:

 

/* 

______________________________________________________________________________________________ Relay 4 is pin 10 red/white Relay 1 is pin 11 blue/white Relay 2 is pin 12 green/white Relay 3 is pin 9 yellow/white  Yellow/white is temp 2 on a1 Green/black is temp 1 on a0 Blue is temp 3 on a2 Temp 4 is the dht11 sensor _____________________________________________________________________________________________  * Inputs ADC Value from Thermistor and outputs  *            Temperature in Celsius * *  requires: include <math.h> * *Utilizes the Steinhart-Hart Thermistor Equation: *    Temperature in Kelvin = 1 / {A + B[ln(R)] + C[ln(R)]3} *    where A = 0.001129148, B = 0.000234125 and C = 8.76741E-08 * * These coefficients seem to work fairly universally, which  is a bit of a surprise.  * * Schematic: *   [Ground] -- [10k-pad-resistor] -- | -- [thermistor] --[Vcc (5 or 3.3v)] *                                     | *                                Analog Pin 0 * * In case it isn't obvious (as it wasn't to me until I thought about it), the analog ports measure the voltage

     between 0v -> Vc c which for an Arduino is a nominal 5v, but for (say) a JeeNode, is a nominal 3.3v. * * The resistance calculation uses the ratio of the two resistors, so the voltage specified above is really only required for the    debugging that  is commented out below * * Resistance = (1024 * PadResistance/ADC) - PadResistor  * *//******************************************************************************************* */

/******************************************************************************************* */

/******************************************************************************************* */

#include <math.h>#define ThermistorPIN0 0                 // Analog Pin 0#define ThermistorPIN1 1#define ThermistorPIN2 2#define ThermistorPIN3 3float vcc = 4.91; // only used for display purposes, if used set to the measured Vcc.

float pad = 9850; // balance/pad resistor value, set this to the measured resistance of  your pad resistor

float thermr = 10000;        //thermistor nominal resistance/******************************************************************************************* */

/******************************************************************************************* */

/******************************************************************************************* */

#include <DHT11.h> //library found online, only slightly modifiedint DHT11pin = 2; //Digital pin for comunicationsint DHT11intNumber = 0; //Interupt #vo dht11_wrapper();   // must be declared before the library initialization

DHT11 DHT11(DHT11pin,DHT11intNumber,dht11_wrapper);  // Library instantiate

/******************************************************************************************* */

/******************************************************************************************* */

/******************************************************************************************* */   float Thermistor(int RawADC) {   long Resistance;     float Temp;  // Dual-Purpose variable to save space.    Resistance=((1024 * pad / RawADC) - pad);    Temp = log(Resistance); // Saving the Log(resistance)    Temp = 1 / (0.001129148 + (0.000234125 * Temp)                  + (0.0000000876741 * Temp * Temp * Temp));   Temp = Temp - 273.15;  // Convert Kelvin to Celsius                          //temp = (Temp * 9.0)/ 5.0 + 32.0;         // Convert to F   return Temp;                     // Return the Temperature}

/******************************************************************************************* *//******************************************************************************************* *//******************************************************************************************* */

vo setup() {   Serial.begin(9600);}/******************************************************************************************* *//******************************************************************************************* */

/******************************************************************************************* */

// This wrapper is in charge of calling vo dht11_wrapper() {   // must be defined like this for the library to work   DHT11.isrCallback();}/******************************************************************************************* */

/******************************************************************************************* */

/******************************************************************************************* */

vo loop() {   float temp0;   temp0=Thermistor(analogRead(ThermistorPIN0));       // read ADC and  convert it to Celsius      float temp1;   temp1=Thermistor(analogRead(ThermistorPIN1));       float temp2;   temp2=Thermistor(analogRead(ThermistorPIN2));       float temp3;   temp3=Thermistor(analogRead(ThermistorPIN3));    /******************************************************************************************* */

DHT11.acquire();   while (DHT11.acquiring())     ;   int result = DHT11.getStatus();   switch (result)   {   case DHTLIB_OK:      //Serial.println("OK");      break;   case DHTLIB_ERROR_CHECKSUM:      Serial.println("Error\n\r\tChecksum error");      break;   case DHTLIB_ERROR_ISR_TIMEOUT:      Serial.println("Error\n\r\tISR Time out error");      break;   case DHTLIB_ERROR_RESPONSE_TIMEOUT:      Serial.println("Error\n\r\tResponse time out error");      break;   case DHTLIB_ERROR_DATA_TIMEOUT:      Serial.println("Error\n\r\tData time out error");      break;   case DHTLIB_ERROR_ACQUIRING:      Serial.println("Error\n\r\tAcquiring");      break;   case DHTLIB_ERROR_DELTA:      Serial.println("Error\n\r\tDelta time to small");      break;   case DHTLIB_ERROR_NOTSTARTED:      Serial.println("Error\n\r\tNot started");      break;   default:      Serial.println("Unknown error");      break;   }/******************************************************************************************* */

/******************************************************************************************* */

/******************************************************************************************* */

//print temperatures here   delay(500);   Serial.print("|==-==-==-==-==-==-==-==-==-==-==-==|");   Serial.println("");   Serial.println("");//print first temp, convert to Fahrenheit   temp0 = (temp0 * 9.0)/ 5.0 + 32.0;                     Serial.print("Temperature: ");    Serial.print(temp0,1);                               //print second temp, convert to Fahrenheit   temp1 = (temp1 * 9.0)/ 5.0 + 32.0;      Serial.print("  ");    Serial.print(temp1,1);                             //print third temp, convert to Fahrenheit    temp2 = (temp2 * 9.0)/ 5.0 + 32.0;      Serial.print("  ");    Serial.print(temp2,1);                              //print fourth temp actually found from DHT11 sensor   Serial.print("  ");   Serial.print(DHT11.getFahrenheit(), 2);   Serial.println("");//print humity   Serial.print("Humity: ");   Serial.print(DHT11.getHumity(), 2);    Serial.println(" %");//print dew point    Serial.print("Dew Point: ");    Serial.println(DHT11.getDewPointSlowF());   Serial.println("");    delay(500);                                         /******************************************************************************************* */

/******************************************************************************************* */

/******************************************************************************************* */  

}

    And here is some screenshots from my phone of serial output through remote view to the Greenhouse using this code: