Smart Home Systems With Arduino

270

2

1

About: Electrical and Electronics Engineer

Definition:

Seven different systems used in Smart Home Systems with Arduino project are designed to make people's lives easier by communicating with each other without the need for manpower. This intelligent system, created by a combination of door system, curtain system, home lighting system, garden lighting system, temperature system, solar power system and fan system, is managed by a microcontroller and Android phone. The door system is controlled by voice command using the Android phone and directs the motor used in the door lock according to the instructions that allow the door to open and close. The curtain system works in the same way as the door system. It is controlled by voice command using the Android phone and directs the motor used in the screen movement according to the instructions allowing the curtains to be opened and closed. Home Lighting system and fan system are controlled by telephone. The temperature sensor in the temperature system controls the internal temperature of the house and allows the fan to operate. It also prints data on the LCD screen. Garden lighting system is controlled by potentiometer. There are three modes in total. These inter-mode transitions are performed using a potentiometer. In another system the phone is charged with solar energy.

Step 1: Garden Lighting System

Working principle of the system:

There are 3 different mode options in the garden lighting system.

Inter-mode transitions are performed using a potentiometer. The first mode allows the lights to turn off completely. The second mode works by falling below the light level determined by the code depending on the Light Dependent Resistor(LDR), and the light increases or decreases depending on the intensity of light coming to the Light Dependent Resistor(LDR). The third mode allows the lights to remain on completely. It also displays the mode transitions on the LCD screen.

1-First mode --> potDeger >= 1020//Potentiometer value

2-Second mode --> potDeger <= 1000 && potDeger >= 65)//Potentiometer value

3-Third mode --> potDeger <= 20//Potentiometer value

