Smart window
opens and closes based on sensing light and temperature
An attempt by the architect to reduce energy consumption that leads to environmental pollution 🍃
and the high electricity bill. 💲↗️💲
GET INTO GREEN
THINKING & SCKITCHING: where and how the mechanism work.
Use Fusion 360 to create Construction.
My project consists of two parts.
1) The main parts.
2) The mechanism parts.
The main parts.
The components box :
I made a sketch of each side separately...
taking into consideration how they will be connected.
Holes for installing the component.
Note: The component was downloaded from GrabCAD website.
Bottom track (for sliding window ):
Vertical tracks for the movement of the glass window (sliding) ..
and circular openings for the rotation of the wooden strips.
Fixed & sliding Window :
There are two windows, one movable and one fixed.
The fixed one is at the base of the previous tracks..
The slide has holes to fix the rack...to move it.
Rotary Strips :
They are 180 mm x 42 mm slices that are fixed with a 3 mm screw from the bottom and top in a channel for them to be able to rotate.
Top part :
One of the important parts...its function is to track all the windows and slides.
It also has a second mechanism for moving the strips.
Side Frame part :
One of the important parts...its function is to track all the windows and slides.
It also has a second mechanism for moving the strips.
In one of them also the motor will be placed.
Internal motor holder
The mechanism parts.
The first mechanism: (for window)
One of the important parts...its function is to track all the windows and slides.
It also has a second mechanism for moving the strips.
In one of them also the motor will be placed.
The gear and rack have been loaded from GrabCAD.
This body is to transmit the movement of the motor gear at the top
The second mechanism: (for strips)
The motor moves the rack to rotate the 6 gears, so the slats open 90 degrees.
I modified the original terrace sketch so that the opening is like a motor (through projection)
Download Nuts and Bolts from
McMaster (fusion )
cura
laser cad
The object took 61 minutes, 5 grams PLA, and 90% Infill Density.
I drew my pattern and logo on AutoCAD..
Then I converted the file to DXF and entered it into the Laser program
I used Fritzing to create the circuit because Tinkercad does not contain all the components in my project.
Electrical circuit connection
Input Components (sensors):
1- LDR sensors (two) ... inside & outside.
To sense the difference in lighting between the interior and exterior space
2- DHT sensors (two) ... inside & outside.
To sense the difference in lighting between the interior and exterior space
Action (output) Components :
1- small stepper motor (two).
stepper 1: Slide the window open or close
stepper 2: Rotates 90 degrees to open or close the slides.
2- Led (two ).
When executing any opening command.. it lights up
5 volt adapter
Use a 5V adapter to connect power to the Arduino (instead of the laptop)
Power supply 5 volt
I use this power supply(5v) because my project contains many components that need more power.
Arduino Uno
To write the code and transfer it to be implemented using Arduino board
The Code
#include "DHT.h"
#include <AccelStepper.h>
#define DHT1_outPin 2
#define DHT2_outPin 3
#define DHTTYPE DHT11
DHT dht1(DHT1_outPin, DHTTYPE);
DHT dht2(DHT2_outPin, DHTTYPE);
const int ledWPin = 12;
const int ledGPin = 13;
const int LDR_PinIN = A1;
const int LDR_PinOUT = A0;
#define FULLSTEP 4
AccelStepper stepper1(FULLSTEP, 8, 10, 9, 11);
AccelStepper stepper2(FULLSTEP, 4, 6, 5, 7);
bool isWindowOpen = false;
bool isShutterOpen = false;
void setup() {
Serial.begin(9600);
pinMode(ledWPin, OUTPUT);
pinMode(ledGPin, OUTPUT);
pinMode(LDR_PinIN, INPUT);
pinMode(LDR_PinOUT, INPUT);
stepper1.setMaxSpeed(1000);
stepper1.setAcceleration(100);
stepper2.setMaxSpeed(1000);
stepper2.setAcceleration(100);
dht1.begin();
dht2.begin();
}
void loop() {
stepper1.run();
stepper2.run();
int LDR_INStatus = analogRead(LDR_PinIN);
int LDR_OUTStatus = analogRead(LDR_PinOUT);
float t1 = dht1.readTemperature();
float t2 = dht2.readTemperature();
if (isnan(t1) || isnan(t2)) {
Serial.println("خطأ في قراءة درجة الحرارة!");
return;
delay(0);
}
static unsigned long lastTime = 0;
if (millis() - lastTime >= 1000) {
lastTime = millis();
Serial.print("LDR داخلي: "); Serial.println(LDR_INStatus);
Serial.print("LDR خارجي: "); Serial.println(LDR_OUTStatus);
Serial.print("درجة الحرارة الداخلية: "); Serial.println(t1);
Serial.print("درجة الحرارة الخارجية: "); Serial.println(t2);
}
// فتح الشيش إذا كان الضوء الخارجي أعلى بكثير من الداخلي
if (LDR_OUTStatus > LDR_INStatus + 50 && !isShutterOpen) {
Serial.println(":high_brightness: فتح الشيش...");
stepper1.move(4000);
isShutterOpen = true;
digitalWrite(ledWPin, HIGH);
}
// إغلاق الشيش إذا كان الضوء الداخلي أعلى بكثير من الخارجي
else if (LDR_OUTStatus < LDR_INStatus - 50 && isShutterOpen) {
Serial.println(":crescent_moon: إغلاق الشيش...");
stepper1.move(-4000);
isShutterOpen = false;
digitalWrite(ledWPin, LOW);
}
// فتح الزجاج والشيش عند ارتفاع الحرارة الداخلية بفارق أكثر من 2 درجة
else if ((t1 - t2) > 2.0 && (!isWindowOpen || !isShutterOpen)) {
Serial.println(":fire: فتح الزجاج والشيش للتهوية...");
stepper1.move(2000);
stepper2.move(2000);
isWindowOpen = true;
isShutterOpen = true;
digitalWrite(ledGPin, HIGH);
}
// إغلاق الزجاج والشيش عند انخفاض الحرارة الداخلية بفارق أكثر من 2 درجة
else if ((t2 - t1) > 2.0 && (isWindowOpen || isShutterOpen)) {
Serial.println(":snowflake: إغلاق الزجاج والشيش...");
stepper1.move(-2000);
stepper2.move(-2000);
isWindowOpen = false;
isShutterOpen = false;
digitalWrite(ledGPin, LOW);
}
}
Code explanation
Definition of libraries used in the code
Definition of DHT sensors and their pins
Definition of a variable (constant) for LEDs and LDR sensors
Stepper motor definition
The FULL STEP operating mode is selected for precise motor control
isWindowOpen: A variable to determine whether the window is open or not.
isShutterOpen: A variable to determine whether the shutters are open or not.
Specify output ports:
ledWPin (for controlling window lighting)
ledGPin (for controlling window lighting)
Specify input ports:
LDR_PinIN for indoor light sensor
LDR_PinOUT for outdoor light sensor
Configure motors:
setMaxSpeed(1000): Specify the maximum motor speed.
setAcceleration(100): Set acceleration to prevent violent vibrations.
Start temperature and humidity sensors using dht.begin().
Motors are continuously started using run().
Reading the indoor and outdoor light sensor value.
Reading the indoor and outdoor temperature.
If the temperature reading fails, a message is printed and the execution of this loop() is stopped.
Data is printed to the Serial Monitor every second.
If the outside light is 50 times brighter than the inside light, the blinds are opened (stepper2.move(2000)).
If the inside light is 50 times brighter than the outside light, the blinds are closed (stepper2.move(-2000)).
If the indoor temperature is 2 degrees higher than the outdoor temperature:
Open the window and shutter together for ventilation.
If the outdoor temperature is 2 degrees higher than the indoor temperature:
Closed the window and shutter to retain warmth.
AI
I used GPT to review the code and correct spelling errors...
And also in understanding how the Stepper motor library works.
Assemble the base (components box)
Poor attempts🫠 to collect strips
Finally, the project is complete.🥳
Installing the electrical components in place
installing the model on top of them
Install the sensors and LEDs in their slots.
Here I put my finger on the sensor to block the light..
All the team and the instructors made a great effort to help me in different ways..😍 Thanks to them💚
Menna ,
Mego,
I would like to express my deepest gratitude to my amazing instructors. They were not just mentors but truly like brothers to me. They supported me endlessly, patiently answered my countless questions and requests, and always checked in to make sure I was on the right track. Their dedication and kindness made all the difference in my journey. Thank you from the bottom of my heart for your time, effort, and unwavering support— I couldn’t have done it without you🥰
1 / problem : The 3D printed part opening was too tight for the stepper motor shaft.
The reason :Filament expands
sol : Expansion using a welding machine
2 / problem : The wood opened in the middle
The reason : The wood quality is very poor.😡
sol : Stick with super glue
Seriously: I'm going to turn on the second mechanism.