viorelracoviteanu
Published © GPL3+

Automatic FART EXTRACTOR / Bathroom Dehumidifier Fan

A fan, a bathroom dehumidifier, or, as I like to call it, an AUTOMATIC FART EXTRACTOR.

IntermediateFull instructions provided325
Automatic FART EXTRACTOR / Bathroom Dehumidifier Fan

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
DHT22 Temperature Sensor
DHT22 Temperature Sensor
×1
Trimmer Potentiometer, 5 kohm
Trimmer Potentiometer, 5 kohm
×1
Relay Module (Generic)
×1
Rocker Switch, SPST
Rocker Switch, SPST
×1
Test Accessory, AC Power Adaptor
Test Accessory, AC Power Adaptor
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Box, General Purpose
Box, General Purpose

Story

Read more

Schematics

Electric diagram

Code

The code

Arduino
/* Automatic fan control for bathroom humidity
 * humidity threshold set by a potentiometer 30<->90%
 * pushbutton for manual activation 15 minutes
 * 
 *  Viorel Racoviteanu
 *  https://www.youtube.com/channel/UCiRLZX0bV9rS04BGAyUf-fA
 *  https://racov.ro
 *  YO3RAK@gmail.com
 *  
 * I cannot take any responsibility for missuse of this code
 * or any kind of damage it may occur from using this code.
 * 
 * nov 2022 - first release
*/

//Libraries
#include <DHT.h>;
DHT sensor(3, DHT22);   // Initialize DHT22 on pin 3

//Variables
unsigned long NowTime;    //Store the current millis() for timing purposes
int hum_set;              //Stores set humidity threshold
int hum_read;             //Stores real humidity
int temp;                 //Stores real temperature
String fan;               //colud be ON of OFF, for serial display

void setup()
{
// pin declaration
  pinMode(A6, INPUT);     //potentiometer pin
  pinMode(3, INPUT);      //DHT22 sensor pin
  pinMode(4, OUTPUT);     //relay pin
  pinMode(13, OUTPUT);    //LED pin
  Serial.begin(9600);
  sensor.begin();
  
// splashscreen
  Serial.println();
  Serial.println("     *****    FART EXTRACTOR, nov.2022    *****");
  Serial.println("Viorel Racoviteanu, https://racov.ro, YO3RAK@gmail.com");
  Serial.println();

  digitalWrite(13, HIGH); // activate relay and led
  digitalWrite(4, HIGH);
// the reset is manual activation for 15 minutes
  Serial.println("Manual activation 15 minutes");
  Serial.println();
  for (int i = 0; i<(15*60); i++){
    delay (1000);
  }
  NowTime = millis();
  digitalWrite(13, LOW);
  digitalWrite(4, LOW);
  fan = "OFF";
  NowTime = millis();
}

void loop()
{
//Read the potentiometer for set humidity threshold
//transforms potentiometer voltage into threshold value
  hum_set = (map(analogRead(A6), 0, 1023, 30, 90));
//Read sensor data every 2 seconds
  hum_read = sensor.readHumidity();
  temp= sensor.readTemperature();
//Print temp and humidity values to serial monitor
  digitalWrite(13, HIGH);     //blink LED
  Serial.print("Rh%:");
  Serial.print(hum_read);
  Serial.print(", Set:");
  Serial.print(hum_set);
  Serial.print(", Temp:");
  Serial.print(temp);
  Serial.print(", Fan-");
  Serial.println(fan);
  delay (100);
  digitalWrite(13, LOW);
//if threshold exceeded
  if(hum_read > hum_set) {
    fan = "ON";
    digitalWrite(4, HIGH);    //activate relay and led
    digitalWrite(13, HIGH);
  }
//if threshold not exceeded (with hysteresis)
  if(hum_read < (hum_set-3)) {
    fan = "OFF";
    digitalWrite(4, LOW);    //deactivate relay
  }
  delay(2000);
}

Credits

viorelracoviteanu

viorelracoviteanu

5 projects • 53 followers

Comments