Real Time Operating System Based Smart Home Automation

About the project

A complete home automation system developed on ESP32 microcontroller using freeRTOS. The system is controlled wirelessly via Bluetooth from a dedicated android app.

Project info

Difficulty: Moderate

Platforms: AndroidEspruinoEspressifMIT App Inventor

Estimated time: 2 weeks

License: MIT license (MIT)

Items used in this project

Hardware components

Monochrome 0.96" OLED Graphic Display Monochrome 0.96" OLED Graphic Display x 1
DHT11 Basic Temp Humidity Sensor DHT11 Basic Temp Humidity Sensor x 1
Ultrasonic Sensor Hc-sr04 Ultrasonic Sensor Hc-sr04 x 1
Analog Gas Sensor(MQ2) Analog Gas Sensor(MQ2) x 1
LDR Module LDR Module x 1
Grove - 2-Channel SPDT Relay Grove - 2-Channel SPDT Relay x 1
LED - Basic Red 3mm LED - Basic Red 3mm x 3
Piezo Buzzer PS1240 Piezo Buzzer PS1240 x 2
Tiny Breadboard Tiny Breadboard x 1
Jumper Wire Kit - 140pcs Jumper Wire Kit - 140pcs x 1
Mini 5V Cooling Fan for RPi Mini 5V Cooling Fan for RPi x 1
ESP32-C3-DevKitC-02 Development Board ESP32-C3-DevKitC-02 Development Board x 1

View all

Software apps and online services

Arduino IDE Arduino IDE
MIT App Inventor MIT App Inventor

Hand tools and fabrication machines

Soldering Kit Soldering Kit x 1


About 'Smart Home Automation'

When we think of home automation we generally visualize switching on/off some buttons, temperature monitoring, etc.

It is not smart automation in true sense.

  • To achieve true home automation RTOS is integrated in the system which can perform multiple things simultaneously.
  • The system is smart enough to automatically trigger actions based on certain events happening in real time.


  • Wireless control with Bluetooth
  • Dedicated Android app
  • Activity monitoring on OLED display and app
  • Temperature sensing using DHT11 sensor
  • Light intensity sensing using LDR
  • Fan/Light control in 3 modes - manual, automatic (based on sensors) and off
  • Person detection at door using ultrasonic sensor
  • Touch detection on door with alarm using ESP32 inbuilt touch sensor
  • Smoke detection with alarm using MQ2 sensor


System Overview

  • The entire system is custom made with wiring and placements planned according to requirements.
  • It is developed to resemble a room in a house.


  • To program the microcontroller Arduino IDE is used which is compatible with ESP32.
  • In addition certain libraries are required for proper functioning of the microcontroller and interfaced components.


  • Bluetooth Serial
  • Wire
  • DHT
  • Adafruit_SSD1306
  • Adafruit_GFX
  • Ticker


    • Another important software required is freeRTOS which is responsible for real time functioning of components present in the system.
    • ESP32 supports freeRTOS out of the box in Arduino IDE with its own flavour on the top of original for proper integration.

    Android App

    The Android app is developed on MIT App Inventor platform.


    Working of the entire Home Automation System.

    Connecting to App

    • Connect/Disconnect button is provided in the app to connect with the system via Bluetooth.
    • There is no external Bluetooth module used as the ESP32 microcontroller has one builtin.

    Activity Monitoring

    • All the sensor activity and switch controls are monitored on OLED display that is interfaced using I2C communication protocol.
    • The same is monitored on the android app.

    Temperature and Light Sensing

    • DHT11 digital sensor is used to sense temperature in the room and it is monitored on App/OLED.
    • Light intensity in the room is sensed using a LDR (Light Dependent Resistor) module. This is used for automatic switching of bulb as explained later.

    Smoke Detection

    • For safety purpose, a smoke detection unit is implemented with MQ2 sensor which activates a buzzer and Led in presence of smoke.
    • The buzzer turns off automatically once the smoke disappears.

    Person Detection

    • If a person comes in the range of ultrasonic sensor mounted on the door, the App/OLED displays presence of the person and Led turns on to notify the same.

    Touch Detection

    • If a person touches the door handle a buzzer is activated and App/OLED displays presence of touch along with an Led indicator.
    • It can be deactivated by pressing the turn off button on app.
    • Touch sensing is implemented using ESP32 inbuilt touch sensor

    Fan/Light Control

    The fan/bulb is operated in 3 modes using relays,

    Manual Mode

    • Buttons on the App are used to manually switch on/off the bulb and fan.

    Automatic Mode

    • Automated switching of fan and light based on temperature monitored by DHT11 sensor and light intensity measured by LDR (Light Dependent Resistor) respectively is implemented.
    • The fan automatically turns on when the temperature crosses threshold value of 33°C and turns off when it falls below the threshold.
    • Based on the lighting conditions in the room sensed by LDR, the bulb turns on automatically when light intensity falls below certain threshold and vice versa.

    Off Mode

    • Everything can be switched off at once with one button on the app when leaving the room.

    Schematics, diagrams and documents

    Circuit Connections



    Code for the project


    Photo of parikshitpagare


    Electronics Engineer | Embedded Software


    Leave your feedback...