top of page
Writer's pictureSanskruti Ashtikar

Voice Controlled Home Automation System Using PIC Microcontroller

Updated: Nov 30

Introduction


With the rise of smart home technology, automation has become an integral part of modern living. Home automation systems allow users to control various household appliances with ease, providing convenience and energy efficiency. Voice-controlled home automation systems take this a step further by enabling users to control devices using simple voice commands. In this article, we will discuss the design and implementation of a voice-controlled home automation system using a PIC microcontroller.





Overview of the Project


The project involves using a voice recognition module interfaced with a PIC microcontroller to control home appliances like lights, fans, and other devices. The system listens for specific voice commands, interprets them, and then takes appropriate actions to control the connected appliances. This setup provides a user-friendly and hands-free approach to home automation.


Components Required


  • PIC Microcontroller (PIC16F877A): The central processing unit that controls the entire system.

  • Voice Recognition Module (e.g., Elechouse Voice Recognition Module V3): Captures and processes voice commands.

  • Relay Module: Used to switch household appliances on or off.

  • Home Appliances (Lights, Fans, etc.): Devices to be controlled.

  • LCD Display (16x2): To display system status and recognized commands.

  • Oscillator (Crystal and Capacitors): Provides the necessary clock signal to the microcontroller.

  • Power Supply: To power the microcontroller, voice recognition module, and other components.

  • Resistors, Capacitors, and Diodes: Additional components for circuit stability and protection.

  • Connecting Wires: For making connections between different components.

  • Breadboard/PCB: For assembling the circuit.


Circuit Diagram


Below is a basic circuit diagram for the voice-controlled home automation system:


Voice Recognition Module  -->  PIC16F877A  -->  Relay Module  -->  Home Appliances
              |                     |
          Power Supply            LCD Display
  1. Voice Recognition Module to PIC Microcontroller:

  2. The voice recognition module is connected to the PIC microcontroller via UART (TX and RX pins). This allows the microcontroller to receive the recognized voice commands.

  3. The module’s Vcc and GND are connected to the power supply.

  4. PIC Microcontroller to Relay Module:

  5. The output pins of the PIC microcontroller are connected to the control pins of the relay module.

  6. The relay module is then connected to the home appliances, which will be switched on or off based on the received commands.

  7. PIC Microcontroller to LCD Display:

  8. The microcontroller’s output pins (data and control pins) are connected to the corresponding pins of the LCD display to show the system status and recognized commands.

  9. Power Supply:

  10. The entire system, including the microcontroller, voice module, and relays, is powered by a suitable DC power supply, typically 5V.





Working Principle


  1. Voice Command Recognition:

  2. The voice recognition module captures voice commands from the user and processes them to identify predefined commands like “Turn on the light” or “Turn off the fan.”

  3. Once a command is recognized, the module sends a corresponding signal to the PIC microcontroller via UART.

  4. Command Processing:

  5. The PIC microcontroller receives the command signal from the voice module and interprets it to determine the desired action.

  6. For example, if the command is “Turn on the light,” the microcontroller will activate the corresponding relay to switch on the light.

  7. Device Control:

  8. The relays connected to the microcontroller act as switches for the home appliances. When the microcontroller sends a signal to a relay, it either opens or closes the circuit, thereby turning the connected device on or off.

  9. Status Display:

  10. The LCD display connected to the microcontroller shows the recognized command and the status of the appliances, providing feedback to the user.


Programming the PIC Microcontroller


The microcontroller is programmed using Embedded C or Assembly language. Below is an example of a basic code snippet in Embedded C for this project:


#include <pic16f877a.h>
#include <lcd.h> // Assumed LCD library for easy interfacing
#define RELAY1 RC0
#define RELAY2 RC1
// Function prototypes
void init_system();
void uart_init();
void uart_transmit(unsigned char data);
unsigned char uart_receive();
void process_command(unsigned char command);
void delay(unsigned int ms);
void main() {
    unsigned char command = 0;
    
    init_system();
    
    while(1) {
        command = uart_receive();
        process_command(command);
    }
}
void init_system() {
    TRISC = 0x80; // Set RC0 and RC1 as output for relays, RC7 as input for RX
    RELAY1 = 0; // Turn off relay 1
    RELAY2 = 0; // Turn off relay 2
    uart_init(); // Initialize UART for communication with voice module
    lcd_init(); // Initialize LCD
}


void uart_init() {
    SPBRG = 25; // Baud rate 9600 for 20MHz oscillator
    TXSTA = 0x20; // Enable transmitter
    RCSTA = 0x90; // Enable receiver and serial port
}
unsigned char uart_receive() {
    while(!RCIF); // Wait for data to be received
    return RCREG; // Return received byte
}
void process_command(unsigned char command) {
    lcd_clear();
    lcd_set_cursor(1,1);
    
    switch(command) {
        case '1': // Command to turn on the light
            RELAY1 = 1; // Turn on relay 1
            lcd_print("Light ON");
            break;
        case '2': // Command to turn off the light
            RELAY1 = 0; // Turn off relay 1
            lcd_print("Light OFF");
            break;
        case '3': // Command to turn on the fan
            RELAY2 = 1; // Turn on relay 2
            lcd_print("Fan ON");
            break;
        case '4': // Command to turn off the fan
            RELAY2 = 0; // Turn off relay 2
            lcd_print("Fan OFF");
            break;
        default:
            lcd_print("Invalid Cmd");
            break;
    }
    
    delay(1000); // Delay for a second
}
void delay(unsigned int ms) {
    unsigned int i, j;
    for(i = 0; i < ms; i++)
        for(j = 0; j < 1275; j++);
}

Explanation of the Code


  • TRISC: Configures the necessary pins as input or output. In this case, RC0 and RC1 are used to control the relays, while RC7 is used to receive data from the voice recognition module.

  • uart_init(): Initializes UART communication for receiving data from the voice recognition module.

  • uart_receive(): Waits for and returns a byte of data received via UART.

  • process_command(): Takes the received command and performs the corresponding action, such as turning on or off a light or fan.

  • RELAY1 and RELAY2: Represent the output pins connected to the relay module, which control the home appliances.





Advantages of a Voice Controlled Home Automation System


  • Convenience: Allows users to control appliances with simple voice commands, providing hands-free operation.

  • Accessibility: Beneficial for elderly or disabled individuals who may have difficulty using traditional switches.

  • Scalability: The system can be expanded to control multiple devices or integrated with other smart home systems.

  • Energy Efficiency: Users can easily turn off devices when not in use, potentially reducing energy consumption.


Conclusion


A voice-controlled home automation system using a PIC microcontroller is a practical and innovative project that brings the convenience of smart home technology into everyday life. By following the steps outlined in this article, you can build your own voice-controlled system to automate household appliances, making your home more efficient and user-friendly. This project demonstrates the practical application of microcontrollers in home automation and offers a foundation for more advanced smart home solutions.


Want us to guide you through your project or make the project for you ?






Create Various Projects

Check out our Free Arduino Projects Playlist - Arduino Projects 

Check out our Free Raspberry Pi Projects Playlist - Raspberry Pi Projects 

Check out our Free TinkerCAD Projects Playlist - TinkerCAD Projects 

Check out our Free IoT Projects Playlist - IoT Projects 

Check out our Free Home Automation Projects Playlist - Home Automation Projects 

Check out our Free NodeMCu Projects Playlist - NodeMCu Projects 



1 view0 comments

Related Posts

See All

Comments


bottom of page