[SCM Graduation Project] [jj-009] Intelligent Curtains | Multi-Function Curtains | Automatic Curtains | Timed Curtains | Light-Controlled Curtains

1. Basic introduction

Item name:
Design of intelligent curtain system based on microcontroller
Design of multifunctional curtain system based on single-chip microcomputer
Design of automatic curtain system based on single chip microcomputer
Design of timer curtain system based on microcontroller
Design of light-controlled curtain system based on single-chip microcomputer

Project name: Curtain
Microcontroller type: STM32F103C8T6
Specific functions:
1. Detect temperature and humidity through DHT11. When the temperature is less than the set minimum value or the humidity is greater than the set maximum value, the curtains will be automatically closed, otherwise the curtains will be opened.
2. Obtain the light value through the photoresistor. When the light value is less than the set minimum value or greater than the set maximum value, the curtains will be automatically closed, otherwise the curtains will be opened.
3. Get the time through the internal RTC clock and set the curtain opening and closing time
4. Simulate opening and closing of curtains through a four-phase stepper motor
5. Set each threshold, manually open and close curtains, and switch modes through buttons
6. Display measurement value, mode and curtain status through LCD1602
Extended functions: Send measurement data to the mobile phone through the Bluetooth module, and can control curtain switches and switch modes.

2. Data Overview

Physical information

Please add a picture description

Simulation data

Please add an image description

3. Display of some information on 51 microcontroller

1. Physical picture display

Microcontroller model: STC89C52
Power supply interface: TYPE-C
Board type: PCB integrated board, thickness 1.2, two-layer board (upper and lower layers are copper-clad and grounded)
Device type: The components are basically pin type, and some buck chips will use SMD type.

2. Simulation diagram display

Simulation software version: proteus8.9
Circuit connection method: network label connection method
Note: Some physical components are not included in the simulation. They will be replaced by other components with similar working principles in the simulation. This may cause the physical program to be different from the simulation program.

3. Schematic display

Software version: AD2013
Circuit connection method: network label connection method
Note: The schematic diagram only shows the pin diagram of the module, not the internal structure diagram of the module.

4. PCB diagram display

Exported from the schematic diagram, there is a project number in the middle, which is hidden under the base of the microcontroller and will not be seen after inserting the microcontroller.
Two-layer board, top and bottom covered with copper and grounded.

IV. Display of some information on 32 microcontroller

1. Physical picture display

Microcontroller model: STM32F103C8T6
Power supply interface: TYPE-C
Board type: PCB integrated board, thickness 1.2, two-layer board (upper and lower layers are copper-clad and grounded)
Device type: The components are basically pin type, and some buck chips will use SMD type.

2. Schematic display

Software version: AD2013
Circuit connection method: network label connection method
Note: The schematic diagram only shows the pin diagram of the module, not the internal structure schematic diagram of the module.

3. PCB diagram display

Exported from the schematic diagram, there is a project number in the middle, which is hidden under the base of the microcontroller and will not be seen after inserting the microcontroller.
Two-layer board, top and bottom covered with copper and grounded.

5. System block diagram

Drawing software: VISIO

This design uses a single-chip microcomputer as the core controller, plus other modules to form the entire system of this design, including the central control part, the input part and the output part. The central control part adopts a single-chip microcomputer controller, whose main function is to obtain the data of the input part, and finally control the output part after internal processing and logical judgment. The input consists of five parts. The first part is the light detection module, through which the light value of the current environment is detected; the second part is the button module, through which the interface can be switched, thresholds are set, modes are switched, etc.; the third part is the power supply module , through which the entire system can be powered; the fourth part is the temperature and humidity detection module, through which the temperature and humidity values in the environment are detected; the fifth part is the clock module, through which the current time is read. The output consists of two parts. The first part is the display module, through which the monitored data and the set threshold can be displayed; the second part is the stepper motor module, through which the curtain switch is simulated. In addition, the Bluetooth module serves as both input and output. The Bluetooth module is connected to the mobile phone and can transmit the monitored data to the user’s mobile phone. The user can also send instructions through the mobile phone to control the work of the relay and its mode switching. The specific system block diagram is shown in Figure 3.1.

6. Partial program display

Software version: keil5
Note: The logic program and driver are separated and distributed in main.c and other .c files

