A smart home is an intelligent living space that uses modern technology to help residents live independently and comfortably. In a smart home, all mechanical and digital devices are connected to each other and can be controlled by a computer over the internet.
In this capstone project, we will build a comprehensive smart home system using many of the components included in the OSOYOO Smart Home IoT Kit.


First, plug the OSOYOO MEGA-IoT Extension Board into the MEGA2560 board:

Build the circuit as shown below:

| Modules | Osoyoo Mega 2560 |
| White LED Module | D2 |
| Red Button Module | D3 |
| Fan Module | D4 |
| DHT11 Module | D5 |
| PIR Motion Sensor | D6 |
| Active Buzzer | D7 |
| Red LED Module | D8 |
| SG90 Servo | D9 |
| Blue Button Module | D10 |
| LED strip light | D11 |
| Photosensitive sensor | A0 |
| Flame sensor | A1 |
| I2C 1602 LCD | I2C_1 Port |
| RGB Module | RGB Port |

Prerequisites:
Download and Edit the Sample Code
Step 1 Download the code from the following link and unzip it:
https://osoyoo.com/driver/smart-home-v2-udp/comprehensive.zip
Step 2 Once done, connect the OSOYOO MEGA2560 Board to your PC with a USB cable.
Step 3 Open Arduino IDE and choose the correct board type and port for your project.

Step 4 In Arduino IDE, click File > Open, then choose the code in the folder and upload the sketch to your Arduino.

You need to edit the code as follows:
In lines 15 and 16, replace *** with your Wi-Fi SSID and password:
char ssid[] = "***";//replace *** with your wifi ssid char pass[] = "***"; //replace *** with your wifi password
Upload the sketch to the board. Wait until you see:
Done uploading
Now open the Serial Monitor in the upper right corner. You should see your Arduino’s IP address and port number:
In the example above, 192.168.1.81 is the IP address of the Arduino. Enter this IP address in the APP in the next step.
APP Installation and Setup:
Step 1) If you haven’t installed the OSOYOO IoT Robot APP yet, search for “OSOYOO IoT Robot Car APP” in Google Play or the Apple App Store to install it.
You can read the following tutorial for more information about the APP installation:
https://osoyoo.com/2022/02/06/smart-house-iot-learning-kit-v2-0-lesson-1-wireless-lighting-control/#installapp
Step 2) Make sure your phone is on the same local network as the Arduino. Open the APP, tap Settings, and enter the Arduino IP address from the Serial Monitor output above and set the Port to 8888:


The features of this capstone project:
1) After starting the Arduino, the LCD will display the Arduino’s IP address for two seconds, then switch to showing the temperature and humidity data read from the DHT11 sensor.
The RGB module starts GREEN, indicating no alerts.
2) Automatic Light
When the environment is darker than a pre-defined threshold (enable_led in line 39), the Arduino will turn on the light (WHITE LED on D2).
3) Flame Detection and Alert
If the flame sensor data on A1 drops below a pre-defined value (flame_alert in line 38), a flame is detected. The Arduino will trigger a buzzer alert and send a flame message to the LCD and the phone APP. The RGB color will also change to RED.
4) Intruder Detection and Alert
If the PIR motion sensor on D6 detects motion, the Arduino will trigger a buzzer alert and send an intruder message to the LCD and the phone APP. The RGB color will also change to Blue.
5) Manually Stop Intruder and Flame Alerts
You can press the Blue button on D10 or press F1 in the APP to stop the buzzer and clear the alert message from the LCD and APP.
6) Using the APP to Open the Door
Press F8 in the APP to rotate the servo on D9 and open the door. The Red LED on D8 will turn on while the door is open. After 2 seconds, the door will automatically close and the Red LED will turn off.
7) Toggle LED Strip and Fan with the Red Button on D3
The Red button on D3 is attached to a hardware interrupt at line 109. Each time you press it, the interrupt handler function changeflag() at lines 115–117 toggles the LED strip and fan ON/OFF.
8) Control LED Strip and Fan via APP
In addition to the Red button, you can also turn on the LED strip and fan by pressing F2 in the APP.
You can turn them off by pressing F3 in the APP.
| No. | Picture | Device | Qty. | Link |
| 1 | ![]() |
OSOYOO MEGA2560 Board | 1 | Click here to buy |
| 2 | ![]() |
OSOYOO MEGA-IoT Extension Board | 1 | Click here to buy |
| 3 | ![]() |
Photosensitive Sensor | 1 | Click here to buy |
| 4 | ![]() |
Temp & Hum Sensor | 1 | Click here to buy |
| 5 | OSOYOO Active Buzzer Module | 1 | Click here to buy | |
| 6 | ![]() |
Flame Detection Sensor | 1 | Click here to buy |
| 7 | ![]() |
Fan Motor Module | 1 | Click here to buy |
| 8 | ![]() |
Micro Servo Motor | 1 | Click here to buy |
| 9 | ![]() |
RGB Module | 1 | Click here to buy |
| 10 | ![]() |
Ultrasonic Sensor | 1 | Click here to buy |
| 11 | PIR Motion Sensor | 1 | Click here to buy | |
| 12 | ![]() |
Microphone Module | 1 | Click here to buy |
| 13 | ![]() |
1602 I2C LCD Screen | 1 | Click here to buy |
| 14 | ![]() |
RFID Module | 1 | Click here to buy |
| 15 | ![]() |
White LED Module | 1 | Click here to buy |
| 16 | ![]() |
Red LED Module | 1 | Click here to buy |
| 17 | ![]() |
Colorful Light | 1 | Click here to buy |
| 18 | ![]() |
Red Button Module | 1 | Click here to buy |
| 19 | ![]() |
Blue Button Module | 1 | Click here to buy |
| 20 | ![]() |
Philips Screwdriver | 1 | Click here to buy |
DownLoad Url osoyoo.com