1. Trang chủ
  2. » Luận Văn - Báo Cáo

luận văn thạc sĩ nghiên cứu thiết kế hệ thống giám sát và cảnh báo sức khỏe ứng dụng công nghệ iot

134 3 0

Đ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 QUY NHƠN NGÔ VĂN TÂM NGHIÊN CỨU, THIẾT KẾ HỆ THỐNG GIÁM SÁT VÀ CẢNH BÁO SỨC KHỎE ỨNG DỤNG CÔNG NGHỆ IOT LUẬN VĂN THẠC SỸ KỸ THUẬT VIỄN THÔNG Bình Định - Năm 2021 download by : skknchat@gmail.com BỘ GIÁO DỤC VÀ ĐÀO TẠO TRƯỜNG ĐẠI HỌC QUY NHƠN NGÔ VĂN TÂM NGHIÊN CỨU, THIẾT KẾ HỆ THỐNG GIÁM SÁT VÀ CẢNH BÁO SỨC KHỎE ỨNG DỤNG CÔNG NGHỆ IOT Chuyên ngành: Kỹ thuật viễn thông Mã số: 8520208 Người hướng dẫn: TS Nguyễn Đức Thiện download by : skknchat@gmail.com LỜI CAM ĐOAN Tôi xin cam đoan cơng trình nghiên cứu tơi, có hỗ trợ từ Thầy hướng dẫn cá nhân, tập thể cảm ơn Các nội dung nghiên cứu kết đề tài trung thực chưa công bố cơng trình Bình Định, ngày tháng TÁC GIẢ Ngơ Văn Tâm download by : skknchat@gmail.com năm 2021 LỜI CẢM ƠN Trong thời gian nghiên cứu thực luận văn này, nhận giúp đỡ nhiệt tình tổ chức cá nhân Tơi xin bày tỏ lời cảm ơn sâu sắc tới tất tập thể cá nhân tạo điều kiện giúp đỡ tơi suốt q trình thực nghiên cứu luận văn Trước hết xin chân thành cảm ơn quý Thầy, Cô Khoa Kỹ thuật & Công nghệ, Trường Đại học Quy Nhơn, đặc biệt quý Thầy, Cô môn Điện tử - Viễn thông trang bị cung cấp kiến thức giúp đỡ tơi suốt q trình học tập vừa qua Tôi xin chân thành cảm ơn Quỹ Đổi sáng tạo VinIF, Viện Nghiên cứu Dữ liệu lớn VinBigData, Tập đồn Vingroup tài trợ kinh phí cho nghiên cứu Với lịng biết ơn sâu sắc, tơi xin trân trọng cảm ơn TS Nguyễn Đức Thiện trực tiếp hướng dẫn khoa học giúp đỡ suốt q trình nghiên cứu hồn thành luận văn Xin chân thành cảm ơn tất bạn bè, đồng nghiệp động viên, giúp đỡ nhiệt tình đóng góp nhiều ý kiến q báu để tơi hồn thành luận văn Do thời gian nghiên cứu có hạn, luận văn tơi chắn khơng thể tránh khỏi thiếu sót Tơi mong nhận đóng góp, giúp đỡ q Thầy Cơ giáo toàn thể bạn đọc Trân trọng cảm ơn! Bình Định, ngày tháng TÁC GIẢ Ngơ Văn Tâm download by : skknchat@gmail.com năm 2021 i MỤC LỤC LỜI CAM ĐOAN LỜI CẢM ƠN MỤC LỤ C i DANH MỤC CHỮ VIẾT T Ắ T vi DANH MỤC HÌNH Ả N H xi DANH MỤC BẢNG B IỂ U xiii MỞ Đ Ầ U 1 Lý chọn đề tài T quan tình hình nghiên u Mục đích nhiệm vụ nghiên cứu 4 3.1 Mục đích nghiên cứu 3.2 Nhiệm vụ nghiên c ứ u Đối tượng phạm vi nghiên cứu 4.1 Đối tượng nghiên u 4.2 Phạm vi nghiên c ứ u 5 Phương pháp nghiên c ứ u Cấu trúc trình bày nội dung luận văn .5 CHƯƠNG TỔNG QUAN VỀ CÔNG NGHỆ IO T 1.1 Giới thiệu chương .6 1.2 Khái niệm Io T 1.3 Kiến trúc hệ thống IoT 1.4 Hệ sinh thái IoT 1.5 Các yêu cầu Io T 1.5.1 Nhận thức lượng hiệu suất lư ợng 1.5.2 Chất lượng dịch vụ 10 1.5.3 Bảo m ậ t 10 1.5.4 Sự tương thích 11 1.5.5 Quản lý can nhiễu .11 download by : skknchat@gmail.com ii 1.6 Các công nghệ truyền dẫn Io T .11 1.6.1 Bluetooth 12 1.6.2 Z igB ee 12 1.6.3 WiFi 12 1.6.4 L oR a 12 1.7 Các ứng dụng IoT 13 1.7.1 Nhà thông m inh 13 1.7.2 Thành p h ố thông m inh 14 1.7.3 Năng lượng thông m in h 14 1.7.4 Sức khỏe thông m inh 15 1.7.5 Cuộc sống thông m in h 15 1.7.6 Giao thông thông m in h 15 1.8 Tình hình triển khai IoT Thế giới Việt N a m 16 1.8.1 Trên Thế giới 16 1.8.2 Tại Việt N a m 17 1.9 Kết luận chương 18 CHƯƠNG ỨNG DỤNG IOT TRONG LĨNH VỰC c h ă m s ó c s ứ c KHỎE 19 2.1 Giới thiệu chương 19 2.2 Vai trị cơng nghệ IoT lĩnh vực chăm sóc sức khỏe (CSSK) 19 2.3 Kiến trúc hệ thống IoT C S S K 20 2.3.1 Lớp cảm biến .20 2.3.2 Lớp truyền thông 21 2.3.3 Lớp điện toán đám mây 21 2.4 Các yêu cầu thách thức triển khai IoT CSSK 21 2.4.1 Thách thức thiết k ế 22 2.4.2 Quản lý liệu 22 2.4.3 Khả mở rộn g .24 2.4.4 Khả tương tác, tiêu chuẩn hóa vấn đề quy định 25 download by : skknchat@gmail.com iii 2.4.5 Giao diện yếu tố người 25 2.4.6 Vấn đề bảo mật riêng tư 25 2.5 Các ứng dụng IoT lĩnh vực chăm sóc sức k h ỏ e 26 2.5.1 mHealth 26 2.5.2 Ứng dụng IoT môi trường sống hỗ trợ 26 2.5.3 Ứng dụng IoT ngành dược p h ẩ m 27 2.5.4 Ứng dụng IoT cho người khuyết tậ t 27 2.5.5 Ứng dụng IoT y sinh cấy g h é p 27 2.5.6 Ứng dụng IoT cảnh báo sớm phát hiệnbất thường 28 2.5.7 Ứng dụng IoT quản lý sức khỏe dân số 28 2.6 Kết luận chương 28 CHƯƠNG THU THẬP DỮ LIỆU SỨC KHỎE TỪ X A 29 3.1 Giới thiệu chương .29 3.2 Mơ hình hệ thống thu thập liệu sức khỏe từ x a 29 3.2.1 Thu thập liệu sức khỏe từ x a 30 3.2.2 Công nghệ truyền thông .33 3.3 Thiết kế phần cứng 37 3.3.1 Khối cảm biến Sensor N ode 37 3.3.2 Khối Gateway xử lý trung tâ m 38 3.4 Thiết kế phần mềm 39 3.4.1 Tổng quan tảng mã nguồn mở Thingsboard 39 3.4.2 Giao thức M Q TT 41 3.4.3 Các lưu đồ thuật to n 41 3.5 Kết luận chương 43 CHƯƠNG HỌC MÁY VÀ ỨNG DỤNG TRONG LĨNH V ự c CHĂM SÓC SỨC K H Ỏ E ’ 44 4.1 Giới thiệu chương .44 4.2 Tổng quan học máy ứng dụng lĩnh vực CSSK 44 4.2.1 Tổng quan học m y 44 download by : skknchat@gmail.com iv 4.2.2 Ứng dụng học máy lĩnh vực chăm sóc sức khỏe 46 4.3 Ứng dụng số thuật toán ML hệ thống CSSK đề x u ấ t 47 4.3.1 Thuật toán K N N 47 4.3.2 Thuật toán Decision T ree 48 4.3.3 Thuật toán Hồi quy L ogistic 48 4.3.4 Thuật toán S V M 49 4.3.5 Thuật toán Random F orest 50 4.3.6 Thuật tốn Nạve B ayes .51 4.4 Bộ liệu Kaggle cho bệnh tim mạch 52 4.5 Các phương pháp đánh giá mơ hình phân lớ p 55 4.5.1 Độ xác (Accuracy) 55 4.5.2 Ma trận nhầm lẫn (Confusion matrix) 55 4.5.3 Đường cong ROC (Receiver Operating Characteristic curve) 56 4.5.4 Diện tích đường cong ROC - A UC (Area Under the Curve) 57 4.5.5 Precision and R ecall 57 4.5.6 F l-sco re 57 4.6 Kết luận chương 58 CHƯƠNG TRIỂN KHAI VÀ ĐÁNH GIÁ HỆ THỐNG 59 5.1 Giới thiệu chương .59 5.2 Triển khai thực t ế 59 5.3 Kết thực h iện 60 5.3.1 Đánh giá hiệu hệ thống 60 5.3.2 Trực quan hóa liệu cảnh báo 61 5.3.3 Khai phá liệu Kaggle dataset 63 5.4 Đánh giá hệ thống .68 5.4.1 Đánh giá sai số hệ thống 68 5.4.2 Đánh giá mơ hình phân lớp dự đốn bệnh tim 69 5.5 Kết luận chương 71 KẾT LUẬN VÀ KIẾN NGHỊ 72 download by : skknchat@gmail.com luan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iot v DANH MỤC CƠNG TRÌNH KHOA HỌC ĐÃ CÔNG BỐ CỦA TÁC GIẢ73 DANH MỤC TÀI LIỆU THAM KHẢO 74 PHỤ L Ụ C 92 QUYẾT ĐỊNH GIAO ĐỀ TÀI LUẬN VĂN luan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iot download by : skknchat@gmail.com luan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iot vi DANH MỤC CHỮ VIẾT TẮT Từ viết tắt Nghĩa tiếng Anh Nghĩa tiếng Việt 2G 2th Generation Thế hệ thứ hai 3G 3th Generation Thế hệ thứ ba 4G 4th Generation Thế hệ thứ tư 5G 5th Generation Thế hệ thứ năm A AI Artificial Intelligence Trí tuệ nhân tạo API Application Programming Interface Giao diện lập trình ứng dụng ASL American Sign Language Ngôn ngữ ký hiệu Hoa Kỳ AUC Area Under the Curve Diện tích đường cong B BKAV Bach Khoa Antivirus Bách Khoa Antivirus BLE Bluetooth Low Energy Bluetooth lượng thấp BW Bandwidth Băng thông BYT Bộ Y tế C CART Classification And Regression Tree Cây phân loại hồi quy CoAP Constrained Application Protocol Giao thức ứng dụng ràng buộc CR Coding Rate Tỉ lệ mã hóa CSS Chirp Spread Spectrum Kỹ thuật trải phổ Chirp CSSK Chăm sóc sức khỏe luan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iot download by : skknchat@gmail.com luan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iot 103 w h ile (¡S e ria l); S P I.b e g in (5 ,1 ,2 ,1 ); L o R a s e tP in s (S S ,R S T ,D I0 ); i f (!L o R a b e g in (B A N D )) { w h ile (1); } S e ria l.p rin t(" In itia liz in g S D c a rd "); p in M o d e (S S , O U T P U T ); i f (!S D b e g in (1 , 2, , )) { S e ria l.p rin tln (" in itia liz a tio n fa ile d !"); re tu rn ; } S e ria l.p rin tln (" c a rd in itia liz e d "); s e n s o rD a ta = S D o p e n (" A u to c sv " , F IL E _ W R IT E ); se n s o rD a ta p rin tln (" D a te , T im e , H e a rtR a te (b p m ), S p O (% ), E C G (m V )"); se n so rD a ta c lo s e (); s e n s o rD a ta = S D o p e n (" M a n u a l.c sv " , F IL E _ W R IT E ); se n s o rD a ta p rin tln (" D a te , T im e , H e a rtR a te (b p m ), S p O (% ), E C G (m V )"); se n so rD a ta c lo s e (); s e n s o rD a ta = S D o p e n (" d a ta E C G c s v " , F IL E _ W R IT E ); se n s o rD a ta p rin tln (" D a te , T im e , E C G (m V )" ); se n so rD a ta c lo s e (); W iF i.d isc o n n e c t(); } v o id lo o p () { p o x u p d a te (); luan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iot download by : skknchat@gmail.com luan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iot 104 b u tto n S ta te = d ig ita lR e a d (b u tto n P in ); i f (b u tto n S ta te != la s tB u tto n S ta te ) { i f (b u tto n S ta te = = L O W ) { b u tto n P u s h C o u n te r+ + ; S e ria l.p rin tln (MD a n g n h a n "); S e ria l.p rin tln (" S o la n n h an : "); S e ria l.p rin tln (b u tto n P u sh C o u n te r); d e la y (1 0 ); } else { S e ria l.p rin tln (" o ff'); } } la s tB u tto n S ta te = b u tto n S ta te ; p o x u p d a te (); b u tto n S ta te _ = d ig ita lR e a d (K h a n P in ); i f (b u tto n S ta te _ != la s tB u tto n S ta te _ ) { i f (b u tto n S ta te _ = = L O W ) { K h a n c a p (); } else { luan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iot download by : skknchat@gmail.com luan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iot 105 d ig ita lW rite (L O A , L O W ); S e ria l.p rin tln (Mo ff"); } } la s tB u tto n S ta te _ = b u tto n S ta te _ ; i f (b u tto n P u s h C o u n te r= = ) { p o x b e g in (); p o x u p d a te (); d is p la y d isp la y O n (); d isp la y c le a r(); d isp la y s e tF o n t(A ria lM T _ P la in _ 0); d is p la y d w S trin g (0 , , "H e llo "); d isp la y d isp la y (); S e ria l.p rin tln (" T u rn o n O le d "); } e lse i f (b u tto n P u s h C o u n te r= = ) { m e a su re _ m a n u a l(); } e lse i f (b u tto n P u s h C o u n te r= = ) { m e a s u re _ a u to (); } e lse i f (b u tto n P u s h C o u n te r= = ) { i f (W iF i.s ta tu s () != W L _ C O N N E C T E D ) luan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iot download by : skknchat@gmail.com luan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iot 106 { W IF I_ C o n n e c t(); } else { m e a su re _ E C G (); } } e lse i f (b u tto n P u s h C o u n te r= = ) { p o x sh u td o w n (); W iF i.d isc o n n e c t(); m e a su re _ T e m p (); } e lse i f (b u tto n P u s h C o u n te r= = ) { G e t_ tim e (); } e lse i f (b u tto n P u s h C o u n te r= = ) { // E S P re sta rt(); d isp la y d isp la y O ff(); b u tto n P u s h C o u n te r= ; } i f (S e ria l.a v a ila b le ()) { R e a d S e ria l(); luan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iot download by : skknchat@gmail.com luan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iot 107 } o n R e c e iv e (L o R a p a rs e P a c k e t()); } v o id In itW iF i(){ S e ria l.p rin tln (" C o n n e c tin g to A P "); W iF i.b e g in (W IF I_ A P , W IF I_ P A S S W O R D ); w h ile (W iF i.s ta tu s () != W L _ C O N N E C T E D ){ d e la y (5 0 ); S e ria l.p rin t(" " ); } S e ria l.p rin tln (" C o n n e c te d to A P " ); } v o id K h a n c a p () { L o R a b e g in P a c k e t(); L o R a p rin t(" !_ " ); L o R a e n d P a c k e t(); d ig ita lW rite (L O A , H IG H ); d e la y (2 0 ); p o x b e g in (); } v o id sa v e D a ta _ A u to () { s e n s o rD a ta = S D o p e n (" A u to c sv " , F IL E _ W R IT E ); i f (se n so rD a ta ) { se n s o rD a ta p rin tln (d a ta S trin g ); luan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iot download by : skknchat@gmail.com luan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iot 108 s e n s o rD a ta c lo s e (); // c lo se th e file S erial p rin tln (d a ta S trin g ); } else { S e ria l.p rin tln (" E rro r w ritin g to file !"); } } C.2 Lập trình cho GW # in c lu d e < T o n e h > # in c lu d e < S P I.h > # in c lu d e < L o R a h > # in c lu d e < S S D h > # in c lu d e < P u b S u b C lie n t.h > # in c lu d e < W iF i.h > # in c lu d e < N T P C lie n t.h > # in c lu d e < W iF iU d p h > # in c lu d e < W ire h > # in c lu d e < L iq u id C ry s ta l_ I2 C h > # in c lu d e < S o ftw a re S e ria l.h > # in c lu d e < D F P la y e r_ M in i_ M p h > # in c lu d e < s trin g h > # in c lu d e < E S P m D N S h > # in c lu d e < A rd u in o O T A h > L iq u id C ry s ta l_ I2 C lc d (0 X , , 4); # d e fin e SS 18 luan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iot download by : skknchat@gmail.com luan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iot 109 # d e fin e R S T 14 # d e fin e D I0 # d e fin e B A N D 3 E # d e fin e R X D 16 # d e fin e T X D 17 # if n d e f S T A S S ID # d e fin e S T A S S ID " IP H O N E P L U S " # d e fin e S T A P S K "0 8 " # e n d if c o n st c h ar* ss id = S T A S S ID ; c o n st c h ar* p a s s w o rd = S T A P S K ; W iF iU D P n U D P ; N T P C lie n t tim e Q ie n t(n U D P ); S trin g d a y S ta m p , tim e S ta m p , d a te _ g , m o n th _ ,y e a r_ ; S o ftw a re S e ria l m y S e ria l(3 ,1 ); c o n st S trin g m y p h o n e = " 8 " ; S trin g R x B u f f = ""; # d e fin e T O K E N " J P M h n k y B m tF H ry n v c S " c h a r th in g s b o a rd S e rv e r[] = " d e m o th in g sb o a rd io " ; W iF iC lie n t w ifiC lie n t; P u b S u b C lie n t c lie n t(w ifiC lie n t); in t sta tu s = W L _ ID L E _ S T A T U S ; u n s ig n e d lo n g la stS e n d ; u n s ig n e d lo n g la s tS e n d _ tim e ; u n s ig n e d lo n g la s tS e n d _ N O D E ; in t v a l1 , v a l2 , m o c _ , m o c _ , m o c _ , m o c _ , m o c _ ; S trin g d a te _ , tim e _ , d a te _ , tim e _ , d a te _ , tim e _ ,d a te _ , tim e _ ; luan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iot download by : skknchat@gmail.com luan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iot 110 S trin g filte r_ d a ta [5 ], d a ta ; v o id se tu p () { S e ria l.b e g in (1 0 ); S e ria l2 b e g in (9 0 , S E R IA L _ N , R X D , T X D ); m y S e ria l.b e g in (9 0 ); m p _ s e t_ s e ria l (S e ria l2 ); m p _ s e t_ v o lu m e (2 ); m p _ p la y (1 ); p in M o d e (N u tT im e , IN P U T ); W iF i.b e g in (s s id , p a ssw o rd ); w h ile (W iF i.s ta tu s () != W L _ C O N N E C T E D ) { d e la y (5 0 ); S e ria l.p rin t(M.M); } c lie n t.s e tS e rv e r(th in g s b o a rd S e rv e r, 1883); la s tS e n d = 0; w h ile (!S e ria l); d e la y (1 0 ); tim e C lie n t.b e g in (); tim e C lie n t.s e tT im e O ffs e t(+ * * ); lc d in it(); lc d b a c k lig h t(); S P I.b e g in (5 ,1 ,2 ,1 8); L o R a s e tP in s (S S ,R S T ,D I0 ); i f (!L o R a b e g in (B A N D )) { luan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iot download by : skknchat@gmail.com luan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iot 111 w h ile (1); } G s m _ In it(); se ria lE v e n t(); G s m _ M a k e C a ll(m y p h o n e ); // T e s t c u o c g o i m p _ p la y (2); } v o id lo o p () { i f (s ta tu s R e p e a te r = = ) { i f (m illis () - m illis B e fo re < 0 ) { i f (tu rn = = 1) { S e n d R e q u e s t(" N " ); w a itF o rA n sw e r_ (); tu rn = 2; } w a itF o rA n sw e r_ (); } e lse i f ((m illis () - m illis B e fo re > 0 ) & & (m illis () - m illis B e fo re < 0 )) { i f (tu rn = = ) { S e n d R e q u e s t(" N " ); w a itF o rA n sw e r_ (); tu rn = 3; } w a itF o rA n sw e r_ (); luan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iot download by : skknchat@gmail.com luan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iot 112 } e lse i f ((m illis () - m illis B e fo re > 0 ) & & (m illis () - m illis B e fo re < 0 )) { i f (tu rn = = ) { S e n d R e q u e s t(" N " ); w a itF o rA n s w e r_ (); tu rn = 4; } w a itF o rA n sw e r_ (); } e lse i f (m illis () - m illis B e fo re > 0 ) { i f (tu rn = = ) { S e n d R e q u e s t(" N " ); w a itF o rA n sw e r_ (); tu rn = 1; } w a itF o rA n sw e r_ (); m illis B e fo re = m illis(); } } in t p a c k e tS iz e = L o R a p a rs e P a c k e t(); i f (p a c k e tS iz e ) { w h ile (L o R a a v a ila b le ()) { d a ta = L o R a re a d S trin g (); lc d c le a r(); lc d s e tC u rs o r(0 , 2); luan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iot download by : skknchat@gmail.com luan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iot 113 lc d p rin t(đ a ta ); if(d a ta s u b s trin g (0 ,2 )= = " !_ " ) { d ig ita lW rite (R E D _ N O D E 1, H IG H ); m p _ p la y (7); G s m _ M a k e C a ll(m y p h o n e ); } e lse if(d a ta s u b strin g (0 ,2 )= = " @ _ ") { d ig ita lW rite (R E D _ N O D E , H IG H ); m p _ p la y (7); G s m _ M a k e C a ll(m y p h o n e ); } e lse if(d a ta s u b s trin g (0 ,2 )= = " # _ " ) { d ig ita lW rite (R E D _ N O D E , H IG H ); m p _ p la y (7); G s m _ M a k e C a ll(m y p h o n e ); } e lse if(d a ta s u b strin g (0 ,2 )= = " $ _ ") { d ig ita lW rite (R E D _ N O D E , H IG H ); m p _ p la y (7); G s m _ M a k e C a ll(m y p h o n e ); } } } luan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iot download by : skknchat@gmail.com luan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iot 114 lc d s e tC u rs o r(0 , 3); lc d p rin t(”R S S I: "); lc d s e tC u rs o r(5 , 3); lc d p rin t((S trin g )L o R a p a c k e tR s s i()); if(!c lie n t.c o n n e c te d ()){ re c o n n e c t(); } c lie n t.lo o p (); } v o id S e n d D a ta _ (){ in t S p o _ _ A la rm = c h u o i2 _ to In t(); S trin g R = (S trin g )L o R a p a c k e tR s s i(); S trin g H = c h u o i1 ; S trin g S = c h u o i2 _ ; S trin g D = c h u o i3 ; S trin g A ; if(S p o _ _ A la rm < ) { A = " A L A R M !" ; //A la rm } e lse i f (S p o _ _ A la rm > = & & S p o _ _ A la rm < = ) { A = " L O W " ; //L O W } e lse i f (S p o _ _ A la rm > = & & S p o _ _ A la rm < = ) { A = " N O R M A L " ; //N O R M A L luan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iot download by : skknchat@gmail.com luan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iot 115 } else { A = " G O O D " ;// G O O D } S trin g p a y lo a d = "{"; p a y lo a d + = " \" H \" :" ; p a y lo a d + = H ; p a y lo a d + = ","; p a y lo a d + = " \" S \":"; p a y lo a d + = S1; p a y lo a d + = ","; p a y lo a d + = " \" D \" :" ; p a y lo a d + = D ; p a y lo a d + = ","; p a y lo a d + = " \"A \":"; p a y lo a d + = A ; p a y lo a d + = ","; p a y lo a d + = " \"R \":"; p a y lo a d + = R ; p a y lo a d + = "}"; c h a r te le m e try [1 0 ]; p a y lo a d to C h a rA rra y ( te le m e try , 100 ); c lie n t.p u b lis h ( " v /d e v ic e s/m e /te le m e try " , te le m e try ); } v o id re c o n n e c t(){ w h ile (!c lie n t.c o n n e c te d ()){ sta tu s = W iF i.s ta tu s(); if(sta tu s != W L _ C O N N E C T E D ){ W iF i.b e g in (s s id , p a ssw o rd ); w h ile (W iF i.s ta tu s () != W L _ C O N N E C T E D ){ d e la y (5 0 ); } } i f ( c lie n t.c o n n e c t(" E S P D e v ic e " , T O K E N , N U L L )) { luan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iot download by : skknchat@gmail.com luan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iot 116 } e lse { d e la y ( 0 ); } } } v o id S e n d R e q u e s t(S trin g re q u e st) { L o R a b e g in P a c k e t(); L o R a p rin t(re q u e s t); L o R a e n d P a c k e t(); } v o id w a itF o rA n s w e r_ () { in t p a c k e tS iz e = L o R a p a rs e P a c k e t(); i f (p a c k e tS iz e ) { w h ile (L o R a a v a ila b le ()) { d a ta = L o R a re a d S trin g (); lc d c le a r(); lc d s e tC u rs o r(0 , 2); lc d p rin t(d a ta ); if(d a ta s u b s trin g (0 ,2 )= = " _ " ) { fo r (in t i = 0; i < d a ta le n g th (); i+ + ) { i f (d a ta c h a rA t(i) = = '_ ') { m o c _ = i; } luan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iot download by : skknchat@gmail.com luan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iot luan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iotluan.van.thac.si.nghien.cuu.thiet.ke.he.thong.giam.sat.va.canh.bao.suc.khoe.ung.dung.cong.nghe.iot

Ngày đăng: 03/01/2024, 06:58

Xem thêm: