Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 21, 2024, 04:13:56 16:13


Login with username, password and session length


Pages: [1]
Print
Author Topic: Cheap dehumidifier control  (Read 2930 times)
0 Members and 1 Guest are viewing this topic.
ozzy1965
Inactive

Offline Offline

Posts: 6

Thank You
-Given: 1
-Receive: 40


« on: March 07, 2022, 09:39:39 21:39 »

I have been fighting mildew/mold and I needed a better control of my humidifier. Now , we can control the humidity by setting the dehumidifier to a desired value but that is relative to a specific temperature and if there are changes in temperature, the dew point can be reached and therefore condensation could occur. The best is to keep the dew point under 16C or 60F but that could be energy demanding in hot weather. I chose to approach this control by blending the above methods.
Recently I came across a cheap sensor with decent accuracy , AHT21, which is a I2C temperature/humidity sensor. I added a cheap Nano clone (LGT8F328 running at 32MHz) a 1" SSD1306 OLED display and a relay for driving the dehumidifier with the following connections:
Nano- A4 -> SDA to AHT/SSD1306
Nano- A5 -> SCL to AHT/SSD1306
Nano- D4 -> output to driver+relay
My display/sensor already came with pullup resistors , so you need to check for it. Of course, this is a very simple approach, it can be customised and improved by adding buttons to change settings or an infrared transmitter  for the dehumidifier. The code below is set for 50-55% RH with 2 degrees margin for dew point. Readings from AHT21 are in Celsius so for Fahrenheit you need to convert it. Arduino libraries are ready available on the web.
Code:
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <AHTxx.h>

float temperature,humidity,temp_dew_point;     //to store T/RH/T dew point result

AHTxx aht20(AHTXX_ADDRESS_X38, AHT2x_SENSOR); //sensor address, sensor type

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

// On an arduino Nano:       A4(SDA), A5(SCL)
#define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin or not used)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

void setup() {
  Serial.begin(115200);
  Serial.println();
  Wire.setClock(400000); //experimental I2C speed! 400KHz, default 100KHz
  pinMode(4, OUTPUT);    // sets the digital pin D4 as output for relay dehumidifier control
 
 
 
  // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
  if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS))
   {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;); // Don't proceed, loop forever
   }
  // display settings
  display.setTextSize(2);      // Double 2:1 pixel scale
  display.setTextColor(SSD1306_WHITE); // Draw white text
  display.cp437(true);         // Use full 256 char 'Code Page 437' font
  while (aht20.begin() != true)
    {
    Serial.println(F("AHT2x not connected or fail to load calibration coefficient")); //(F()) save string to flash & keeps dynamic memory free
    display.clearDisplay();
    display.setCursor(0, 0);
    display.print(F("Bad sensor"));
    display.display();
    delay(5000);
    }
  Serial.println(F("AHT20 OK"));
  display.setCursor(0, 0);     // Start at top-left corner
 }
 
void loop() {
 
  Show_Data();
  // Set point control for RH between 50-55% and 2deg margin over dew point
  if ((humidity > 55) || ((temperature-2) < temp_dew_point))// start dehumidifier
     digitalWrite(4, HIGH);
  if ((humidity < 50) && ((temperature-2) > temp_dew_point))  // stop dehumidifier
     digitalWrite(4, LOW);
  delay(5000);//measurement with high frequency leads to heating of the sensor
    }
 
void Show_Data(void) {
  display.clearDisplay();
  temperature = aht20.readTemperature(); //read first 6-bytes via I2C, takes 40 milliseconds
  display.setCursor(0, 0);
  display.print(F("Temp="));
  if (temperature != AHTXX_ERROR) //AHTXX_ERROR = 255, library returns 255 if error occurs
   {
    display.print(temperature,1);
   }
  else
   {
      if   (aht20.softReset() == true) display.print(F("reset success")); //as the last chance to make it alive
      else                            { display.print(F("reset failed"));
                                        display.display();
                                        return;}
   }

  humidity = aht20.readHumidity(); //read another 6-bytes via I2C, takes 40 milliseconds
  display.setCursor(0, 21); // go to second row
  display.print(F("Hum ="));
 
  if (humidity != AHTXX_ERROR) //AHTXX_ERROR = 255, library returns 255 if error occurs
  {
    display.print(humidity,1);
  }
temp_dew_point = temperature - ((100 - humidity)/5);
display.setCursor(0,42);// go to third row
display.print(F("Tdp ="));
display.print(temp_dew_point,1);
display.display();
}
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC