Nowadays most of the people have cars for daily commuting, thanks to easily available loans with variety of instalment options. With explosive growth of sales in auto sector, traffic management and parking are now two major problems especially in metropolitan cities. Leave aside the traffic problem, parking has become a great issue whether at office premises or home. One may not always find place at a parking spot and may need to manage by parking the car anywhere space available. This has lead to another problem of car theft. One’s car remains safe in a parking lot, but when parked to some distant spot, it is all vulnerable to be damaged or stolen by mischievous elements. There comes central locking system, but it only protects one’s precious vehicle from theft and not any intentional damage.
In this project, an ATMega8 based Car Anti Theft and Security System has been designed which can be installed along with the Central Locking Systems. The embedded system designed in this project equips the user with a remote car monitoring device which by default work as a digital clock and is capable of alerting the user if any mischievous element tries to damage car, try to break into doors or is somehow able to self-start the car illicitly.
The system involves two embedded device, one which has to be installed in car and other a digital clock which is at the same time a car security alert system. Both devices are built on ATMega8 microcontroller. The installable system has been designed by interfacing GY-61 Accelerometer module which can detect any jerks to the car and HC-12 Bluetooth module that makes possible communicating alert messages to remote digital clock cum car security system. The remote monitor system is built by interfacing RTC-DS1307 and 16×2 character LCD to display alert messages otherwise current date and time. The monitoring device too communicates with the installed embedded system via HC-12 Bluetooth module.
Fig. 1: Prototype of In-Car Embedded Device for Car Anti Theft and Security
Both devices have been designed on AVR ATMega8 microcontrollers and are programmed using embedded C. The code has been written, compiled and burnt to the respective systems using AVR Studio.
You may also like:
Project Source Code
//Program to /* filename : ParkedVehicleRx.C author : fhn date : 02-mar-2019 mcu : atmega8 (A) usage : to receive data through HC-12 and set alarm accordingly. else display date and time only */ #define F_CPU 1000000UL #define FCPU_BY_100 F_CPU/100 #define ON 1 #define OFF 0 #define TOGGLE 2 #define ERROR 1 #define OK #define BUTTONS_PORT PIND #define BUTTON_UP 0b10000000 #define BUTTON_NEXT 0b01000000 #define BUTTON_MUTE 0b00100000 #define BUTTON_SETTING 0b01000000 #define RTC_BIT 0b00010000 //portD #define HC12_SET 0b00000100 //portD #define BLINKER_LED 0b00100000 //portB #define BUZZER_BIT 0b00000001 //portB #define USART_MAX_RECV_BUF_SIZE 40 char USART_RECV_BUF[USART_MAX_RECV_BUF_SIZE+1]; char TEMP_STR[20]; #include#include #include #include uint8_t CURRENT_PROCESS = 0; uint8_t HC12error=0, RTCerror=0; uint8_t isUSART_DATA_READY=0; uint8_t USART_RECD_DATA_POS=0; uint8_t USART_RXD = 0; #include "FHN_LCD4_LIB.C" #include "FHN_TWI_LIB.C" #include "fhn_rtc_ds1307_lib.C" //============================================================ void initPorts ( ) { DDRB=0; DDRC=0; DDRD=0; LCD_DATA_REG |= ( LCD_DATA_BITS ); LCD_CTRL_REG |= ( LCD_ENABLE | LCD_RS ); DDRD |= 0b00000110; DDRB |= (BLINKER_LED | BUZZER_BIT); cli(); //all interrupts disabled } //============================================================ int USART_init ( ) { // INITIATES 9500-8-N-1 FORMAT UBRRL = 12; UBRRH = 0; UCSRA |= (1< '9') ch = '0'; if ( ch>'3' && pos==0 ) ch='0'; if ( ch>'1' && (pos==3 || pos==7) ) ch='0'; if ( ch>'1' && DATESTR[0]=='3' && pos==1 ) ch='0'; if ( ch>'2' && DATESTR[3]=='1' && pos==4 ) ch='0'; DATESTR[pos%10] = ch; LCD_gotoRowCol (1,1 ); LCD_writeString ( DATESTR ); } else { ch = TIMESTR[pos%10]; ch++; if (ch>'9') ch = '0'; if ( ch>'5' && (pos==13 || pos==16) ) ch='0'; if ( ch>'2' && pos==10 ) ch='0'; if ( ch>'3' && TIMESTR[0]=='2' && pos==11 ) ch='0'; TIMESTR[pos%10] = ch; LCD_gotoRowCol (2,1 ); LCD_writeString ( TIMESTR ); } } else if ( (BUTTONS_PORT & BUTTON_NEXT) == 0 ) // MOVES TO NEXT POSITION { //isEdited=1; eloop=0; pos++; if (pos>=18) pos=0; if (pos==2 || pos==5 || pos==12 || pos==15 ) pos++; if (pos==6) // for year 2000 series pos++; if (pos==7) // for year 2000 series pos++; } else { eloop++; } } // set for foolproof except Feb 29 days in leap year (alway 28 days max.) if ( isEdited==1) { if ( DATESTR[0]=='3' && DATESTR[1]>'1') { DATESTR[1]='1'; } if ( DATESTR[3]=='1' && DATESTR[4]>'2') { DATESTR[4]='2'; } if ( DATESTR[0]=='3' && DATESTR[3]=='0' && DATESTR[4]=='2') { DATESTR[0]='2'; DATESTR[1]='8'; } if ( DATESTR[0]=='3' && DATESTR[1]>'0' && DATESTR[3]=='0' &&(DATESTR[4]=='4' || DATESTR[4]=='6' || DATESTR[4]=='9' )) { DATESTR[1]='0'; } if ( DATESTR[0]=='3' && DATESTR[1]>'0' && DATESTR[3]=='1' && DATESTR[4]=='1') { DATESTR[1]='0'; } RTC_WriteDate ( DATESTR ); RTC_WriteTime ( TIMESTR ); LCD_gotoRowCol (2,11 ); LCD_writeString ("SAVED"); _delay_ms ( 2000 ); } LCD_writeCommand ( 0x0C ); } //============================================================ void clearUsartRx ( ) { USART_RECD_DATA_POS=0; isUSART_DATA_READY=0; USART_RECV_BUF[0]=0; USART_RECV_BUF[1]=0; USART_RECV_BUF[2]=0; USART_RECV_BUF[3]=0; } //============================================================ int main ( ) { uint8_t errorloop = 0; _delay_ms ( 100 ); initPorts (); _delay_ms ( 500 ); setBlinker (ON); _delay_ms ( 500 ); setBlinker (OFF); setBuzzer ( ON ); _delay_ms ( 200 ); setBuzzer ( OFF ); LCD_start ( ); _delay_ms ( 100 ); LCD_clrscr(); LCD_writeString("PARKED VEHICLE"); LCD_gotoRowCol (2, 1); LCD_writeString("MONITOR -fhn/.."); setBlinker (ON); _delay_ms ( 500 ); setBlinker (OFF); _delay_ms ( 100 ); sei(); USART_init ( ); setBlinker (ON); _delay_ms ( 500 ); setBlinker (OFF); _delay_ms ( 500 ); HC12error = HC12_start ( ); setBlinker (ON); _delay_ms ( 500 ); setBlinker (OFF); _delay_ms ( 500 ); //RTC_Start ( ); _delay_ms ( 100 ); LCD_clrscr(); if ((PIND & RTC_BIT) == 0) { LCD_writeString("BY-PASS CHECKING"); LCD_gotoRowCol (2, 1); LCD_writeString(" RTC:DS1307"); RTCerror = 5; } else { LCD_writeString("Check RTC:DS1307"); LCD_gotoRowCol (2, 1); RTCerror=RTC_getTime ( ); strcpy (TEMP_STR, TIMESTR ); if ( RTCerror ) //error LCD_writeString( "ERROR" ); else if (strcmp ( TIMESTR, "HH:MM:SS")==0) { LCD_writeString( "NOT CONNECTED" ); RTCerror = 2; } } _delay_ms ( 1500 ); LCD_clrscr(); while ( 1 ) { setBlinker ( TOGGLE ); clearUsartRx ( ); if ( (BUTTONS_PORT & BUTTON_MUTE) == 0) { errorloop=0; } if ( (BUTTONS_PORT & BUTTON_SETTING) == 0) { editDateTime(); } sendMessage ( "?" ); if (errorloop==0) { if ( RTCerror ) { LCD_gotoRowCol (1,1); LCD_writeString ("HAVE A NICE DAY "); LCD_gotoRowCol (2,1); LCD_writeString ("VEHICLE MONITOR "); _delay_ms(100); } else { RTC_getDate ( ); _delay_ms(100); LCD_gotoRowCol (1,1); LCD_writeString ("DATE: "); LCD_writeString (DATESTR); LCD_gotoRowCol (2,1); LCD_writeString ("TIME: "); RTC_getTime ( ); LCD_writeString (TIMESTR); LCD_writeString (" " ); } } _delay_ms(500); if ( isUSART_DATA_READY==1 ) { if ( USART_RECV_BUF[0] != '<' || USART_RECV_BUF[3] != '>' || (USART_RECV_BUF[1]!=USART_RECV_BUF[2]) ) { errorloop++; LCD_gotoRowCol (1,1); LCD_writeString ("WEAK SIGNAL OR "); LCD_gotoRowCol (2,1); LCD_writeString (" LONG DISTANCE"); } else if ( USART_RECV_BUF[1] != 0x80 ) { errorloop++; if ( USART_RECV_BUF[1] & 0x07 ) { LCD_gotoRowCol (1,1); LCD_writeString ("JERKS/VIBRATION/"); } if ( USART_RECV_BUF[1] & 0x38 ) { LCD_gotoRowCol (2,1); LCD_writeString ("ENGINE/KEY USED "); } } } else // signal is out of coverage { errorloop++; LCD_gotoRowCol (1,1); LCD_writeString ("NO SIGNAL. CHECK"); LCD_gotoRowCol (2,1); LCD_writeString ("VEHICLE & BOARD." ); } setBuzzer(OFF); if (errorloop>0) { _delay_ms(250); setBuzzer ( ON ); errorloop=1; } } } //============================================================ ISR ( USART_RXC_vect ) { USART_RXD = UDR; if ( USART_RECD_DATA_POS < USART_MAX_RECV_BUF_SIZE && USART_RXD>0) USART_RECV_BUF[USART_RECD_DATA_POS++] = USART_RXD; if ( USART_RECD_DATA_POS>=4 ) //( USART_RXD == '>' ) isUSART_DATA_READY=1; } //============================================================
Circuit Diagrams
Project Datasheet
Project Video
Filed Under: Electronic Projects
Filed Under: Electronic Projects
Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.