Integrated Security System with Microcontroller, Serial Communication, and ASP.NET Interface

System Overview This system combines an 8051 microcontroller, infrared control, temperature sensing, and serial communication to implement a secure password-protected lock mechanism. The system architecture includes:

Password verification via keypad Infrared remote control interface Temperature monitoring using DS18B20 sensor Visual feedback through LCD and 7-segment display Alarm activation via buzzer Motor control for lock actuation

Hardware Configuration

Microcontroller Connections

Keypad - Port 0 7-segment display - Port 2 LCD interface - P2.5 (RW), P2.6 (RS), P2.7 (EP) Buzzer - P1.0 Stepper motor control - P1.2 to P1.7 Infrared sensor - P3.2 Temperature sensor (DS18B20) - P3.7

Key Software Components

Temperature Sensor Interface

void ds18b20_init() {
    DQ = 1; _nop_();
    DQ = 0; delay_us(480);
    DQ = 1; delay_us(80);
    // Verify presence pulse
}

unsigned char ds_read_byte() {
    unsigned char i, value = 0;
    for (i = 0; i < 8; i++) {
        DQ = 0; value >>= 1; DQ = 1;
        if (DQ) value |= 0x80;
        delay_us(2);
    }
    return value;
}

int get_temperature() {
    unsigned char low, high;
    ds18b20_init();
    ds_write_byte(0xCC); // Skip ROM
    ds_write_byte(0x44); // Start conversion
    delay_ms(750);
    
    ds18b20_init();
    ds_write_byte(0xCC);
    ds_write_byte(0xBE); // Read scratchpad
    
    low = ds_read_byte();
    high = ds_read_byte();
    
    return ((high * 256 + low) * 62.5);
}

LCD Display Management

bit lcd_busy_check() {
    LCD_RS = 0; LCD_RW = 1; LCD_EP = 1;
    bit result = (P0 & 0x80);
    LCD_EP = 0;
    return result;
}

void lcd_command(unsigned char cmd) {
    while (lcd_busy_check());
    LCD_RS = 0; LCD_RW = 0;
    P0 = cmd; LCD_EP = 1; _nop_(); LCD_EP = 0;
}

void lcd_write_char(unsigned char data) {
    while (lcd_busy_check());
    LCD_RS = 1; LCD_RW = 0;
    P0 = data; LCD_EP = 1; _nop_(); LCD_EP = 0;
}

Serial Communication

void serial_init() {
    SCON = 0x50; // 8-bit, variable baud
    PCON |= 0x80; // Double baud rate
    TMOD |= 0x20; // Timer 1, mode 2
    TH1 = 0xF3; TL1 = 0xF3; // 4800 baud at 12MHz
    TR1 = 1; 
    ES = 1; EA = 1; // Enable serial and global interrupts
}

void send_byte(char data) {
    SBUF = data;
    while (!TI);
    TI = 0;
}

Infrared Remote Handling

void ir_interrupt() interrupt 0 {
    // Signal decoding logic
    if (validate_ir_signal()) {
        decode_ir_data();
        process_ir_command();
    }
}

System Operation The system operates in multiple modes selected through serial communication:

Password Lock Mode Hendles keypad input verification and motor control for lock mechanism

Temperature Monitoring Dsiplays real-time temperature on LCD with DS18B20 sensor

Infrared Control Processes remote control commands for system configuration

The system provides audio feedback through the buzzer for successful operations or invalid attempts.

Tags: 8051-microcontroller serial-communication ds18b20 lcd-interface infrared-control

Posted on Tue, 29 Sep 2026 16:30:12 +0000 by swampster