ms_peach
Published © CC BY

Climate Chamber System

Control and maintain stable relative humidity and temperature states to simulate natural conditions for experimental testing in the lab.

AdvancedProtip4,967
Climate Chamber System

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Rotary Encoder with Push-Button
Rotary Encoder with Push-Button
×1
0.96" OLED 64x128 Display Module
ElectroPeak 0.96" OLED 64x128 Display Module
×1
DHT22 Temperature Sensor
DHT22 Temperature Sensor
×1
Ultrasonic Nebuliser / Mist Maker / Fogger
×3
Thermoelectric Peltier Cooler
×2
Heated Bed for 3D Printing
×2
5 mm LED: Green
5 mm LED: Green
×1
5 mm LED: Red
5 mm LED: Red
×1
Breadboard (generic)
Breadboard (generic)
×1
Through Hole Resistor, 150 ohm
Through Hole Resistor, 150 ohm
×2
Resistor 100 ohm
Resistor 100 ohm
×1
MOSFET Transistor, Switching
MOSFET Transistor, Switching
×3
MOSFET High Power 210A
×3
Thermistor, 100 K
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Wire, Wrapping Wire
Wire, Wrapping Wire
×1
AC/DC Power Supply, 12 V
AC/DC Power Supply, 12 V
×1
DC/DC Transformer, 12-24V, 1A
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

Code Humidity

Arduino
This is our code used to handle the switching of the nebulisers in order to maintain stable humidity conditions at a desired level.
// load libraries
#include "DHT.h"
#include "U8glib.h"
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE | U8G_I2C_OPT_DEV_0);

//set Pin for T/RH Sensor and specify type, give character string for output
#define DHTPIN 2
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
char str [10];

//Hardware Pins
const int Fog = 3; //nebulisers
const int Fan = 6; //CPU Fans for air circulation
const int OK = 7;  //rotary encoder push
const int CCW = 8; //rotary encoder counterclockwise
const int CW = 9;  //rotary encoder clockwise

//Global Variables
int ack = 0;
int RH_set = 35; //start value for setting
int SET = 0;
int Direction = 0;
boolean T_condition = true;
boolean RH_condition = true;
long previousMillis = 0;
long interval = 2000;

void setup()
{
  pinMode(Fog, OUTPUT);
  pinMode(Fan, OUTPUT);
  pinMode(OK, OUTPUT);
  pinMode(CCW, OUTPUT);
  pinMode(CW, OUTPUT);

  digitalWrite(Fog, LOW);
  digitalWrite(OK, HIGH);
  digitalWrite(CCW, HIGH);
  digitalWrite(CW, HIGH);

  Serial.begin(9600);
  dht.begin();
  
  // show start page on OLED display; delay for 1.5s
  u8g.firstPage();
  do
  {
    u8g.setFont(u8g_font_helvB14);
    u8g.drawStr(10, 20, "Climate");
    u8g.drawStr(10, 40, "Chamber");
  } while (u8g.nextPage());

  delay(1500);
}

void loop()
{
  if (SET == 0)
  {
    float T = dht.readTemperature();
    float RH = dht.readHumidity();
    
    // show setting menu on OLED display
    u8g.firstPage();
    do
    {
      u8g.setFont(u8g_font_helvB08);
      u8g.drawStr(10, 20, "Set Humidity:");
      u8g.setPrintPos(20, 40);
      u8g.print(RH_set);
      u8g.drawStr(40, 40, "%");
    } while (u8g.nextPage());
    delay(100);
    
    
    while (RH_condition)
    {
      // +5 when encoder is rotated clockwise; set upper-limit to 100
      if (digitalRead(CW) == LOW)
      {
        RH_set = RH_set + 5;
        if (RH_set > 100)
        {
          RH_set = 100;
        }
        
        // show value changes on OLED display
        u8g.firstPage();
        do
        {
          u8g.setFont(u8g_font_helvB08);
          u8g.drawStr(10, 20, "Set Humidity:");
          u8g.setPrintPos(20, 40);
          u8g.print(RH_set);
          u8g.drawStr(40, 40, "%");
        } while (u8g.nextPage());
        delay(100);
      }
      
      // -5 when encoder is rotated counterclockwise; set lower-limit to 30
      if (digitalRead(CCW) == LOW)
      {
        RH_set = RH_set - 5;
        if (RH_set < 30)
        {
          RH_set = 30;
        }
        
        // show value changes on OLED display
        u8g.firstPage();
        do
        {
          u8g.setFont(u8g_font_helvB08);
          u8g.drawStr(10, 20, "Set Humidity:");
          u8g.setPrintPos(20, 40);
          u8g.print(RH_set);
          u8g.drawStr(40, 40, "%");
        } while (u8g.nextPage());
        delay(200);
      }
      if (digitalRead(OK) == LOW)
      {
        delay(100);
        RH_condition = false;
      }
    }
    
    // confirm setting to don't repeat this process
    SET = 1;
  }
  
  // continously read actual conditions via the DHT22 every 2 seconds:
  //if the difference between the current time and last time the DHT22        was read is bigger than the interval at which you want it to be read      -> read DHT22
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis > interval)
  { 
    // save the last time you read the DHT22 
    previousMillis = currentMillis;
    
    float RH = dht.readHumidity();
    float T = dht.readTemperature();
    
    // show DHT22 reading on OLED display
    u8g.firstPage();
    do
    {
      float T = dht.readTemperature();
      float RH = dht.readHumidity();
      u8g.setFont(u8g_font_helvB08);
      u8g.drawStr( 2, 20, "Temperature:");
      u8g.setPrintPos(80, 20);
      u8g.print(T);
      u8g.drawStr( 110, 20, "*C");
      u8g.drawStr( 3, 50, "Humidity:");
      u8g.setPrintPos(80, 50);
      u8g.print(RH);
      u8g.drawStr( 112, 50, "%");
    } while (u8g.nextPage());
    
    //humidity control: 
    //if humidity equal to or above set point -> nebulisers stay off
    if (RH  >= RH_set)
    {
      delay(3000);
      if (RH >= RH_set)
      {
        digitalWrite(Fog, LOW);
        analogWrite(Fan, 180);
      }
    }
    
    //if humidity below set point -> nebulisers turn on for 2s; 
    if (RH < RH_set)
    {
      delay(3000);
      if (RH < RH_set)
      {
        digitalWrite(Fog, HIGH);
        analogWrite(Fan, 180);
        delay(2000);
        digitalWrite(Fog, LOW);
      }
    }
  }
}

Credits

ms_peach

ms_peach

0 projects • 4 followers

Comments