Arduino Code:

  1. #include
  2. const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
  3. LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
  4. int led = 10;
  5. int butonPin = 6;//Button pin value
  6. int potPin = A0;//Potentiometer pin value
  7. int ldrPin = A1;//light dependent resistor(LDR) pin value
  8. void setup()
  9. {
  10. pinMode(led, OUTPUT);
  11. pinMode(6, INPUT);
  12. lcd.begin(16, 2);
  13. lcd.print("GARDEN LIGHT");
  14. Serial.begin(9600);
  15. }
  16. void loop()
  17. {
  18. int butonDeger = digitalRead(butonPin);//Button value
  19. int potDeger = analogRead(potPin);//Potentiometer value
  20. int ldrDeger = analogRead(ldrPin);//Light dependent resistor(LDR) value
  21. int LedParlaklikDegeri = map(ldrDeger, 0, 255, 0, 255 );//Led brightness value
  22. delay(50);
  23. Serial.println(potDeger);
  24. //lcd.setCursor(0, 1);
  25. if (potDeger >= 1020)
  26. {
  27. lcd.setCursor(0, 1);
  28. lcd.print("Lights are on!");
  29. digitalWrite(led, HIGH);
  30. }
  31. else if (potDeger <= 20)
  32. {
  33. lcd.setCursor(0, 1);
  34. lcd.print("Lights are off!");
  35. digitalWrite(led, LOW); }
  36. if (potDeger <= 1000 && potDeger >= 65)
  37. {
  38. lcd.setCursor(0, 1);
  39. lcd.println("Sensor Active! ");
  40. if (ldrDeger <= 20) { digitalWrite(led, HIGH);
  41. }
  42. else if (ldrDeger >= 21 && ldrDeger <= 26)
  43. {
  44. analogWrite(led, 75);
  45. }
  46. else if (ldrDeger >= 27 && ldrDeger <= 35)
  47. {
  48. analogWrite(led, 50);
  49. } else if (ldrDeger >= 36 && ldrDeger <= 41)
  50. {
  51. analogWrite(led, 25);
  52. } else if (ldrDeger >= 42 && ldrDeger <= 47)
  53. {
  54. analogWrite(led, 5);
  55. }
  56. else if(ldrDeger >=48)
  57. {
  58. analogWrite(led, 0);
  59. }
  60. }

Step 2: Fan Control System With Temperature Sensor

Working principle of the system:

Data from temperature sensor(LM35) is read in Arduino. Fan control is provided by the temperature value determined by the code. For example, fan operation is provided when the temperature exceeds 26C. The most important point of this system is that it has 3 modes. The button switches between modes. What are modes?

1.Mode: Keep fan control on continuously.

2.Mode: Operation of the fan connected to the temperature sensor(LM35).

3.Mode: Keeping the fan control fully closed.

There are three LEDs which indicate which mode it is.

1.Mode: The red LED is lit in mode.

2.Mode: In the mode yellow led is lit.

3.Mode: Green LED is lit in mode.

Important components of the system:

Temperature sensor(LM35).

NPN transistor(BD139).

Arduino Code:

  1. int tempPin = A0;
  2. int fan = 11;
  3. int led = 8;
  4. int temp;
  5. int tempMin = 27;
  6. int tempMax = 70;
  7. int buton = 6;
  8. int led1 = 7;
  9. int led2 = 4;
  10. int led3 = 5;
  11. void setup()
  12. {
  13. Serial.begin(9600);
  14. pinMode(fan, OUTPUT);
  15. pinMode(led1, OUTPUT);
  16. pinMode(led2, OUTPUT);
  17. pinMode(led3, OUTPUT);
  18. pinMode(tempPin, INPUT);
  19. pinMode(buton, INPUT);
  20. }
  21. void loop()
  22. {
  23. temp = readTemp();
  24. int butonDeger = digitalRead(buton);
  25. Serial.println(temp);
  26. while (butonDeger)
  27. {
  28. if (digitalRead(buton) == HIGH)
  29. {
  30. if (butonDeger == 1)
  31. {
  32. for (int i = 0; i < 3; i++)
  33. {
  34. digitalWrite(led1, HIGH);
  35. digitalWrite(led2, HIGH);
  36. digitalWrite(led3, HIGH);
  37. delay(200);
  38. digitalWrite(led1, LOW);
  39. digitalWrite(led2, LOW);
  40. digitalWrite(led3, LOW);
  41. delay(200);
  42. }
  43. }
  44. butonDeger++;
  45. }
  46. if (butonDeger == 5)
  47. {
  48. butonDeger = 2;
  49. }
  50. delay(200);
  51. switch (butonDeger)
  52. {
  53. case 2:
  54. digitalWrite(fan, HIGH);
  55. digitalWrite(led1, HIGH);
  56. digitalWrite(led2, LOW);
  57. digitalWrite(led3, LOW);
  58. break;
  59. case 3:
  60. digitalWrite(fan, LOW);
  61. digitalWrite(led1, LOW);
  62. digitalWrite(led2, HIGH);
  63. digitalWrite(led3, LOW);
  64. break;
  65. case 4:
  66. temp = readTemp();
  67. Serial.println(temp);
  68. digitalWrite(led1, LOW);
  69. digitalWrite(led2, LOW);
  70. digitalWrite(led3, HIGH);
  71. if (temp > tempMin)
  72. {
  73. digitalWrite(fan, HIGH);
  74. }
  75. else if (temp < tempMin)
  76. {
  77. digitalWrite(fan, LOW);
  78. }
  79. break;
  80. default:
  81. break;
  82. }
  83. }
  84. delay(200);
  85. }

Step 3: Temperature System With Two Arduino

Working principle of the system:

Firstly, The most important circuit elements used in the system: Two Arduino and two NRF24L01 wireless module. You have noticed that this system has 2 Arduino. Why so? The most important point in making the temperature system in this project is the exchange of data between two Arduino wireless connections. One is the Arduino receiver and the other is the transmitter. Which is the recipient of the data to decide which of the coding is decided. Transmitter The value is read by the temperature sensor(LM35) in the Arduino and the receiver prints the value from the Arduino on the LCD screen. This way you can send the data you want.

Components of the system:

Arduino

NRF24L01 wireless module

Temperature sensor(LM35)

LCD

Potentiometer

Arduino Code:

1-Transmitter Code:

  1. #include
  2. #include "RF24.h"
  3. const int analogPin = A0;
  4. float gerilimDeger = 0;
  5. float sensorDeger = 0;
  6. float sicaklikDeger = 0;
  7. int pot = A1;
  8. int fan = 6;
  9. int tempMax = 27;
  10. int msg[1];
  11. //SCK -> 13
  12. //MISO -> 12
  13. //MOSI -> 11
  14. //CSN -> 7
  15. //CE -> 8
  16. RF24 radio(8, 7);
  17. const uint64_t pipe = 0xE8E8F0F0E1LL;
  18. void setup(void)
  19. {
  20. Serial.begin(9600);
  21. pinMode(fan, OUTPUT);
  22. radio.begin();
  23. radio.openWritingPipe(pipe);
  24. }
  25. void loop(void)
  26. {
  27. sensorDeger = analogRead(analogPin);
  28. gerilimDeger = (sensorDeger / 1023) * 5000;
  29. sicaklikDeger = gerilimDeger / 10.0;
  30. msg[0] = sicaklikDeger; radio.write(msg, 1);
  31. }
  32. }