*******Monitoring function
*****/
void Monitor_function(void)
{<!-- -->
char fasong[32];
if(flag_display == 0) //Measurement interface
{<!-- -->
if(time_num % 10 == 0) //Detect once every 2 seconds
{<!-- -->
Dht11_Get_Temp_Humi_Value( & amp;temp_value, & amp;humi_value); //Get temperature and humidity
\t\t\t
light_value = 30*((Get_Adc_Average(0,3)/4096.0)*3.3);//Get the light
}
}
if(time_num % 20 == 0) //Send once every 4 seconds
{<!-- -->
sprintf(fasong,"Temperature:%d.%d℃",temp_value/10,temp_value );
UsartPrintf(USART1,fasong);
sprintf(fasong,"Humidity: %d.%d%%",humi_value/10,humi_value );
UsartPrintf(USART1,fasong);
sprintf(fasong,"Lighting:%dLx",light_value);
UsartPrintf(USART1,fasong);
}
if(USART1_WaitRecive() == 0)
{<!-- -->
if(strstr((char*)usart1_buf,"A") != NULL) //Switch to automatic mode
{<!-- -->
flag_mode = 0;
}
else if(strstr((char*)usart1_buf,"B") != NULL)//Open window
{<!-- -->
flag_window = 0;
flag_mode = 1;
}
else if(strstr((char*)usart1_buf,"C") != NULL)//Close window
{<!-- -->
flag_window = 1;
flag_mode = 1;
}
USART1_Clear();
}
}

/****
*******Display function
*****/
void Display_function(void)
{<!-- -->
switch(flag_display) //Display different interfaces according to different display mode flags
{<!-- -->
case 0: //Interface 0: measurement interface, displaying each measurement value and mode
// sprintf(display_buf,"%d-%d%d-%d%d",calendar.w_year,calendar.w_month/10,calendar.w_month,calendar.w_date/10,calendar.w_date );
// Oled_ShowString(1, 2, display_buf);
sprintf(display_buf,"%d%d:%d%d:%d%d",calendar.hour/10,calendar.hour ,calendar.min/10,calendar.min ,calendar.sec/10 ,calendar.sec );
Oled_ShowString(1, 3, display_buf);
Oled_ShowCHinese(2, 0, "temperature");
sprintf(display_buf,":%d.? ",temp_value/10,temp_value );
Oled_ShowString(2, 4, display_buf);
Oled_ShowCHinese(3, 0, "humidity");
sprintf(display_buf,":%d.%d%% ",humi_value/10,humi_value );
Oled_ShowString(3, 4, display_buf);
Oled_ShowCHinese(4, 0, "lighting");
sprintf(display_buf,":%dLx ",light_value);
Oled_ShowString(4, 4, display_buf);
\t\t

\t\t
// Oled_ShowCHinese(4, 0, "Mode:");
if(flag_mode == 0)
Oled_ShowCHinese(3,6,"automatic");
else
Oled_ShowCHinese(3,6,"Manual");

if(flag_window == 0)
Oled_ShowCHinese(4,6,"Open");
else
Oled_ShowCHinese(4,6,"Close");
break;

case 1: //Interface 1: Display the minimum value of the set temperature
Oled_ShowCHinese(1,0,"Set the minimum temperature value");
if(time_num % 5 == 0)
{<!-- -->
sprintf(display_buf,"%d ",temp_min);
Oled_ShowString(2, 6, display_buf);
}
if(time_num % 10 == 0)
{<!-- -->
Oled_ShowString(2, 6, " ");
}
break;
\t\t\t
case 2: //Interface 2: Display and set the maximum humidity value
Oled_ShowCHinese(1,0,"Set the maximum humidity value");
if(time_num % 5 == 0)
{<!-- -->
sprintf(display_buf,"%d ",humi_max);
Oled_ShowString(2, 6, display_buf);
}
if(time_num % 10 == 0)
{<!-- -->
Oled_ShowString(2, 6, " ");
}
break;

case 3: //Interface 3: Display and set the maximum lighting value
Oled_ShowCHinese(1,0,"Set the maximum lighting value");
if(time_num % 5 == 0)
{<!-- -->
sprintf(display_buf,"%d ",light_max);
Oled_ShowString(2, 6, display_buf);
}
if(time_num % 10 == 0)
{<!-- -->
Oled_ShowString(2, 6, " ");
}
break;
\t\t\t
case 4: //Interface 4: Display and set the minimum lighting value
Oled_ShowCHinese(1,0,"Set the minimum lighting value");
if(time_num % 5 == 0)
{<!-- -->
sprintf(display_buf,"%d ",light_min);
Oled_ShowString(2, 6, display_buf);
}
if(time_num % 10 == 0)
{<!-- -->
Oled_ShowString(2, 6, " ");
}
break;

case 5: //Interface 5: Display and set the scheduled start time
Oled_ShowCHinese(1,1,"Set start time");
if(time_num % 5 == 0)
{<!-- -->
sprintf(display_buf," d: d", time_shi_begin, time_fen_begin);
Oled_ShowString(2, 6, display_buf);
}
if(time_num % 10 == 0)
{<!-- -->
Oled_ShowString(2, 6, " ");
}
break;
\t\t\t
case 6: //Interface 6: Display and set the scheduled start time
Oled_ShowCHinese(1,0,"Set start time");
if(time_num % 5 == 0)
{<!-- -->
sprintf(display_buf," d: d", time_shi_begin, time_fen_begin);
Oled_ShowString(2, 6, display_buf);
}
if(time_num % 10 == 0)
{<!-- -->
Oled_ShowString(2, 9, " ");
}
break;

case 7: //Interface 7: Display and set the scheduled end time
Oled_ShowCHinese(1,1,"Set end time");
if(time_num % 5 == 0)
{<!-- -->
sprintf(display_buf," d: d", time_shi_end, time_fen_end);
Oled_ShowString(2, 6, display_buf);
}
if(time_num % 10 == 0)
{<!-- -->
Oled_ShowString(2, 6, " ");
}
break;
\t\t\t
case 8: //Interface 7: Display and set the scheduled end time
Oled_ShowCHinese(1,1,"Set end time");
if(time_num % 5 == 0)
{<!-- -->
sprintf(display_buf," d: d", time_shi_end, time_fen_end);
Oled_ShowString(2, 6, display_buf);
}
if(time_num % 10 == 0)
{<!-- -->
Oled_ShowString(2, 9, " ");
}
break;
default:
break;
}
}

