โครงงานเครื่องตรวจจับควันบุหรี่ในห้องน้ำ
ที่มาและความสำคัญ
เนื่องจากโรงเรียนศึกษาสงเคราะห์นราธิวาส ได้มีนักเรียนบางส่วนทำผิดกฎของทางโรงเรียน มีการประพฤติตนไม่พึงประสงค์หลายประเภท เช่น การสูบบุหรี่ในห้องน้ำ ซึ่งเป็นปัญหาที่สะสมมานาน และเป็นปัญหาที่ยังแก้ไขไม่ได้ คณะครูและฝ่ายกิจการนักเรียนได้ดูแล ควบคุม และกวดขันพฤติกรรมของนักเรียนเหล่านี้มาโดยตลอด
เพื่อเป็นการรักษาภาพลักษณ์ของทางโรงเรียน ทางคณะผู้จัดทำจึงได้คิดค้นเครื่องตรวจจับควันบุหรี่ขึ้นมา โดยศึกษาและออกแบบระบบตรวจจับควันขนาดเล็ก เพื่อที่จะนำมาใช้ในการตรวจจับควันบุหรี่เป็นหลัก และทำการออกแบบเครื่องตรวจจับควัน คือ แบบใช้ LED Infrared ที่เครื่องตรวจจับควันมาประยุกต์ใช้ โดยเครื่องตรวจจับควัน จะส่งสัญญาณแจ้งเตือนไปยัง Application Line เป็นการป้องกันการสูบบุหรี่ในห้องน้ำ และรอบๆ บริเวณโรงเรียน และยังสามารถช่วยลดภาระในการดูแลของคณะครู และฝ่ายกิจการนักเรียน ตลอดจนมีการส่งข้อความและรูปภาพผ่าน Application Line ของคณะครูที่รับผิดชอบเพื่อให้สามารถรับรู้ได้ทันท่วงที
วัตถุประสงค์
1. สร้างต้นแบบเครื่องจับควันบุหรี่
2. ลดปัญหาการสูบบุหรี่
3. สามารถแจ้งเตือนผ่าน Application Line ทั้งข้อความและรูปภาพได้ทันทีเมื่อมีผู้สูบบุหรี่
วัสดุอุปกรณ์
2.Breadboard
3. ตัวต้านทาน
4. Micro SD Card
5.เซนเซอร์เสียง
6.เซนเซอร์ควัน
7.led nano
8. สายไฟจัมเปอร์
9. Camera Module
ผังโครงสร้าง
หลักการทำงาน
เมื่อเซนเซอร์ควันตรวจพบควัน ก็จะส่งสัญญาญไปยังโปรแกรมเพื่อที่จะประมวลผลและส่งกลับมาเป็นสัญญาญเสียงสัญญาญไฟกระพริบ ส่งข้อความและรูปภาพไปยังกลุ่มไลน์ที่ได้ตั้งค่าไว้
CODE คำสั่งการทำงาน
/********************************** |
* This code for detec the smoke |
* if the smoke has detected it will open |
* alarm system and sedn notify to LINE application |
*********************************/ |
//get needed library |
#include<wiringPi.h> |
#include<stdio.h> |
//pin specfication |
#defineLED0 |
#defineBUZZER1 |
#defineSMOKE4 |
#defineLINE_BUFSIZE1024 |
voidsiren(void); |
intsend_line(void); |
// main funcion |
intmain(void) |
{ |
intsensordetect = 0; // set default sensor value |
//initial device |
if(wiringPiSetup() == -1){ //when initialize wiring failed,printmessageto screen |
printf(“setup wiringPi failed !”); |
return1; |
} |
printf(“linker LedPin : GPIO %d(wiringPi pin)\n”,BUZZER); //when initialize wiring successfully,print message to screen |
//setup pin for device |
pinMode(LED, OUTPUT); |
pinMode(BUZZER, OUTPUT); |
pinMode(SMOKE, INPUT); |
//run forever |
while(1){ |
sensordetect = digitalRead(SMOKE);//คำสั่งส่ง line ไปยังโทรศัพท์ |
//printf(“sensor status : %d\n”,sensordetect); |
printf(“OK!!!\n”); |
//echo siren and show bliking led if sensor has detected ( 0 means senser has detected) |
if (sensordetect == 0) { |
printf(“hey!!! there are stududent smoking!!!\n”);ข้อความ |
siren(); |
send_line(); |
} |
} |
return0; |
} |
//make a siren sound and blinking led //คำสั่งส่งเสียง |
voidsiren(void) { |
int i; |
//generate siren low sound |
digitalWrite(LED,HIGH); |
for (i = 0; i <80; i++) // Wen a frequency sound |
{ |
digitalWrite (BUZZER, HIGH) ;// send voice//ส่งเสียง |
delay (1) ;// Delay 1ms |
digitalWrite (BUZZER, LOW) ;// do not send voice |
delay (1) ;// delay ms |
} |
digitalWrite(LED,LOW); |
//generate siren high sound |
for (i = 0; i <100; i++) // Wen Qie out another frequency sound |
{ |
digitalWrite (BUZZER, HIGH) ;// send voice |
delay (2) ;// delay 2ms |
digitalWrite (BUZZER, LOW) ;// do not send voice |
delay (2) ;// delay 2ms |
} |
} |
#!/bin/bash
raspistill –o /home/pi/smoke/smokr.jpg Convert smoke.jpg –resize 1280×962 smoke01.jpg //คำสั่งแสดงรูปภาพ Curl –x POST –H ‘Authorization: Bearer ciiGBax0ejh0mVKzIkbPagr7Z5FOMD2Zxtgyx1Hyhef’ –F ‘message=hey!!! There are student smoking’ –F ‘imageFile=@/home/pi/smoke/smoke01.jpg’ https://notify-api.line.line.me/api/notify
|
intsend_line(void) { |
char line[LINE_BUFSIZE]; |
intlinenr; |
FILE *pipe; |
/* Get a pipe where the output from the scripts comes in */ |
pipe = popen(“./sendline.sh”, “r”); |
if (pipe == NULL) { /* check for errors */ |
//perror(argv[0]); /* report error message */ |
return1; /* return with exit code indicating error */ |
} |
/* Read script output from the pipe line by line */ |
linenr = 1; |
while (fgets(line, LINE_BUFSIZE, pipe) != NULL) { |
printf(“Script output line %d: %s”, linenr, line); |
++linenr; |
} |
/* Once here, out of the loop, th
e script has ended. */ |
pclose(pipe); /* Close the pipe */ |
return0; /* return with exit code indicating success. */ |
} |
ผลของการทดสอบ
ผลของการทดสอบเครื่องตรวจจับควันบุหรี่ช่วยเพิ่มความสามารถในการนำกลับมาใช้ใหม่และใช้งานได้จริง
รูปการทำงาน
1. ทำการเข้าโปรแกรมแล้วพิมว่า cd smoke แล้วกด Enter
2. ทำการพิมคำว่า ./smoke แล้วกด Enter
3.หลังจากทำทั้ง 2 ขั้นตอนเสร็จ โปรแกรมจะแสดงว่า OK !!! หมายความว่าโปรแกรมพร้อมใช้งาน
วีดีโอผลงาน
คณะผู้จัดทำโครงงาน
1. นายเจษฎา สมใจ ชั้นมัธยมศึกษาปีที่ 6
2. นางสาวโนรอาซีกิมณ์ นาพี ชั้นมัธยมศึกษาปีที่ 6
3. นางสาวนูรอารีฟะห์ มะสะอิ ชั้นมัธยมศึกษาปีที่ 4
อาจารย์ที่ปรึกษา
1. นางสาวเปรมยุดา จันทร์เหมือน สอนวิชา คอมพิวเตอร์
โทรศัพท์ 089-2935974 E-mail premyuda2526@hotmail.com
2. นางสาวปาตีเมาะ กอและ สอนวิชา ฟิสิกส์
โทรศัพท์ 093-5826282 E-mail pamo_phy2@hotmail.com
โรงเรียนศึกษาสงเคราะห์นราธิวาส
ที่อยู่ 195/1 หมู่ที่ 9 ตำบลโละจูด อำเภอแว้ง จังหวัดนราธิวาส 96160