Đồng hồ kiêm trung tâm điều khiển thiết bị nhà thông minh

327 112 1
Đồng hồ kiêm trung tâm điều khiển thiết bị nhà thông minh

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

BỘ GIÁO DỤC VÀ ĐÀO TẠO TRƯỜNG ĐẠI HỌC CÔNG NGHỆ TP HỒ CHÍ MINH ĐỒ ÁN TỐT NGHIỆP ĐỒNG HỒ KIÊM TRUNG TÂM ĐIỀU KHIỂN THIẾT BỊ NHÀ THÔNG MINH Ngành: KĨ THUẬT ĐIỆN TỬ, TRUYỀN THÔNG Chuyên ngành: VIỄN THÔNG Giảng viên hướng dẫn : Nguyễn Thị Ngọc Anh Sinh viên thực : Nguyễn Đức Anh MSSV : 1311010029 Lớ : 13DDT02 TP Hồ Chí Minh, 2017 LỜI CAM ĐOAN Em xin cam đoan: Những nội dung đồ án Em thực hướng dẫn cô NGUYỄN THỊ NGỌC ANH nghiên cứu Internet, sách báo, tài liệu ngồi nước có liên quan, khơng chép hay sử dụng làm khác Mọi tham khảo dùng đồ án trích dẫn rõ ràng tên tác giả, tên cơng trình, thời gian, địa điểm cơng bố Em xin chịu hồn tồn trách nhiệm lời cam đoan trước thầy cô nhà trường TP.HCM, Tháng 12 Năm 2017 SINH VIÊN THỰC HIỆN Nguyễn Đức Anh LỜI CẢM ƠN Lời Em xin chân thành cảm ơn tất quí thầy giáo hướng dẫn bảo tận tình thời gian em làm Đồ án tốt nghiệp vừa qua, đặc biệt Viện kĩ thuật - HUTECH tạo điều kiện thuận lợi cho em hòan thành đồ án Em vơ biết ơn Cô NGUYỄN THỊ NGỌC ANH người trực tiếp hướng dẫn bảo tận tình cho em hòan thành đồ án tốt nghiệp “Đồng hồ kiêm trung tâm điều khiển thiết bị nhà thông minh” Vì lần đầu làm đồ án tốt nghiệp với kiến thức thời gian hạn chế nên không tránh khỏi nhiều sai sót, với ước mong học hỏi, em mong nhận góp ý Quý Thầy, Cô giáo bảo, hướng dẫn thêm để em rút kinh nghiệm cho đồ án em hoàn chỉnh Kính chúc Q Thầy Cơ dồi thành công công tác Em xin chân thành cảm ơn BM04/QT05/ĐT-KT Viện Kỹ thuật Hutech BẢN NHẬN XÉT CỦA GIẢNG VIÊN HƯỚNG DẪN ĐỒ ÁN/ KHÓA LUẬN TỐT NGHIỆP (GVHD nộp Bản nhận xét Văn phòng Viện) Họ tên sinh viên/ nhóm sinh viên giao đề tài (sĩ số nhóm……): (1) MSSV: ………………… Lớp: (2) MSSV: ………………… Lớp: (3) MSSV: ………………… Lớp: Ngành : Chuyên ngành : Tên đề tài: Tổng quát ĐA/KLTN: Số trang: Số chương: Số bảng số liệu: Số hình vẽ: Số tài liệu tham khảo: Phần mềm tính tốn: Số vẽ kèm theo: Hình thức vẽ: Hiện vật (sản phẩm) kèm theo: Nhận xét: a) Về tinh thần, thái độ làm việc sinh viên: BM04/QT05/ĐT-KT b) Những kết đạt ĐA/KLTN: c) Những hạn chế ĐA/KLTN: Đề nghị: Được bảo vệ (hoặc nộp ĐA/KLTN để chấm)  Không bảo vệ  TP HCM, ngày … tháng … năm ……… Giảng viên hướng dẫn (Ký ghi rõ họ tên) Ghi chú: Đính kèm Phiếu chấm điểm ĐA/KLTN BM04/QT05/ĐT-KT Viện kỹ thuật Hutech BẢN NHẬN XÉT CỦA GIẢNG VIÊN PHẢN BIỆN ĐỒ ÁN/ KHÓA LUẬN TỐT NGHIỆP (GVPB nộp Bản nhận xét Văn phòng Viện) Họ tên sinh viên/ nhóm sinh viên giao đề tài (sĩ số nhóm……): (1) MSSV: ………………… Lớp: (2) MSSV: ………………… Lớp: (3) MSSV: ………………… Lớp: Tên đề tài: Nhận xét: a) Những kết đạt ĐA/KLTN: b) Những hạn chế ĐA/KLTN: BM04/QT05/ĐT-KT Đề nghị: Được bảo vệ  Bổ sung thêm để bảo vệ  Không bảo vệ  10 Các câu hỏi sinh viên cần trả lời trước Hội đồng: (1) (2) (3) TP HCM, ngày … tháng … năm ……… Giảng viên phản biện (Ký ghi rõ họ tên) Ghi chú: Đính kèm Phiếu chấm điểm ĐA/KLTN i MỤC LỤC DANH MỤC BẢNG v DANH MỤC CÁC BIỂU ĐỒ, ĐỒ THỊ, SƠ ĐỒ, HÌNH ẢNH vi LỜI MỞ ĐẦU A Lí chọn đề tài B Tổng quan đề tài C Phương pháp nghiên cứu D Kết cấu đồ án 1.1 Tổng quan internet of thing 1.2 Ảnh hưởng ý nghĩa Internet Of Things 1.3 Cách hoạt động Internet Of Things 1.4 Ứng dụng Internet Of Things điều khiển thiết bị 2.1 Module âm Wtv020sd-16p 2.1.1 Giới thiệu Wtv020sd-16p: 2.1.2 Thông số kĩ thuật Wtv020sd-16p: 2.1.3 Tính chân: 2.2 Module RF NFR24L01 10 2.2.1 Giới thiệu NRF24L01: 10 2.2.2 Thông số kĩ thuật NRF24L01: 11 2.2.3 Chế độ phát: 11 2.2.4 Chế độ thu: 12 2.3 Module bluetooth HC-05 12 2.3.1 Giới thiệu HC-05: 12 2.3.2 Thông số kĩ thuật HC-05: 13 2.3.3 Chức chân: 14 2.4 Module wifi ESP8266 14 2.4.1 Giới thiệu ESP8266: 14 ii 2.4.2 Thông số kĩ thuật ESP8266: 15 2.5 Opamp khuếch đại âm LM386 16 2.5.1 Giới thiệu LM86: 16 2.5.2 Thông số kĩ thuật LM386: 16 2.6 Cảm biến nhiệt độ DS18B20 17 2.6.1 Giới thiệu DS18B20: 17 2.6.2 Thông số kĩ thuật DS18B20: 17 2.7 Cảm biến độ ẩm HS1101 18 2.7.1 Giới thiệu HS1101: 18 2.7.2 Thông số kĩ thuật HS1101: 19 2.8 Quang trở 19 2.8.1 Giới thiệu quang trở: 19 2.8.2 Thông số kĩ thuật HS1101: 19 2.9 PIC18F66K80 20 2.9.1 Giới thiệu PIC18F66K80: 20 2.9.2 Thông số kĩ thuật PIC18F66K80: 21 2.10 Arduino nano 22 2.10.1 Giới thiệu Arduino Nano: 22 2.10.2 Thông số kĩ thuật Arduino Nano: 22 3.1 Mục tiêu đề tài 24 3.2 Sơ đồ khối 25 3.3 Sơ đồ Nguyên lý 27 3.2.1 Khối MCU - HIỂN THỊ - NÚT NHẤN 27 3.2.1.1 LED đoạn: 30 3.2.1.2 LCD 16x2: 32 3.2.1.3 Nút nhấn: 33 3.2.2 Khối MCU - WIRELESS 34 3.2.3 Khối MCU- CẢM BIẾN – RTC 37 3.2.3.1 Cảm biến ánh sáng: 38 iii 3.2.3.2 Cảm biến nhiệt độ: 39 3.2.3.3 Cảm biến độ ẩm: 39 3.2.3.4 Mạch RTC: 41 3.2.4 Khối MCU – AUDIO 42 3.2.4.1 Modle WTV020: 44 3.2.4.2 Khuếch đại âm LM386: 44 3.2.5 Khối MCU - POWER 46 3.2.5.1 ASM117: 48 3.2.5.2 LM7805: 48 3.2.5.3 Arduino nano: 48 3.2.5.4 Pic18F66K80 I/PT: 48 3.2.6 Sơ đồ nguyên lý tổng quát 49 4.1 Lưu đồ giải thuật 52 4.1.1 Lưu đồ giải thuật chương trình 52 4.1.2 Lưu đồ giải thuật timer0 53 4.1.3 Lưu đồ giải thuật timer1 55 4.1.4 Lưu đồ giải thuật timer3 56 4.1.5 Lưu đồ giải thuật chương trình đọc độ ẩm 57 4.1.6 Lưu đồ giải thuật chương trình đọc ánh sáng 58 4.1.7 Lưu đồ giải thuật chương trình đọc nhiệt độ 59 4.1.8 Lưu đồ giải thuật chương trình cài đặt 60 4.1.9 Lưu đồ giải thuật chương trình cập nhật hình 61 4.1.10 Lưu đồ giải thuật chương trình thơng báo 62 4.1.11 Lưu đồ giải thuật chương trình RX_UART 63 4.1.12 Lưu đồ giải thuật chương trình TX_RF 64 4.1.13 Lưu đồ giải thuật chương trình cho Arduino 65 4.1.14 Lưu đồ giải thuật chương trình cho ESP8266 66 4.1.15 Lưu đồ giải thuật chương trình cho App Android 67 4.2 Mô 68 298 //Do this to read each of filled FIFO buffer stacks while(true) { while(RF24_IRQ_state()==false); //Waits for any interrupt Same as "while(!RF24_IRQ_state());" stat=RF24_get_status(); if (RF24_STATUS_TX_datasent_IRQ(stat)) break; //Fifo transfered else { //if (RF24_STATUS_MAX_retrys_reached_IRQ(stat)) { RF24_STATUS_clr_IRQs(IRQ_ALL); //Allows clearing all IRQs at the same time //RF24_comm(REUSE_TX_PL); //Reuse last transmitted payload TX payload reuse is active until W_TX_PAYLOAD or FLUSH TX is executed TX payload reuse must not be activated or deactivated during package transmission } } //You can check statistic regiters if you want to //lost=RF24_lost_packets(); //How how many packets was lost during Transmition //retrys=RF24_retry_packets(); //How how many retrys for transmit data(TX) RF24_STATUS_clr_IRQs(IRQ_ALL); at the same time // // // //Allows clearing all IRQs 299 // //now, you can write FIFO stack3, filling the last nRF24 FIFO space ret=RF24_TX_putbuffer(false,32, "La cucaracha!!, Fill FIFO Stack2"); //Transmit 32bytes data(text string) to actual address(default_config address) //Do this to read each of filled FIFO buffer stacks while(true) { while(RF24_IRQ_state()==false); //Waits for any interrupt Same as "while(!RF24_IRQ_state());" stat=RF24_get_status(); if (RF24_STATUS_TX_datasent_IRQ(stat)) break; //Fifo transfered else { //if (RF24_STATUS_MAX_retrys_reached_IRQ(stat)) { RF24_STATUS_clr_IRQs(IRQ_ALL); //Allows clearing all IRQs at the same time //RF24_comm(REUSE_TX_PL); //Reuse last transmitted payload TX payload reuse is active until W_TX_PAYLOAD or FLUSH TX is executed TX payload reuse must not be activated or deactivated during package transmission } } //You can check statistic regiters if you want to lost=RF24_lost_packets(); //How how many packets was lost during Transmition retrys=RF24_retry_packets(); transmit data(TX) //How how many retrys for 300 RF24_STATUS_clr_IRQs(IRQ_ALL); //Allows clearing all IRQs at the same time // // //You must check and clear IRQ to assert that two last packets was sent(They remain in FIFO stack) /*while(RF24_IRQ_state()==false); //Waits for any interrupt Same as "while(!RF24_IRQ_state());" RF24_STATUS_clr_IRQs(IRQ_ALL); //Allows clearing all IRQs at the same time while(RF24_IRQ_state()==false); //Waits for any interrupt Same as "while(!RF24_IRQ_state());" RF24_STATUS_clr_IRQs(IRQ_ALL); //Allows clearing all IRQs at the same time*/ /*while(true) { RF24_TX_reusebuffer(); //Retransmit last TX data present in TX buffer while(RF24_IRQ_state()==false); //Waits for any interrupt Same as "while(!RF24_IRQ_state());" RF24_STATUS_clr_IRQs(IRQ_ALL); //Allows clearing all IRQs at the same time }*/ /*stat=RF24_get_status(); if (RF24_STATUS_TX_datasent_IRQ(stat)) //return true if buffer_empty delay_ms(1); //ACK Received OK 301 if (RF24_STATUS_MAX_retrys_reached_IRQ(stat)) //return true if trnasmit error delay_ms(1); //ACK not Received lost=RF24_lost_packets(); //How how many packets was lost during Transmition retrys=RF24_retry_packets(); //How how many retrys for transmit data(TX) */ //RF24_STATUS_clr_IRQs(IRQ_ALL); //Allows clearing all IRQs at the same time //RF24_TX_reusebuffer(); //Retransmit last TX data present in TX buffer //RF24_REUSE_TX_PL(); //(do not check for errors like TX_EMPTY)Reuse last transmitted payload TX payload reuse is active until W_TX_PAYLOAD or FLUSH TX is executed TX payload reuse must not be activated or deactivated during package transmission //RF24_FLUSH_TX(); //RF24_STATUS_clr_IRQs(IRQ_ALL); //Allows clearing all IRQs at the same time //output_toggle(INDICACAO_LED); happening } }// //Show something is 302 /********************************************************** ******************************* *********************************************************** ******************************* *********************************************************** ******************************* *********************************************************** ******************************/ /********************************************************** ************************** * Driver use example 3: Transmiting data(simple withou level fifo) * * ps: At first, set nRF24L01 SPI and control PINS * Then, include driver file * Now, that´s all right * * put RF24_TX_putbuffer(true,32, " for enabling burst and reach 2Mbps * */ void RF24_driver_use_example_TXdata_simple() { this driver RF24_initPorts(); RF24_default_config(); RF24_TX_SET(); //Transmitter on //Example of using 303 while(true) { //Enter transmit mode infinitely //now, you can write FIFO stack1 RF24_TX_putbuffer(false,32, "La cucaracha!!, Fill FIFO Stack1"); //Transmit 32bytes data(text string) to actual address(default_config address) //Do this to check each data transfer while(RF24_IRQ_state()==false); //Waits for any interrupt Same as "while(!RF24_IRQ_state());" RF24_STATUS_clr_IRQs(IRQ_ALL); at the same time } }// B Code Arduino #include #include SoftwareSerial mySerial(9, 10); // RX, TX int resetPin = 5; // The pin number of the reset pin int clockPin = 4; // The pin number of the clock pin int dataPin = 3; // The pin number of the data pin int busyPin = 2; // The pin number of the busy pin int mathongbao = 199;//mathongbao setup int temp_mathongbao, capnhatmathongbao; //Allows clearing all IRQs 304 String readString; const int dkloa = 6; Wtv020sd16p wtv020sd16p(resetPin, clockPin, dataPin, busyPin); void setup() { mySerial.begin(115200); Serial.begin(115200); pinMode(dkloa, OUTPUT); digitalWrite(dkloa, HIGH); pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, LOW); wtv020sd16p.reset(); delay(2000); } void loop() { if (mySerial.available()) { mathongbao = mySerial.read(); } temp_mathongbao = capnhatmathongbao; capnhatmathongbao = mathongbao; if (temp_mathongbao != capnhatmathongbao) { digitalWrite(dkloa, LOW); 305 if (mathongbao == 74) { wtv020sd16p.asyncPlayVoice(74); } else wtv020sd16p.playVoice(mathongbao); digitalWrite(dkloa, HIGH); } while (Serial.available()) { delay(3); char c = Serial.read(); readString += c; } if (readString.length() >0) { if (readString == "batdenchuonglon") { mySerial.write('a'); } if (readString == "tatdenchuonglon") { mySerial.write('b'); } if (readString == "batdenphongkhach") { mySerial.write('c'); } 306 if (readString == "tatdenphongkhach") { mySerial.write('d'); } if (readString == "batdenphongngu") { mySerial.write('e'); } if (readString == "tatdenphongngu") { mySerial.write('f'); } readString=""; } //Serial.write(55); //mySerial.println("Hello, world?"); //delay(1000); //incomingByte = incomingByte + 1; //mySerial.println(incomingByte, DEC); //mySerial.println("Goodnight moon!"); //delay(1000); } C Code Esp8266 #include #include 307 #include #include #include const byte RX = D1; const byte TX = D2; SoftwareSerial mySerial = SoftwareSerial(RX, TX, false, 256); MDNSResponder mdns; ESP8266WebServer server(80); String webPage; const char* ssid = "TP-LINK_E632E0"; //Thay tên wifi const char* password = "99241629"; //Thay tên password // NETWORK: Static IP details IPAddress ip(192, 168, 1, 123); // where xx is the desired IP Address IPAddress gateway(192, 168, 1, 1); // set gateway to match your network IPAddress subnet(255, 255, 255, 0); // set subnet mask to match your network void setup() { webPage += ""; webPage += ""; webPage += ""; webPage += ""; webPage += ".button {"; webPage += "background-color: #FFFF00;"; 308 webPage += "border: none;"; webPage += "color: black;"; webPage += "padding: 15px 32px;"; webPage += "text-align: center;"; webPage += "text-decoration: none;"; webPage += "display: inline-block;"; webPage += "font-size: 16px;"; webPage += "margin: 4px 2px;"; webPage += "cursor: pointer;"; webPage += "}"; webPage += ""; webPage += ""; webPage += ""; webPage += "VIC"; webPage += "Đèn chuồng lợn    Bat Tat

"; webPage += "

Đèn phòng khách Bat Tat

"; webPage += "

Đèn phòng ngủ     Bat Tat

"; 309 webPage += ""; webPage += ""; //webPage += "

Đen phong khach ON OFF

"; //webPage += "

Ngày đăng: 22/10/2018, 00:18

Tài liệu cùng người dùng

Tài liệu liên quan