Bu konumuzda SMS alarmlı, PIR sensör tabanlı hırsız alarm sisteminin nasıl yapılacağını anlatacağız.
Bu devre, PIR sensörü kullanarak hareketi algılar ve belirlenmiş mobil telefona SMS yollar. Aynı zamanda LCD displayde hareketin meydana geldiği yerin numarası da görünür. Bu devrede 8051 mikrodenetleyicisi PIR sensörü izlemek ve GSM modülü üzerinden SMS yollamak için kullanılıyor. Hareket algılandığında aynı zamanda bir alarm da çalmaya başlıyor.
PIR sensör.
PIR sensör pasif bir infrared (kızılötesi) sensör çeşididir. Bir kaynaktan gelen IR (infrared) ışını algılamak ve ölçmek için kullanılır. PIR sensörlerde algılama kısmında, Galyum Nitrid denilen bir piroelektrik malzeme kullanılır. Basitçe anlatmaya çalışırsak; PIR sensörü üzerine düşen ışın miktarına bağlı olarak bir elektriksel çıkış üretir. Dışarıda, IR ışınlarını sensör yüzüne odaklamak için, kafes formunda bir fresnel lens kullanılır. PIR sensörünün önünde bir hareket meydana geldiği anda, PIR sensörünün üzerine düşen IR radyasyon yoğunluğu değişir ve elektriksel bir çıkış üretilir. Sensörün içindeki elektronik devre, değişikliği tespit eder ve çıkış pinini HIGH yapar. 8051 ile PIR sensörünün nasıl kullanıldığını öğrenmek için şu makaleyi okuyabilirsiniz.
GSM Module.
GSM (Global Systems fro Mobile communication) mödülü, içine SİM kart konulabilen ve GSM ağında çalışabilen bir araçtır. Bir çok şey yapabilir: Mesaj gönderebilir, mesaj alabilir, telefon numarasını arayabilir, çağrı alabilir, sesli mesaj alabilir veya gönderebilir, dijital medya gönderebilir. Basitçe, bir GSM modülü, Ağ servis sağlayıcının ve modülün desteklediği bir çok görevi yapabilir. GSM modülü bir cep telefonu gibi kullanılabilir. GSM modülünün en yaygın kullanımı, bir makinayı uzaktan çalıştırmak, sesli mail göndermek gibi uygulamalardır.
Bu uygulamada kullanılan SIM900A GSM chip’inin 8051 ile nasıl kullanıldığını öğrenmek için şu makaleyi okuyunuz.
Elektronik Devre Şeması:
GSM modülü 8051 ile seri iletişim ile haberleşiyor. GSM modülünün Tx pini mikrodenetleyicinin Rx pinine (pin10) bağlanacak. GSM modülünün Rx pini ise mikrodenetleyicinin Tx pinine bağlanacak. PIR sensörünün çıkış pini, mikrodenetleyicinin p3.5 pinine bağlanacak. LCD modülünün data pinleri (D0—D7) , mikrodenetleyicinin PORT0’ına bağlanacak. PORT0’ın her pini 10k dirençle pull up yapılacak. 8051’in port0’ı açık draindir ve internal pull up dirençleri yoktur. bu yüzden ayrıca pull up dirençlerine gerek vardır.Bu uygulamada LCD modül olarak JHD162A kullanılıyor. R4 direnci LCD’nin kontrastını ayarlamak için kullanılır.R5 direnci ise display’in arka ışık ledinin akımını sınırlandırmak için kullanılıyor.
S2 butonu, C11 kondansatörü ve R6 direnci, reset devresini oluşturuyor. C11 butonun yerinde çalışması için(bounce durumu) kullanılır. Butona basarken meydana gelen titreşimleri elemine eder. X1 kristali ve c8,c10 kondansatörleri, saat devresinde kullanılıyor. Seri iletişimin baud rate oranı 9600dür. Bu yüzden kristalin tam olarak frekansı, 11.0592 MHz olmalı.
Mikrodenetleyicinin Port 2,0 kısmı alarmı kontrol etmek için kullanılır. Röle Q1 transistörünün kollektörüne bağlanır. Röle anahtarlandığında oluşacak emf leri ise D5 diyodu by-pass edecektir. Aksi halde geri emf’ler transistörü hatta mikrodenetleyiciyi bile bozar. 12V röle, rölenin normalde açık kontağı ile bağlanır.
Program.
PIR EQU P3.5 //equates P3.5 to PIR RS EQU P2.7 //equates P2.7 to RS RW EQU P2.6 //equates P2.6 to RW E EQU P2.5 //equates P2.5 ot E ORG 00H //origin MOV TMOD,#00100001B //Timer1=Mode2 timer & Timer0=Mode1 timer MOV TH1,#253D //loads Th1 with 253D (9600 baud) MOV SCON,#50H //sets serial port to Mode1 and receiver enabled SETB TR1 //starts Timer1 MOV DPTR,#LUT //loads DPTR with starting address of LUT SETB P3.5 //sets P3.5 as input port for PIR sensor CLR P2.0 //sets 2.0 as output port for alarm MOV R7,#00D //loads R7 with 00D MAIN:ACALL DINT //calls DINT subroutine ACALL TEXT1 //calls TEXT1 subroutine ACALL LINE2 //calls LINE2 subroutine ACALL TEXT2 //calls TEXT2 subroutine ACALL TEXT3 //calls TEXT3 subroutine ACALL SPLIT //calls SPLIT subroutine ACALL NUM //calls NUM subroutine HERE:JNB PIR,HERE //loops here until PIR output is HIGH SETB P2.0 //sets P2.0 (alarm ON) INC R7 //increments R7 (No: of intrusions) ACALL DINT //calls DINT subroutine ACALL TEXT1 //calls TEXT1 subroutine ACALL LINE2 //calls LINE2 subroutine ACALL TEXT4 //calls TEXT4 subroutine ACALL TEXT3 //calls TEXT3 subroutine ACALL SPLIT //calls SPLIT subroutine ACALL NUM //calls NUM subroutine ACALL SMS //calls SMS subroutine HERE1:JB PIR,HERE1 //loops here PIR output is LOW CLR P2.0 //clears P2.0 (alarm OFF) SJMP MAIN //jumps to MAIN loop SMS:MOV A,#"A" //ascii of A ACALL SEND //sends the ascii code to GSM MOV A,#"T" //ascii of T ACALL SEND //sends the ascii code to GSM MOV A,#0DH //ascii of /r ACALL SEND //sends the ascii code to GSM ACALL DELAY1 //calls DELAY1 (1S) MOV A,#"A" //ascii of A ACALL SEND //sends the ascii code to GSM MOV A,#"T" //ascii of T ACALL SEND //sends the ascii code to GSM MOV A,#"+" //ascii of + ACALL SEND //sends the ascii code to GSM MOV A,#"C" //ascii of C ACALL SEND //sends the ascii code to GSM MOV A,#"M" //ascii of M ACALL SEND //sends the ascii code to GSM MOV A,#"G" //ascii of G ACALL SEND //sends the ascii code to GSM MOV A,#"F" //ascii of F ACALL SEND //sends the ascii code to GSM MOV A,#"=" //ascii of = ACALL SEND //sends the ascii code to GSM MOV A,#"1" //ascii of 1 ACALL SEND //sends the ascii code to GSM MOV A,#0DH //ascii of /r ACALL SEND //sends the ascii code to GSM ACALL DELAY1 //calls DELAY1 (1S) MOV A,#"A" //ascii of A ACALL SEND //sends the ascii code to GSM MOV A,#"T" //ascii of T ACALL SEND //sends the ascii code to GSM MOV A,#"+" //ascii of + ACALL SEND //sends the ascii code to GSM MOV A,#"C" //ascii of C ACALL SEND //sends the ascii code to GSM MOV A,#"M" //ascii of M ACALL SEND //sends the ascii code to GSM MOV A,#"G" //ascii of G ACALL SEND //sends the ascii code to GSM MOV A,#"S" //ascii of S ACALL SEND //sends the ascii code to GSM MOV A,#"=" //ascii of = ACALL SEND //sends the ascii code to GSM MOV A,#34D //ascii of " ACALL SEND //sends the ascii code to GSM MOV A,#"+" //ascii of + ACALL SEND //sends the ascii code to GSM MOV A,#"9" //ascii of 9 ACALL SEND //sends the ascii code to GSM MOV A,#"1" //ascii of 1 ACALL SEND //sends the ascii code to GSM MOV A,#"9" //ascii of 9 ACALL SEND //sends the ascii code to GSM MOV A,#"5" //ascii of 5 ACALL SEND //sends the ascii code to GSM MOV A,#"4" //ascii of 4 ACALL SEND //sends the ascii code to GSM MOV A,#"4" //ascii of 4 ACALL SEND //sends the ascii code to GSM MOV A,#"7" //ascii of 7 ACALL SEND //sends the ascii code to GSM MOV A,#"9" //ascii of 9 ACALL SEND //sends the ascii code to GSM MOV A,#"0" //ascii of 0 ACALL SEND //sends the ascii code to GSM MOV A,#"7" //ascii of 7 ACALL SEND //sends the ascii code to GSM MOV A,#"9" //ascii of 9 ACALL SEND //sends the ascii code to GSM MOV A,#"3" //ascii of 3 ACALL SEND //sends the ascii code to GSM MOV A,#34D //ascii of " ACALL SEND //sends the ascii code to GSM MOV A,#0DH //ascii of /r ACALL SEND //sends the ascii code to GSM ACALL DELAY1 //calls DELAY1 (1S) MOV A,#"I" //ascii of I ACALL SEND //sends the ascii code to GSM MOV A,#"n" //ascii of n ACALL SEND //sends the ascii code to GSM MOV A,#"t" //ascii of t ACALL SEND //sends the ascii code to GSM MOV A,#"r" //ascii of r ACALL SEND //sends the ascii code to GSM MOV A,#"u" //ascii of u ACALL SEND //sends the ascii code to GSM MOV A,#"d" //ascii of d ACALL SEND //sends the ascii code to GSM MOV A,#"e" //ascii of e ACALL SEND //sends the ascii code to GSM MOV A,#"r" //ascii of r ACALL SEND //sends the ascii code to GSM MOV A,#"!" //ascii of ! ACALL SEND //sends the ascii code to GSM MOV A,#"!" //ascii of ! ACALL SEND //sends the ascii code to GSM ACALL DELAY1 //calls DELAY1 (1S) MOV A,#1AH //ascii of CTRL+Z ACALL SEND //sends the ascii code to GSM ACALL DELAY1 //calls DELAY1 (1S) RET //returns from subroutine SEND:CLR TI //clears TI flag of SCON MOV SBUF,A //moves value in A to SBUF register WAIT:JNB TI,WAIT //waits here until TI flag is set RET //returns from subroutine SPLIT:MOV A,R7 //moves the value in R7 to A MOV B,#10D //loads B with 10D DIV AB //divides A with B MOV R6,B //moves the remainder to R6 MOV B,#10D //loads B with 10D DIV AB //divides A with B MOV R5,B //moves the remainder to R5 MOV R4,B //moves the quotient to R4 RET //returns from subroutine TEXT1: MOV A,#"I" //ascii of I ACALL DISPLAY //calls DISPLAY subroutine MOV A,#"N" //ascii of N ACALL DISPLAY //calls DISPLAY subroutine MOV A,#"T" //ascii of T ACALL DISPLAY //calls DISPLAY subroutine MOV A,#"R" //ascii of R ACALL DISPLAY //calls DISPLAY subroutine MOV A,#"U" //ascii of U ACALL DISPLAY //calls DISPLAY subroutine MOV A,#"D" //ascii of D ACALL DISPLAY //calls DISPLAY subroutine MOV A,#"E" //ascii of E ACALL DISPLAY //calls DISPLAY subroutine MOV A,#"R" //ascii of R ACALL DISPLAY //calls DISPLAY subroutine MOV A,#" " //ascii of SPACE ACALL DISPLAY //calls DISPLAY subroutine MOV A,#"A" //ascii of A ACALL DISPLAY //calls DISPLAY subroutine MOV A,#"L" //ascii of L ACALL DISPLAY //calls DISPLAY subroutine MOV A,#"A" //ascii of A ACALL DISPLAY //calls DISPLAY subroutine MOV A,#"R" //ascii of R ACALL DISPLAY //calls DISPLAY subroutine MOV A,#"M" //ascii of M ACALL DISPLAY //calls DISPLAY subroutine RET //return from subroutine TEXT2: MOV A,#"S" //ascii of S ACALL DISPLAY //calls DISPLAY subroutine MOV A,#"C" //ascii of C ACALL DISPLAY //calls DISPLAY subroutine MOV A,#"A" //ascii of A ACALL DISPLAY //calls DISPLAY subroutine MOV A,#"N" //ascii of N ACALL DISPLAY //calls DISPLAY subroutine MOV A,#"I" //ascii of I ACALL DISPLAY //calls DISPLAY subroutine MOV A,#"N" //ascii of N ACALL DISPLAY //calls DISPLAY subroutine MOV A,#"G" //ascii of G ACALL DISPLAY //calls DISPLAY subroutine MOV A,#"." //ascii of . ACALL DISPLAY //calls DISPLAY subroutine MOV A,#"." //ascii of . ACALL DISPLAY //calls DISPLAY subroutine RET //return from subroutine TEXT3: MOV A,#"I" //ascii of I ACALL DISPLAY //calls DISPLAY subroutine MOV A,#"N" //ascii of N ACALL DISPLAY //calls DISPLAY subroutine MOV A,#"T" //ascii of T ACALL DISPLAY //calls DISPLAY subroutine MOV A,#"R" //ascii of R ACALL DISPLAY //calls DISPLAY subroutine RET //return from subroutine TEXT4: MOV A,#"A" //ascii of A ACALL DISPLAY //calls DISPLAY subroutine MOV A,#"L" //ascii of L ACALL DISPLAY //calls DISPLAY subroutine MOV A,#"E" //ascii of E ACALL DISPLAY //calls DISPLAY subroutine MOV A,#"R" //ascii of R ACALL DISPLAY //calls DISPLAY subroutine MOV A,#"T" //ascii of T ACALL DISPLAY //calls DISPLAY subroutine MOV A,#"!" //ascii of ! ACALL DISPLAY //calls DISPLAY subroutine MOV A,#"!" //ascii of ! ACALL DISPLAY //calls DISPLAY subroutine MOV A,#"!" //ascii of ! ACALL DISPLAY //calls DISPLAY subroutine MOV A,#"!" //ascii of ! ACALL DISPLAY //calls DISPLAY subroutine RET //return from subroutine NUM:MOV A,R4 //moves 1st digit to A ACALL ASCII //calls ASCII subroutine ACALL DISPLAY //calls DISPLAY subroutine MOV A,R5 //moves 2nd digit to A ACALL ASCII //calls ASCII subroutine ACALL DISPLAY //calls DISPLAY subroutine MOV A,R6 //moves last digit to A ACALL ASCII //calls ASCII subroutine ACALL DISPLAY //calls DISPLAY subroutine RET //return subroutine DINT:MOV A,#0FH //loads a with 0FH ACALL CMD //calls CMD subroutine MOV A,#01H //loads a with 01H ACALL CMD //calls CMD subroutine MOV A,#06H //loads a with 06H ACALL CMD //calls CMD subroutine MOV A,#81H //loads a with 81H ACALL CMD //calls CMD subroutine MOV A,#3CH //loads a with 3CH ACALL CMD //calls CMD subroutine RET //return from subroutine LINE2:MOV A,#0C0H //loads a with 0C0H ACALL CMD //calls CMD subroutine RET //return from subroutine CMD: MOV P0,A //loads P0 with A CLR RS //clears RS pin CLR RW //clears RW pin SETB E //sets E pin CLR E //clears E pin ACALL DELAY //calls DELAY subroutine RET //return from subroutine DISPLAY:MOV P0,A //loads P0 with A SETB RS //sets RS pin CLR RW //clears RW pin SETB E //sets E pin CLR E //clears E pin ACALL DELAY //calls DELAY subroutine RET //return from subroutine DELAY1:MOV R6,#15D //loads R6 with 15D BACK: MOV TH0,#00000000B //loads TH0 with 00B MOV TL0,#00000000B //loads TH0 with 00B SETB TR0 //starts Timer 0 HERE2: JNB TF0,HERE2 //loops here until TF0 is set (roll over) CLR TR0 //stops Timer 0 CLR TF0 //clears TF0 DJNZ R6,BACK //jumps to BACK label (loops 15 times) RET //return from subroutine DELAY: CLR E //clears E CLR RS //clears RS SETB RW //sets RW MOV P0,#0FFh //writes P0 with all 1's SETB E //sets E MOV A,P0 //moves P0 to A JB ACC.7,DELAY //jumps to label DELAY when ACC.7 is set CLR E //clears E CLR RW //clears RW RET //return from subroutine ASCII: MOVC A,@A+DPTR //overwrites A with ascii of data in A RET //return from subroutine LUT: DB 48D //ascii of 0 DB 49D //ascii of 1 DB 50D //ascii of 2 DB 51D //ascii of 3 DB 52D //ascii of 4 DB 53D //ascii of 5 DB 54D //ascii of 6 DB 55D //ascii of 7 DB 56D //ascii of 8 DB 57D //ascii of 9 END //END statement
Notlar.
- GSM modülü piyasada değişik besleme gerilimleriyle bulunur. (12V,9V,5V gibi). Bu devrede 12V DC modül kullanılıyor. Bu yüzden GSM modülünüzü doğru besleme geriliminde kullandığınızdan emin olunuz.
- Bütün ground uçlarının birlikte kısa devre edildiğinden emin olun. (GSM modül, PIR sensör ve devrenin geri kalanı)
- Kolay gelsin. Yorum yapmayı unutmayın… 🙂