loading

This machine starts a vent through a relay in ether an automatic mode or manual.
1. Automatic mode : The vent start whenever the humidity levels in the room (bathroom) is higher then the levels selected by the user in the humidity level knob and stops when the levels dropped below.

2. Manual Mode : The vent starts when the start button pressed and stops according to the duration select knob.

Step 1: Parts List

Arduino pro mini (5v)
2 X 220ohm Resistors
2 X 1k Potentiometers
Realy module
AM2301 (boxed DHT22) humidity / temperature sensor
5v Regulator
Bunch of cables
Press Button (I used a doorbell button)

Step 2: You Will Also Need

You will also need the DHTxx Arduino library

Step 3: The Code

#include 
dht DHT;
#define Rel 7
#define Buttn 4
#define onTime A1
#define trashold A0
#define DHT22_PIN 5
long sensCount = millis ();
void setup()
{
  Serial.begin(9600);
  pinMode (Rel, OUTPUT);
  pinMode (Buttn, INPUT);
}
void loop()
{
// READ DATA
  if (millis () < sensCount) { sensCount = millis (); }             /*  millis() resets every 50 days or so */
  if (millis () >= sensCount + 5000) {
    Serial.print("DHT22, \t");
    int chk = DHT.read22(DHT22_PIN);
    switch (chk)
    {
      case DHTLIB_OK:  
	  	Serial.print ("OK,\t"); 
                Serial.print (DHT.humidity,1);
                Serial.print (",\t");
                Serial.print (DHT.temperature, 1);
                Serial.print (",\t");
                Serial.println (map (analogRead (trashold), 1, 1023, 45, 95));
		break;
      case DHTLIB_ERROR_CHECKSUM: 
		Serial.println ("Checksum error,\t"); 
		break;
      case DHTLIB_ERROR_TIMEOUT: 
		Serial.println ("Time out error,\t"); 
		break;
      default: 
		Serial.println ("Unknown error,\t"); 
		break;
    }
    sensCount = millis ();
  }
  if (DHT.humidity >= map (analogRead (trashold), 1, 1023, 45, 95)) {
    digitalWrite (Rel, HIGH);
  }
  else digitalWrite (Rel, LOW);
  /* Manual Ignition */
  if (digitalRead (Buttn) == HIGH) {
    long delayButtn =  map (analogRead (onTime), 0, 1023, 1, 61) * 6000;
    long startTime = millis ();
    digitalWrite (Rel, HIGH);
    /* Delay Loop */
    while (millis () <= delayButtn + startTime) {
      Serial.println (map (delayButtn + startTime - millis (), 0, 3600000, 1, 60));
      if (startTime > millis () ) {                            /*  millis() resets every 50 days or so */
        startTime = millis ();
      }
      delayButtn =  map (analogRead (onTime), 0, 1023, 1, 61) * 60000;
    }
    digitalWrite (Rel, LOW);
  }
}
//
// END OF FILE
//
<p>i like that be nice policy, now that is a great lesson in it self. thanks and great site.</p>
<p>amazing, exactly what i needed.! but most important I have learned that you can connect 2x 9V battery clips upside down to each other :) really cool. i love the mode options and the custom box. thanks a lot for sharing !</p>
Thanks for the replay.<br>When connecting the 2 9v connectors dont forget that the -,+ are opposite. (the - connection on the first goes to the + connection on the second and so on)

About This Instructable

8,725views

146favorites

License:

More by udubinsky:ENC28J60 Using Ethernet With Arduino Electro Double Pie Face Showdown  Never Forget It on - Energy Saver 
Add instructable to: