Introduction: Miniature Green House With Arduino

Requirements

- Soda bottle
- humidity / temperature sensor
- Servo motor
- Arduino
- box
- Arduino case
- elastic bands
- electrical wires

Step 1: Attach the Humidity / Temperature Sensor to the Soda Bottle

Attach the humidity / temperature sensor to the soda bottle with an elastic band

Step 2: Attach the Arduino Case to the Box

Step 3: Connect the Sensor to Arduino

in this case it is the AM2302 sensor

the AM2302 has the following wires yellow,red and black

Connect the red wire to the 5v slot on the arduino, connect the black wire to the ground slot (GRD) on the arduino. The yellow wire goes to a data slot on the arduino you select which pin in code later on, I used pin 2.

Step 4: Instal the Required Library for the Sensor in the Arduino IDE

http://playground.arduino.cc/Main/DHTLib

Download the library from Github and import the library in the Arduino IDE

Step 5: Write the Code for the Sensor and Test If It Works

U can use this code from the examples in the dht library to test the sensor

https://github.com/adafruit/DHT-sensor-library/blo...

Step 6: Connect the Servo Motor to Arduino

Connect the servo motor to Arduino the one I used had red,white and black wires.

Red once again was for the power 3,3v or 5v, black for the ground and white was for a dat pin in this case i used pin 9 like in the sweep tutorial of the Arduino examples library.

Step 7: Test the Servo Motor

To test the servo motor u can use the sweep example from the examples library in the Arduino IDE.

Examples -> Servo -> sweep

Step 8: Connect Both the Sensor and the Servo Motor to Arduino

Servo

red - 3.3v black - grd white - pin 9

Sensor

red - 5v black - grd yellow - pin 2

Step 9: Write the Code for the Green House

This is the code I wrote for my green house which ask for water if the humidity is below 50 %

copy the code and format it in the Aduino IDE so its easier to read (ctrl+T)

#include "DHT.h" // DHT & AM2302 library
#include // servo library

// Version number const float fVerNum = 0.03;

// Data pin connected to AM2302 #define DHTPIN 2

#define DHTTYPE DHT22 // DHT 22 (AM2302)

DHT dht(DHTPIN, DHTTYPE); // LED pins

Servo myservo; // create servo object to control a servo // a maximum of eight servo objects can be created

int pos = 0; // variable to store the servo position

////////////////////////////////////////////////////// // // SETUP // void setup() { // Setup serial monitor Serial.begin(9600);

//servo pin 9 myservo.attach(9);

// Wait 3 seconds delay(3000);

Serial.println(F("\nAM2302 Sensor")); Serial.print(F("Version : ")); Serial.println(fVerNum); Serial.println(F("Arduino - Derek Erb\n")); delay(5000);

dht.begin(); }

void loop() {

// Reading temperature or humidity takes about 250 milliseconds! // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) float h = dht.readHumidity(); float t = dht.readTemperature();

// check if returns are valid, if they are NaN (not a number) then something went wrong! if (isnan(t) || isnan(h)) { Serial.println(F("Failed to read from DHT")); } else { Serial.print(F("Humidity: ")); Serial.print(h); Serial.print(F(" %\t")); Serial.print(F("Temperature: ")); Serial.print(t); Serial.println(F(" C"));

if (h < 50){ // if humidity is lower then 50 the plants should be waterd for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees { // in steps of 1 degree myservo.write(pos); // tell servo to go to position in variable 'pos' } } else { for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees { myservo.write(pos); // tell servo to go to position in variable 'pos' // waits 15ms for the servo to reach the position } } }

// Wait 3 seconds delay(3000); }

Step 10: Put the Arduino in the Case and Attach the Watering Indicator

Step 11: Put the Green House Over a Plant

Step 12: Done

The green house should now measure humidity and temperature.

If the humidity goes below 50 % the servo should turn putting the flag up indicating the plant needs water.