Tuesday, June 4, 2019

Arduino-Based Temperature Automated Curtain Railing System

Arduino-Based Temperature Automated winding-clothes Railing governanceCHAPTER 5THE SOLUTION5.1OverviewThe goal of Arduino-Based Temperature Automated Curtain Railing System is to ease the daily operation of residential drapes by automating the curtains w present the curtains doesnt require human effort and operates by using electric powered motors. Based on the performance methods discussed in the previous chapter, the proposed solution to achieve the goal and objectives is thoroughly explained and evaluated in this chapter. Arduino-Based Temperature Automated Curtain Railing System has two methods of application. A temperature module detector is integrated into the system to read and send temperature data which then the systems evaluates and decides in closing and opening the curtains. Also, a Bluetooth module is added to give the system the capability to be connected and controlled by users through a smart phone. For this application, an existing Android app is used to establis h the connection between the smartphone and the Arduino microcontroller. The prime language used in this system is C++.5.2Arduino Microcontrollerinclude limit btRX 3 // BT RX pindefine btTX 4 // BT TX pindefine ledClose 9 // Close indicator conductdefine led blossom 10 // Open indicator leaddefine swClose 11 // Curtain Close limit switch inputdefine swOpen 12 // Curtain Open limit switch inputdefine ledOn 13 // Power ON and RECV indicator LEDdefine LM35pin A0 // LM35 temp pindefine motRev A5 // Motor extirpate control pindefine motFor A4 // Motor Forward control pin hear 5.1 Declaring the pinsThe microcontroller pins are prime(prenominal) say. Each module is assigned to a pin. The declared value is used later on throughout the code instead of the pins.5.3Initializing System Componentsvoid measTemp()reading = analogRead(LM35pin) // Read sensortempC = reading / 9.31 // Convert to Celciusdelay(100)Figure 5.2 Initialize LM35 Temperature sensorSystem reads the value produced from t he LM35 pin. The value produced by the sensor is in voltage metric and is converted to Celsius. The debate delay is set to 0.1 plump fors.measTemp() // contain a temperature readingif (HC05.available()0)char inByte = HC05.read()delay(100)Figure 5.3 Initialize HC-05 Bluetooth moduleBluetooth module reads the temperature data from temperature sensor and sends the data to any smartphone device connected through Bluetooth. The parameter delay is set to 0.1 seconds.void blinkLED()digitalWrite(ledOn, pathetic)delay(50)digitalWrite(ledOn, elevated)delay(50)Figure 5.4 Initialize LED indicatorLED is set to blink by turning on and off for 0.05 second intervals. This is used later on as to indicate the system is running.5.3Curtain Initializing Functions void chkStatus()openStat = digitalRead(swOpen)closeStat = digitalRead(swClose)if (openStat == HIGH closeStat == LOW) // Curtain is opendigitalWrite(ledOpen, HIGH)digitalWrite(ledClose, LOW)HC05.println(Curtain sensory(a))else if (openSta t == LOW closeStat == HIGH) // Curtain is closeddigitalWrite(ledOpen, LOW)digitalWrite(ledClose, HIGH)HC05.println(Curtain unkindly)else if (openStat == LOW closeStat == LOW) // Curtain state not known // so close it firstHC05.println(Initialise..)delay(500)HC05.println(Waiting to CLOSE) //displays this while curtain closingblinkLED()closeStat = digitalRead(swClose)digitalWrite(motRev, HIGH)digitalWrite(motFor, LOW)while (closeStat == LOW) //Wait until Close Sw = HIGHdigitalWrite(motRev, LOW)digitalWrite(ledOpen, LOW)digitalWrite(ledClose, HIGH)HC05.println(Curtain CLOSED)Figure 5.5 Function to initialize the curtainThe curtain functions are presented above. The function detects if the open switch is engaged and the close switch is not. If its true, then red LED is switched on indicating the curtain is open and Curtain turn over character is sent to the Bluetooth module which later sends to any connected smartphone. Else if, the yellow LED is switched on indicating curtain is cl osed and Curtain CLOSE character is displayed on smartphone. Else if the function is unable to read the switch or if the curtain state is unknown, the curtain is closed first by default and only then system begins its function. Waiting to CLOSE is displayed while curtain is closing.5.4AUTO/MANUAL Mode Selectioncase 3 // Select Manual Mode on smartphoneHC05.println(Manual ON)autoStat = 0breakFigure 5.8 MANUAL manner selection The code above switches the default auto modality to manual, braggart(a) access to Bluetooth module to receive and send command from connected smartphones. Manual ON is displayed in smartphone indicating that manual mode has been enabled and ready. The case switch tale here is set as case 3.case 4 // Select Auto mode on smartphoneHC05.println(Auto ON)autoStat = 1breakFigure 5.9 AUTO mode selectionThe code in Figure 5.6 switches from manual mode to auto, enabling the temperature module to control the whole system automatically based on temperature.Auto ON is displayed in smartphone indicating that auto mode has been enabled and live. The user has no control on the system in this mode, unless select manual mode. The case switch statement here is set as case 4.5.4Bluetooth Initializing Functions (MANUAL MODE)switch (inByte)case 1 // Open Curtain MANUAL MODEHC05.println(Waiting to OPEN)doblinkLED()openStat = digitalRead(swOpen)digitalWrite(motFor, HIGH)digitalWrite(motRev, LOW)while (openStat == LOW)digitalWrite(motFor, LOW)digitalWrite(ledOpen, HIGH)digitalWrite(ledClose, LOW)HC05.println(Curtain OPEN)breakFigure 5.6 OPEN Curtain Bluetooth financial statementThe code on top shows the OPEN curtain function through Bluetooth connection. The code also enables the Bluetooth module to send curtain posture in real time. Once curtain is full open, the red LED is switched indicating the curtain is to the full open. The green LED blinks, indicating the motor is running and executing. Curtain OPEN is displayed on smartphone screen when the curta in has successfully completed the open process. The function above is declared as a case switch statement giving it case 1. The Android application installed in the smartphone recognizes the case 1 function when the command setting for a specific button is set to 1.case 2 // Close Curtain MANUAL MODEHC05.println(Waiting to CLOSE)doblinkLED()closeStat = digitalRead(swClose)digitalWrite(motRev, HIGH)digitalWrite(motFor, LOW)while (closeStat == LOW) //Wait until Close Sw = HIGHdigitalWrite(motRev, LOW)digitalWrite(ledOpen, LOW)digitalWrite(ledClose, HIGH)HC05.println(Curtain CLOSED)breakFigure 5.7 CLOSE Curtain Bluetooth CommandThe code on top shows the CLOSE curtain function. Yellow LED is turned on when the curtain is fully closed. As the curtain closes fully, Curtain CLOSED is displayed on smartphone screen. The case switch statement here is set as case 2.5.4Temperature Sensor Initializing Function (AUTO MODE)else if (autoStat == 1 tempC 32 openStat == HIGH openClose == 1) // Te mperature exceeds 32measTemp()HC05.println(tempC,1) // forward Temperature data//HC05.println(Waiting to CLOSE) //displays this when curtain closingdoblinkLED()closeStat = digitalRead(swClose)digitalWrite(motRev, HIGH)digitalWrite(motFor, LOW)while (closeStat == LOW) // Wait until Close Sw = HIGHdigitalWrite(motRev, LOW)digitalWrite(ledOpen, LOW)digitalWrite(ledClose, HIGH)HC05.println(Auto CLOSED) // display when curtain closedopenClose = 0Figure 5.10 Curtain CLOSE when temperature highThe above code initializes the curtain to close when the temperature exceeds 32-degree Celsius in automatic mode. When temperature exceeds the icy value, the temperature data is sent to Bluetooth module and is displayed to connected smartphone. While closing, the LED is set to blink indicating the system is running and Waiting to CLOSE is displayed on smartphone. When the curtain is fully closed and the close switch is engaged, AUTO CLOSED is displayed on smartphone.else if (autoStat == 1 tempC me asTemp()HC05.println(tempC,1) // Send Temp data//HC05.println(Waiting to OPEN) //displays this when curtain openingdoblinkLED()openStat = digitalRead(swOpen)digitalWrite(motFor, HIGH)digitalWrite(motRev, LOW)while (openStat == LOW) // Wait until Open Sw = HIGH (Open switch click)digitalWrite(motFor, LOW)digitalWrite(ledOpen, HIGH)digitalWrite(ledClose, LOW)HC05.println(Auto OPEN) //displays this when curtain fully openedopenClose = 1Figure 5.11 Curtain OPEN when temperature low (AUTO)The above code initializes the curtain to open when the temperature goes below 32-degree Celsius in automatic mode. When temperature goes below the fixed value, the temperature data is sent to Bluetooth module and is displayed to connected smartphone. While opening, the LED is set to blink indicating the system is running and Waiting to OPEN is displayed on smartphone. When the curtain is fully opened and the open switch is engaged, AUTO OPEN is displayed on smartphone.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.