/****
*******Handling function
*****/
void Manage_function(void)
{<!-- -->
if(flag_display == 0) //Measurement interface
{<!-- -->
if(flag_mode == 0) //If in automatic mode
{<!-- -->
      if(time_shi_begin*60 + time_fen_begin > time_shi_end*60 + time_fen_end) //Start time > End time
      {<!-- -->
        if((time_shi_end*60 + time_fen_end <= calendar.hour*60 + calendar.min) & amp; & amp; (calendar.hour*60 + calendar.min < time_shi_begin*60 + time_fen_begin)) //The current time is not set within the time
          flag_time_on = 0;
        else //otherwise
          flag_time_on = 1;
      }
      else if(time_shi_begin*60 + time_fen_begin < time_shi_end*60 + time_fen_end) //Start time <End time
      {<!-- -->
        if((time_shi_begin*60 + time_fen_begin <= calendar.hour*60 + calendar.min) & amp; & amp; (calendar.hour*60 + calendar.min < time_shi_end*60 + time_fen_end)) //The current time is setting within the time
          flag_time_on = 1;
        else //otherwise
          flag_time_on = 0;
      }
if(temp_value < temp_min *10 ||
humi_value > humi_max*10 ||
light_value < light_min ||
light_value > light_max ||
flag_time_on == 0) //If the temperature/light is less than the minimum value or the humidity is greater than the maximum value or outside the set value, close the curtains
{<!-- -->
if(flag_window_status == 0)
{<!-- -->
Motor_Reversal();
flag_window_status = 1;
flag_window = 1;
}
}
else //if((temp_value >= temp_min || humi_value <= humi_max || (light_value >= light_min & amp; & amp; light_value <= light_max)) & amp; & amp; flag_time_on == 1 )
{<!-- -->
if(flag_window_status == 1)
{<!-- -->
Motor_Foreward();
flag_window_status = 0;
flag_window = 0;
}
}
}
    else //Manual mode controls the motor according to button presses
{<!-- -->
switch(flag_window)
{<!-- -->
case 0: //0: Motor rotates forward, window opening
if(flag_window_status == 1)
Motor_Foreward();
flag_window_status = 0;
break;
\t\t\t\t
case 1: //1: Motor reverses, close window
if(flag_window_status == 0)
Motor_Reversal();
flag_window_status = 1;
break;
\t\t\t\t\t\t
default:
break;
}
}
}
else //Set up interface
{<!-- -->

}
}