2- Receiver Code:

  1. #include
  2. #include
  3. #include "RF24.h"
  4. const int rs = 9, en = 6, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
  5. LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
  6. //SCK -> 13
  7. //MISO -> 12
  8. //MOSI -> 11
  9. //CSN -> 7
  10. //CE -> 8
  11. RF24 radio(8, 7);
  12. const uint64_t pipe = 0xE8E8F0F0E1LL;
  13. int msg[1];
  14. void setup()
  15. {
  16. Serial.begin(9600);
  17. lcd.begin(16, 2);
  18. lcd.print("--TEMPERATURE--");
  19. delay(1000);
  20. radio.begin();
  21. radio.openReadingPipe(1, pipe);
  22. radio.startListening();
  23. }
  24. void loop()
  25. {
  26. if (radio.available())
  27. {
  28. bool done = false;
  29. while (!done)
  30. {
  31. done = radio.read(msg, 1);
  32. lcd.setCursor(0, 1);
  33. lcd.print("TEMP: ");
  34. lcd.setCursor(7, 1);
  35. lcd.print("C");
  36. lcd.setCursor(5, 1);
  37. lcd.print(msg[0]);
  38. }
  39. delay(5000);
  40. }
  41. }

    Step 4: Android Phone Controlled Systems

    Working principle of the systems:

    Systems that use HC-06 module are used to make a bluetooth connection with an Android data-based phone (tablet, etc.). After the connection is made, an Android application (App Inventor-2 (MIT),etc.) can be used with the help of the developer to perform certain encodings, for example by controlling the motor control, light switching on and off. -In this project, the light system, fan system, door open and close by the voice command and the curtain is opened and closed by the voice command can be controlled by Android phone connection. After the entry is done correctly, the control screen of four systems (lighting system, fan system, door system, curtain system) is opened. There are separate buttons for each system. After logging in to a desired system, it requires a bluetooth connection and a connection must be made for each system. The most important thing is that the systems do not close when you exit the application. After re-entry, systems can be controlled from where they were left.

    1.Lighting System:

    The prototype house in the Smart Home System project has 3 rooms in total. Each room has its own lighting and is controlled by the Android phone. There are two buttons for each room: "Açık" and "Kapalı".

    2.Fan System:

    This system is also controlled in the same way with Android phone. A total of 3 steps are set and a "STOP" button is available.

    Componenets: DC Motor and L298N Motor Driver

    3.Door-Lock System:

    There are two command-detector words in the system controlled by voice command. (The words "open" and "closed" are the Turkish words. if you want to english language, you can define the code.)(You just write "Open" where you see "Açık"(Arduino IDE). In the same way, you just write "Close" where you see "Kapalı"(Arduino IDE)). -Door lock system is provided with Mini Servo motor.

    4.Curtain System:

    There are two command-detector words in the system controlled by voice command. (The words "Perde açılsın" and "Perde kapansın" are the Turkish words. if you want to english language, you can define the code.)(You just write "Curtain open" where you see "Perde açılsın"(Arduino IDE).In the same way, you just write "Curtain close" where you see "Perde kapansın"(Arduino IDE)).

    Arduino Code:

    1. #include
    2. Servo servoMotor;
    3. Servo servoMotor2;
    4. String state;
    5. int led = 8;
    6. int led4 = 5;
    7. int data;
    8. int led1 = 2;
    9. int led2 = 3;
    10. int led3 = 4;
    11. int in1 = 10;
    12. int in2 = 11;
    13. int enA = 6;
    14. int motorStop = 0;
    15. int speed1 = 75;
    16. int speed2 = 125;
    17. int speed3 = 255;
    18. int leddurum = 0;
    19. boolean motordurum = 0;
    20. void setup()
    21. {
    22. pinMode(led1, OUTPUT);
    23. pinMode(led2, OUTPUT);
    24. pinMode(led3, OUTPUT);
    25. pinMode(in1, OUTPUT);
    26. pinMode(in2, OUTPUT);
    27. pinMode(enA, OUTPUT);
    28. pinMode(led, OUTPUT);
    29. pinMode(led4, OUTPUT);
    30. servoMotor.attach(9);
    31. servoMotor2.attach(7);
    32. Serial.begin(9600);
    33. }
    34. void loop()
    35. {
    36. while (Serial.available())
    37. {
    38. delay(10);
    39. int data = Serial.read();
    40. char deger = char(data);
    41. state += deger;
    42. //delay(100);
    43. if (data == '1')
    44. {
    45. digitalWrite(led1, HIGH);
    46. delay(500);
    47. }
    48. else if (data == '0')
    49. {
    50. digitalWrite(led1, LOW);
    51. delay(500);
    52. data = data + 2;
    53. }
    54. else if (data == '2')
    55. {
    56. digitalWrite(led2, HIGH);
    57. delay(500);
    58. data = data + 1;
    59. }
    60. else if (data == '3')
    61. {
    62. digitalWrite(led2, LOW);
    63. delay(500);
    64. data = data + 1;
    65. }
    66. else if (data == '4')
    67. {
    68. digitalWrite(led3, HIGH);
    69. delay(500);
    70. data = data + 1;
    71. }
    72. else if (data == '5')
    73. {
    74. digitalWrite(led3, LOW);
    75. delay(500);
    76. data = data + 1;
    77. }
    78. else if (data == '6')
    79. {
    80. analogWrite(enA, speed1);
    81. digitalWrite(in1, HIGH);
    82. digitalWrite(in2, LOW);
    83. data = data + 1;
    84. }
    85. else if (data == '7')
    86. {
    87. analogWrite(enA, speed2);
    88. digitalWrite(in1, HIGH);
    89. digitalWrite(in2, LOW);
    90. data = data + 1;
    91. }
    92. else if (data == '8')
    93. {
    94. analogWrite(enA, speed3);
    95. digitalWrite(in1, HIGH);
    96. digitalWrite(in2, LOW);
    97. data = data + 1;
    98. }
    99. else if (data == '9')
    100. {
    101. analogWrite(enA, motorStop);
    102. digitalWrite(in1, LOW);
    103. digitalWrite(in2, LOW);
    104. data = data + 1;
    105. }
    106. }
    107. if (state == "açık")
    108. {
    109. digitalWrite(led, HIGH);
    110. digitalWrite(led4, LOW);
    111. servoMotor.write(90);
    112. }
    113. else if (state == "kapalı")
    114. {
    115. digitalWrite(led, LOW);
    116. digitalWrite(led4, HIGH);
    117. servoMotor.write(10);
    118. }
    119. else if (state == "perde açılsın")
    120. {
    121. servoMotor2.write(350);
    122. }
    123. else if (state == "perde kapansın")
    124. {
    125. servoMotor2.write(10);
    126. }
    127. state = "";
    128. }

    Step 5: App Inventor for Android Phone

    Step 6: Battery Charge With Solar Energy

    The voltage value is doubled by connecting two 6v 15w solar panels in series. Following the specific cable connections using the TP4056 type module, connection to the 18650 type 3.7v li-ion battery was made. A fixed 5v 1a value usb circuit board was used as output.

    Step 7: Video of Smart Home System With Arduino

    Share

      Recommendations

      • Trash to Treasure

        Trash to Treasure
      • Tape Contest

        Tape Contest
      • Arduino Contest 2019

        Arduino Contest 2019

      Discussions

      0
      None
      seamster

      16 days ago

      Thank you for sharing your project with us! : )