DIY Anti-Theft Alarm

Simple alarm designed around the dirt cheap microwave proximity sensor from China - RCWL-0516.

Schematics PCB
Schematics PCB

Charger and Boost Converter modules are those "blue" ones from AliExpress that everyone seems to be using for DIY projects nowadays.

Boost Charger
Boost Converter Battery Charger

And finally, here is the project's code.


#include <xc.h>

// Constants

#define _XTAL_FREQ 1000000

#pragma config OSC = IntRC, WDTE = OFF, MCLRE = OFF

// Functions

void beep() {
    
    __delay_ms(250);
    
    for (int i = 0; i < 100; i ++) {
        
        GP2 = 1;
        __delay_us(500);
        
        GP2 = 0;
        __delay_us(500);
        
    }
    
    __delay_ms(250);
}

void alarm() {
    
    __delay_ms(500);
    
    for (int i = 0; i < 40; i ++) {
        
        for (int i = 0; i < 500; i ++) {
            
            GP2 = 1;
            __delay_us(2000);
            
            GP2 = 0;
            __delay_us(2000);
        }
        
        __delay_ms(300);
    }
    
    __delay_ms(500);
}

// Logic

void main() {
    
    // Delay For Pickit 2
    
    __delay_ms(1000);
    
    // Oscillator Calibration
    
    CAL0  = CAL1 = CAL2 = CAL3 = CAL4 = CAL5 = 0b0;
    CAL6  = 0b1;
    FOSC4 = 0b0;
  
    // IO Preparation
    
    OPTION = 0b00000111;
    TRIS   = 0b1001;
    GP0    = 0x0;
    GP2    = 0x0;
    
    // Delay & Signal Activation
    
    beep();
    beep();
    
    __delay_ms(10000);
    
    beep();
    
    // Probe Module
    
    while (0x1) {
        
        if (GP0 == 0x1) {
            
            __delay_ms(500);
            
            if (GP0 == 0x1) {
                alarm();
            }
        }
    }
}

If you would like KiCAD symbols/footprints for the modules...send me a DM on Twitter.

Contact

If you don't want to contact me via office@djordjejocic.com, please use the form bellow. All fields are required.