After connecting all components finally program the Seeeduino with following program
#include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #include <DHT.h> #define DHTPIN 9 // connect DHT11 sensor signal output with A9 #define RELAY_PIN 10 // relay signal pin #define DHTTYPE DHT11 // DHT 11 DHT dht(DHTPIN, DHTTYPE); // declare DHT11 sensor #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins) #define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin) Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); int h; // humidity int t; // trmperature String motor_Status = "OFF"; int needed_room_temp = 25 ; // targate room temp // int motor_interval_minutes = 3 * 60 * 1000; // value in minutes // int motor_ON_interval_minutes = 2 * 60 * 1000; // value in minutes // int motor_OFF_interval_minutes = 2 * 60 * 1000; // value in minutes int motor_ON_interval_minutes = 2 * 60* 1000; // value in minutes int motor_OFF_interval_minutes = 2 * 60* 1000; // value in minutes void setup() { display.begin(SSD1306_SWITCHCAPVCC, 0x3C); delay(2000); display.clearDisplay(); display.setTextColor(WHITE); pinMode(RELAY_PIN, OUTPUT);//set pin 10 to output Wire.begin(); Serial.begin(115200); dht.begin(); } void loop() { h = dht.readHumidity(); // Read humidity value t = dht.readTemperature(); // Read temperature value switchON(); showOnScreen(); showOnSerial(); delay(motor_ON_interval_minutes); switchOFF(); showOnScreen(); showOnSerial(); delay(motor_OFF_interval_minutes); // if(t < needed_room_temp){ // switchON(); // }else{ // switchOFF(); // } } void switchON(){ digitalWrite(RELAY_PIN , HIGH); motor_Status = "ON"; Serial.println(motor_Status); } void switchOFF(){ digitalWrite(RELAY_PIN , LOW); motor_Status = "OFF"; Serial.println(motor_Status); } void showOnSerial(){ Serial.print("The Temperature is: "); Serial.print(t); Serial.print(" C, Humidity is: "); Serial.print(h); Serial.println("%"); } void showOnScreen(){ display.clearDisplay(); display.setTextSize(2); // display temp , humidity , motor state(ON/OFF) and timing interval // Set the cursor position for the 1st line display.setCursor(0,0); display.print("Temp : "); display.print(t); // Set the cursor position for the second line display.setCursor(0, 16); // Move the cursor to the next row display.print("Humid: "); display.print(h); // Set the cursor position for the third line display.setCursor(0, 32); // Move the cursor to the third row display.print("Motor: "); display.print(motor_Status); // Set the cursor position for the 4th line display.setCursor(0, 48); // Move the cursor to the third row display.print("GAP: "); display.print(motor_ON_interval_minutes/(60*1000)); display.print(" : "); display.print(motor_OFF_interval_minutes/(60*1000)); display.print(" min"); display.display(); }
Here we this program will turn on motor for desired interval(her we take it 2 minutes) and then switch off for 2 mins , by this switching operation we can save most of electricity and water as described earlier blogs.
We can set motor operation based on Room Temperature also instead of fixed Time intervals like
#include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #include <DHT.h> #define DHTPIN 9 // connect DHT11 sensor signal output with A9 #define RELAY_PIN 10 // relay signal pin #define DHTTYPE DHT11 // DHT 11 DHT dht(DHTPIN, DHTTYPE); // declare DHT11 sensor #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins) #define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin) Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); int h; // humidity int t; // trmperature String motor_Status = "OFF"; int needed_room_temp = 25 ; // targate room temp 25 Centrigate // int motor_interval_minutes = 3 * 60 * 1000; // value in minutes // int motor_ON_interval_minutes = 2 * 60 * 1000; // value in minutes // int motor_OFF_interval_minutes = 2 * 60 * 1000; // value in minutes int motor_ON_interval_minutes = 2 * 60* 1000; // value in minutes int motor_OFF_interval_minutes = 2 * 60* 1000; // value in minutes void setup() { display.begin(SSD1306_SWITCHCAPVCC, 0x3C); delay(2000); display.clearDisplay(); display.setTextColor(WHITE); pinMode(RELAY_PIN, OUTPUT);//set pin 10 to output Wire.begin(); Serial.begin(115200); dht.begin(); } void loop() { h = dht.readHumidity(); // Read humidity value t = dht.readTemperature(); // Read temperature value switchON(); showOnScreen(); showOnSerial(); delay(motor_ON_interval_minutes); switchOFF(); showOnScreen(); showOnSerial(); delay(motor_OFF_interval_minutes); //i in case we want it to switch on based on Room Temp instead of Fixed time interval if(t > needed_room_temp){ switchON(); }else{ switchOFF(); delay(motor_OFF_interval_minutes); } } void switchON(){ digitalWrite(RELAY_PIN , HIGH); motor_Status = "ON"; Serial.println(motor_Status); } void switchOFF(){ digitalWrite(RELAY_PIN , LOW); motor_Status = "OFF"; Serial.println(motor_Status); } void showOnSerial(){ Serial.print("The Temperature is: "); Serial.print(t); Serial.print(" C, Humidity is: "); Serial.print(h); Serial.println("%"); } void showOnScreen(){ display.clearDisplay(); display.setTextSize(2); // display temp , humidity , motor state(ON/OFF) and timing interval // Set the cursor position for the 1st line display.setCursor(0,0); display.print("Temp : "); display.print(t); // Set the cursor position for the second line display.setCursor(0, 16); // Move the cursor to the next row display.print("Humid: "); display.print(h); // Set the cursor position for the third line display.setCursor(0, 32); // Move the cursor to the third row display.print("Motor: "); display.print(motor_Status); // Set the cursor position for the 4th line display.setCursor(0, 48); // Move the cursor to the third row display.print("GAP: "); display.print(motor_ON_interval_minutes/(60*1000)); display.print(" : "); display.print(motor_OFF_interval_minutes/(60*1000)); display.print(" min"); display.display(); }
working video
https://youtu.be/lmu3Odk1kZw
In conclusion, the "Upgrade Old Air Coolers to Smart Coolers to save Electricity and water to save environment" will provide an intelligent and efficient solution to conserve energy and water in residential cooling applications. By leveraging the capabilities of the Seeeduino xiao and the Temperature & Humidity Sensor, the system will optimize the operation of the evaporative cooler, enhance user comfort, and promote sustainable cooling practices.
#3 Energy Saver Cooler : Setting up Seeduino with Arduino IDE
#4 Energy Saver Cooler : Circuit Assembly on Breadbord
#5 Energy Saver Cooler : Final Programming and working model