Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
MatthiasDankers
Published © GPL3+

Humiduino

An automated humidor using an Arduino — with or without building your own humidor.

BeginnerFull instructions provided11,300
Humiduino

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
DHT22 Temperature Sensor
DHT22 Temperature Sensor
With a 2% humidity precision and 0.5C temperature precision it is a good choice. It is possible to use the DHT11 as well.
×1
Funduino LCM1602 i2c
You can use any 16*2 LCD screen but I used one with the i2c LCD interface to the back of it. You only have to connect 4 wires.
×1
5V Relay module
×1
3V-6V submersible water pump
×1
9V 1A Switching Wall Power Supply
9V 1A Switching Wall Power Supply
×1
Linear Regulator (7805)
Linear Regulator (7805)
×1
Capacitor 10 µF
Capacitor 10 µF
×1
Resistor 10k ohm
Resistor 10k ohm
×2
18 ohm 1W resistor
×2

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Custom parts and enclosures

Humidor box

Solidworks humidor box. The holes for the LCD and analog hygrometer might not be in the correct size and it depends on the parts you are using.

Humidor box lid

Solidworks humidor box lid.

Schematics

Humidiuno electronics Fritzing

Humidor electronics Fritzing - Image

Code

Humidor Arduino no comments

Arduino
#include "DHT.h"
#include "Wire.h"
#include "LiquidCrystal_I2C.h"

#define DHTPIN 7
#define DHTTYPE DHT22

const int buttonPin = 3;
const int pMotor = 9;
int buttonState = 0;
int timeT = 0; 
int countPump = 0;
float hum;
float temp;
float htCalcA;
float htCalcB;
float htCalcC;
float htCalcD;
float htCalcE;
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
 
void setup()
{
  Serial.begin(9600);
  lcd.begin(16,2);
  lcd.clear();
  lcd.noBacklight(); 
  pinMode(buttonPin, INPUT);
  pinMode(pMotor, OUTPUT); 
}
void loop()
{
  temp = dht.readTemperature();
  hum = dht.readHumidity();
  timeT = 0;
  digitalWrite(pMotor, LOW);
  htCalcA = 17.2694*temp/(238.3+temp); 
  htCalcB = 0.61078*7.501*(exp(htCalcA));
  htCalcC = 76000/hum; 
  htCalcD = (htCalcC / htCalcB)-1;
  htCalcE = 620.69*(1/htCalcD);

  if (htCalcE < 10.70 && countPump >=48)
    {
      digitalWrite(pMotor, HIGH);
      delay(1000);
      digitalWrite(pMotor, LOW); 
      countPump = 0;
    }
  else if (htCalcE > 11.00)
    {
      digitalWrite(pMotor, LOW);
      countPump = 0;
    }
  else
    {
      digitalWrite(pMotor, LOW);
      countPump ++;
    }
  while(timeT < 1200) 
    {
    // start while loop
    buttonState = digitalRead(buttonPin); 
    if (buttonState == HIGH) 
      {
      temp = dht.readTemperature();
      hum = dht.readHumidity();
      lcd.backlight();
      lcd.clear(); 
      lcd.setCursor(2, 0);
      lcd.print("Humi= ");
      lcd.print(hum);
      lcd.print("%");
      lcd.setCursor(2, 1);
      lcd.print("Temp= ");
      lcd.print(temp);
      lcd.print("C");
      delay(5000);
      lcd.clear(); 
      lcd.noBacklight();
      timeT +20;
      }
    else 
      {
      timeT ++;
      }
    delay(250);
  }

/* I don't now exactly how the Arduino Community works, but i've used a lot of code and knowledge from others so you are free to use 
 and change this code above. Enjoy - Matthias Dankers*/ 

Humidor Arduino code

Arduino
#include "DHT.h" // Library for the DHT sensor. Download available in Arduino project hub.
#include "Wire.h" // Library for communication with i2c devices. 
#include "LiquidCrystal_I2C.h" // Library for the LCD. Download available in Arduino project hub.

#define DHTPIN 7 // Digital Pin used for the sensor. If you use a DHT11 make sure to use a analog pin.
#define DHTTYPE DHT22 // Define the sensor type you are using.

const int buttonPin = 3;
const int pMotor = 9;
int buttonState = 0;
int timeT = 0; 
int countPump = 0;
float hum;
float temp;
float htCalcA;
float htCalcB;
float htCalcC;
float htCalcD;
float htCalcE;
DHT dht(DHTPIN, DHTTYPE); // DHT sensor initialiseren
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); //initialize LCD 
 
void setup()
{
  Serial.begin(9600);
  lcd.begin(16,2);
  lcd.clear();
  lcd.noBacklight(); 
  pinMode(buttonPin, INPUT);
  pinMode(pMotor, OUTPUT); 
}
 
void loop()
{
  temp = dht.readTemperature();
  hum = dht.readHumidity();
  timeT = 0;
  digitalWrite(pMotor, LOW);
  /* Following calculations are based on formulas used for the psychrometric chart.
   * As a beginner I split the calculation in five parts. If you have a way to do it all at once, please let me know. 
   */
  htCalcA = 17.2694*temp/(238.3+temp); 
  htCalcB = 0.61078*7.501*(exp(htCalcA));
  htCalcC = 76000/hum; 
  htCalcD = (htCalcC / htCalcB)-1;
  htCalcE = 620.69*(1/htCalcD);

  if (htCalcE < 10.70 && countPump >=48)
  /* First we check if the humidity is high enough. After that we have to make sure the pump will not add too much water to the
   *  humidifier. The evaporation of water to the air is a slow proces. The humidity will not rise immediatly after adding water 
   *  to the humidifier. Therefore we add a counter; countPump. It will increase everytime it did not pump and the humidity is 
   *  not above 11.00 and can reach 48 in four hours. See while statement furter in the code to see why. 
   *  You can change the values if you like.
   */
    {
      digitalWrite(pMotor, HIGH);
      delay(1000); //Change this value to regulate the amount of water that is pumped. It is now 1 second.
      digitalWrite(pMotor, LOW); 
      countPump = 0;
    }
  
  else if (htCalcE > 11.00)
    {
      digitalWrite(pMotor, LOW);
      countPump = 0;
    }
  else
    {
      digitalWrite(pMotor, LOW);
      countPump ++;
    }
    

  
  while(timeT < 1200) 
  /*So this while loop will be active until timeT becomes 1200. The while loop takes 250ms per time. When you
   *push the button you will turn on the screen and the screen will be turned on for 5 seconds. timeT will increase 20. 

   *As long as the program runs the while loop de code above this loop will not run. The humidor can't check temp en hum and it
   *can't start the motor. You can make this while loop much longer if you want.
   */
  
    {
    // start while loop
    buttonState = digitalRead(buttonPin); 
    if (buttonState == HIGH) 
      {
      //start if statement
      //show on LCD
      temp = dht.readTemperature();
      hum = dht.readHumidity();
      lcd.backlight();
      lcd.clear(); 
      lcd.setCursor(2, 0);
      lcd.print("Humi= ");
      lcd.print(hum);
      lcd.print("%");
      lcd.setCursor(2, 1);
      lcd.print("Temp= ");
      lcd.print(temp);
      lcd.print("C");
      delay(5000);//LCD is on for 5 seconds.
      lcd.clear(); 
      lcd.noBacklight(); //LCD off
      timeT +20;
      }// end if statement 
    else 
      {
      timeT ++;
      }//end else statement
    
    delay(250);//delay of 0.25 seconds the while statement is in total 1200*250=300000 mSeconds. So 5 minutes.
  }//end while loop
}// end loop() 

/* I don't now exactly how the Arduino Community works, but i've used a lot of code and knowledge from others so you are free to use 
 and change this code above. Enjoy - Matthias Dankers*/ 

DHT_Library.zip

Arduino
Load this library in Arduino.
No preview (download only).

Newliquidcrystal_1.3.5.zip

Arduino
Load one part of this file as a library in Arduino. The library; LiquidCrystal_I2C.h has to be included.
No preview (download only).

Humidor_compleet_4_met_data_logging.ino

Arduino
The code for the Humidiuno with data logging to the SD card.
#include "DHT.h" // Library for the DHT sensor. Download available in Arduino project hub.
#include "Wire.h" // Library for communication with i2c devices. 
#include "LiquidCrystal_I2C.h" // Library for the LCD. Download available in Arduino project hub.
#include <SD.h>
#include <SPI.h>
File myFile;
int pinCS = 10; // Pin 10 on Arduino Uno

#define DHTPIN 7 // Digital Pin used for the sensor. If you use a DHT11 make sure to use a analog pin.
#define DHTTYPE DHT22 // Define the sensor type you are using.

const int buttonPin = 3;
const int pMotor = 9;
int buttonState = 0;
int timeT = 0; 
int countPump = 0;
float hum;
float temp;
float htCalcA;
float htCalcB;
float htCalcC;
float htCalcD;
float htCalcE;
DHT dht(DHTPIN, DHTTYPE); // DHT sensor initialiseren
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); //initialize LCD 
 
void setup()
{
  Serial.begin(9600);
  pinMode(pinCS, OUTPUT);
  lcd.begin(16,2);
  lcd.clear();
  lcd.noBacklight(); 
  pinMode(buttonPin, INPUT);
  pinMode(pMotor, OUTPUT); 

  // SD Card Initialization
  if (SD.begin())
  {
    Serial.println("SD card is ready to use.");
  } else
  {
    Serial.println("SD card initialization failed");
    return;
  }
}
 
void loop()
{
  temp = dht.readTemperature();
  myFile = SD.open("test.txt", FILE_WRITE);
  myFile.println("temp =");
  myFile.println(temp);
  myFile.close(); // close the file
  hum = dht.readHumidity();
  myFile = SD.open("test.txt", FILE_WRITE);
  myFile.println("hum =");
  myFile.println(hum);
  myFile.close(); // close the file
  timeT = 0;
  digitalWrite(pMotor, LOW);
  /* Following calculations are based on formulas used for the psychrometric chart.
   * As a beginner I split the calculation in five parts. If you have a way to do it all at once, please let me know. 
   */
  htCalcA = 17.2694*temp/(238.3+temp);
  myFile = SD.open("test.txt", FILE_WRITE);
  myFile.println("htCalcA =");
  myFile.println(htCalcA);
  myFile.close(); // close the file
  htCalcB = 0.61078*7.501*(exp(htCalcA));
  myFile = SD.open("test.txt", FILE_WRITE);
  myFile.println("htCalcB =");
  myFile.println(htCalcB);
  myFile.close(); // close the file
  htCalcC = 76000/hum;
  myFile = SD.open("test.txt", FILE_WRITE);
  myFile.println("htCalcC =");
  myFile.println(htCalcC);
  myFile.close(); // close the file 
  htCalcD = (htCalcC / htCalcB)-1;
  myFile = SD.open("test.txt", FILE_WRITE);
  myFile.println("htCalcD =");
  myFile.println(htCalcD);
  myFile.close(); // close the file
  htCalcE = 620.69*(1/htCalcD);
  myFile = SD.open("test.txt", FILE_WRITE);
  myFile.println("htCalcE =");
  myFile.println(htCalcE);
  myFile.close(); // close the file

  if (htCalcE < 10.70 && countPump >=47)
  /* First we check if the humidity is high enough. After that we have to make sure the pump will not add too much water to the
   *  humidifier. The evaporation of water to the air is a slow proces. The humidity will not rise immediatly after adding water 
   *  to the humidifier. Therefore we add a counter; countPump. It will increase everytime it did not pump and the humidity is 
   *  not above 11.00 and can reach 47 in four hours. See while statement furter in the code to see why. 
   *  You can change the values if you like.
   */
    {
      digitalWrite(pMotor, HIGH);
      delay(180); //Change this value to regulate the amount of water that is pumped. For me between 150ms and 180ms is perfect.
      digitalWrite(pMotor, LOW); 
      countPump = 0;

      myFile = SD.open("test.txt", FILE_WRITE);
      myFile.println("1: Water has been pumped.");
      myFile.println(countPump);
      myFile.close(); // close the file
      
    }
  
  else if (htCalcE > 11.00)
    {
      digitalWrite(pMotor, LOW);
      countPump = 0;

      myFile = SD.open("test.txt", FILE_WRITE);
      myFile.println("2: The humidity is too high.");
      myFile.println(countPump);
      myFile.close(); // close the file
    }
  else
    {
      digitalWrite(pMotor, LOW);
      countPump ++;
      
      myFile = SD.open("test.txt", FILE_WRITE);
      myFile.println("Humidity is between 10.70 and 11:00.");
      myFile.println(countPump);
      myFile.close(); // close the file
    }
    

  
  while(timeT < 1200) 
  /*So this while loop will be active until timeT becomes 1200. The while loop takes 250ms per time. When you
   *push the button you will turn on the screen and the screen will be turned on for 5 seconds. timeT will increase 20. 

   *As long as the program runs the while loop de code above this loop will not run. The humidor can't check temp en hum and it
   *can't start the motor. You can make this while loop much longer if you want.
   */
  
    {
    // start while loop
    buttonState = digitalRead(buttonPin); 
    if (buttonState == HIGH) 
      {
      //start if statement
      //show on LCD
      temp = dht.readTemperature();
      hum = dht.readHumidity();
      lcd.backlight();
      lcd.clear(); 
      lcd.setCursor(2, 0);
      lcd.print("Humi= ");
      lcd.print(hum);
      lcd.print("%");
      lcd.setCursor(2, 1);
      lcd.print("Temp= ");
      lcd.print(temp);
      lcd.print("C");
      delay(5000);//scherm is on for 5 seconds.
      lcd.clear(); 
      lcd.noBacklight(); //LCD off
      timeT +20;
      }// end if statement 
    else 
      {
      timeT ++;
      }//end else statement
    
    delay(250);//delay of 0.25 seconds the while statement is in total 1200*250=300000 mSeconds. So 5 minutes.
  }//end while loop
}// end loop() 

/* I don't now exactly how the Arduino Community works, but i've used a lot of code and knowledge from others so you are free to use 
 and change this code above. Enjoy - Matthias Dankers*/ 

Credits

MatthiasDankers
1 project • 6 followers
Contact

Comments

Please log in or sign up to comment.