一、crm开发定制课题研究意义、crm开发定制现状及应用分析
crm开发定制作为物联技术在居住环crm开发定制境中的综合体现, crm开发定制现今已被越来越多的中crm开发定制国消费者所接受。crm开发定制环境监测作为其中的一crm开发定制项重要组成部分, crm开发定制通常会通过各种传感器对空气温度、湿度、燃气浓度、火焰探测等项目进行监测。其中空气温湿度的智能检测常作为附加功能应用于空调、加湿器、除湿器等家电, 需要启动体量较大的家电才能实现检测, 成本较高;而传统的简易物理温湿度测量仪不具备远程实时显示的功能, 便捷性较低。
本文设计提出的基于的空气温湿度检测系统, 具有通过远程实时显示空气温湿度讯息的功能, 具备系统结构简易、硬件连接简单、网页制作便捷、成本较低等优点。
二、课题总体方案设计及功能模块
(一)课题总体方案设计
本系统由检测对象、、ESP8266开发板、web端、蜂鸣器等部分构成。检测对象为空气温湿度信息;传感器把在空气中获取的温湿度信息转变为电信号输出至ESP8266开发板;开发板首先将接收到的空气温湿度信息进行数据处理, 通过比特与数值的换算公式,输出可直接读取的温湿度数字和符号信息,例如“32℃ 78%”;然后开发板通过wifi与web端相连接, web端接收并实时显示开发板输出的温湿度信息;最后将温湿度信息数据与设定的阀值进行对比,实现高温报警。
(二)功能模块
三、系统硬件平台及接口设计
(一)系统硬件平台
1、ESP8266 MCU 开发板
ESP8266作为一款WIFI网络通信模块,能够实现数据的网络传输,具有运行稳定、价格便宜等特点,该模块不仅能独立运行、也可作为子模块搭载于其他控制器运行。ESP8266支持AP/STA/AP+STA三种工作模式,这里选择STA工作方式,将 ESP8266 作为站点连接到由接入点建立的 WiFi 网络。
2、DHT11数字温湿度传感器
DHT11 数字温湿度传感器,包括一个电阻式感湿元件和一个NTC测温元件,是一款含有已校准数字信号输出的温湿度复合传感器。该产品精度高、可靠性好、响应快、稳定性强、抗干扰能力强、性价比极高并且连接方便。
3、0955无源蜂鸣器
0955无源蜂鸣器内部不带震荡源,直接用直流信号无法令其鸣叫。必须使用2K-5K的波形脉冲信号才能驱动它。
4、电源模块
电源信号由USB接口提供,目的是方便提供电源的来源和可靠性。
(二)接口设计
四、系统软件功能设计,程序流程图及代码实现
(一)系统软件功能设计
用HTML标签、CSS、JavaScript等语言,制作一款简单实用的web端实时温湿度显示界面,调用API接口,将传感器获取的温湿度信息传送到显示界面。
(二)程序流程图
(三)代码实现
1、硬件代码(Arduino C)
- #include <ESP8266WiFi.h>
- #include <ESP8266WebServer.h>
- #include "DHT.h"
-
- // Uncomment one of the lines below for whatever DHT sensor type you're using!
- #define DHTTYPE DHT11 // DHT 11
- #define frequency 300 //无源蜂鸣器频率设为300
- #define PIN_BEEP 15 // 无源蜂鸣器接ESP8266引脚D8(GPIO15)
-
- /*Put your SSID & Password*/
- const char* ssid = "Xiaomi 12X"; // Enter SSID here
- const char* password = "12345678"; //Enter Password here
- ESP8266WebServer server(80);
-
- // DHT Sensor
- uint8_t DHTPin = D4;
-
- // Initialize DHT sensor.
- DHT dht(DHTPin, DHTTYPE);
- float Temperature;
- float Humidity;
-
- void setup()
- {
- Serial.begin(115200);
- delay(100);
- pinMode(PIN_BEEP, OUTPUT);
- pinMode(DHTPin, INPUT);
-
- dht.begin();
-
- Serial.println("Connecting to ");
- Serial.println(ssid);
-
- //connect to your local wi-fi network
- WiFi.begin(ssid, password);
-
- //check wi-fi is connected to wi-fi network
- while (WiFi.status() != WL_CONNECTED)
- {
- delay(1000);
- Serial.print(".");
- }
- Serial.println("");
- Serial.println("WiFi connected..!");
- Serial.print("Got IP: ");
- Serial.println(WiFi.localIP());
- server.on("/", handle_OnConnect);
- server.onNotFound(handle_NotFound);
- server.begin();
- Serial.println("HTTP server started");
- }
- void loop()
- {
- server.handleClient();
- }
-
- void handle_OnConnect()
- {
- Temperature = dht.readTemperature(); // Gets the values of the temperature
- Humidity = dht.readHumidity(); // Gets the values of the humidity
- server.send(200, "text/html", SendHTML(Temperature,Humidity));
- }
-
- void handle_NotFound()
- {
- server.send(404, "text/plain", "Not found");
- }
-
- String SendHTML(float Temperaturestat,float Humiditystat){
- String ptr = "<!DOCTYPE html> <html lang=\"en\">";
-
- ptr += "<head>";
- ptr += "<meta charset=\"UTF-8\">";
- ptr += "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">";
- ptr += "<meta http-equiv=\"refresh\" content=\"1\">";
- ptr += "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">";
- ptr += "<title>智能检测</title>";
- ptr += "<style>";
- ptr += "#webpage{background-color: rgb(239, 227, 227)}";
- ptr += ".main_1{border-radius: 15px; margin: 60px; text-align: center}"; // 圆角长方体
- ptr += ".font_1{color: rgb(255, 255, 255); text-align: center; margin: 7px}"; // 文本框
- ptr += ".foot_2{font-size: 25px; width: 300px; height: 70px; margin: 80px auto; text-align: center; line-height: 70px; padding: 15px;}";
- ptr += "</style>";
- ptr += "</head>";
-
- ptr += "<body style=\"background-color:rgb(239, 227, 227); background-size: 100%;\">";
-
- //文本“室内温室检测系统”
- ptr += "<div id=\"webpage\" style=\"height: 100px; margin: auto;\">";
- ptr += "<h1 style=\"text-align: center; line-height: 100px; color: rgb(7, 12, 7); font-size: 80px;\">客房温湿度检测</h1>\";
- ptr += "</div>";
-
- //文本“室内温度”
- ptr += "<div class=\"main_1\" style=\"width:430px; height: 450px;float: left; padding: 15px; background-color: rgb(62, 109, 95);\">\";
- ptr += "<h2 class=\"font_1\" style=\"text-align: center; line-height: 120px; font-size: 80px; margin: 50px;\">室内温度</h2>\";
- ptr += "<h2 class=\"font_1\" style=\"font-size: 80px; line-height: 150px;\">";
- ptr += (int)Temperaturestat;
- ptr += "°C </h2>\";
- ptr += "</div>";
-
- //文本“室内湿度”
- ptr += "<div class=\"main_1\" style=\"width:430px; height: 450px;float: right; padding: 15px; background-color: rgb(124, 85, 59);\">\";
- ptr += "<h2 class=\"font_1\" style=\"text-align: center; line-height: 120px; font-size: 80px; margin: 50px;\">室内湿度</h2>\";
- ptr += "<h2 class=\"font_1\" style=\"font-size: 80px; line-height: 150px;\">";
- ptr += (int)Humiditystat;
- ptr += "% </h2>\";
- ptr += "</div>";
-
- //定义温度变量,并且赋值,用于逻辑判断。
- int wd = Temperaturestat ;
- int i =0;
-
- if (wd>=30)
- {
- ptr += "<div class=\"foot_2\"> 天气炎热,注意防暑 </div>";
- for(i=0;i<3;i++)
- {
- tone(PIN_BEEP, frequency); //打开蜂鸣器
- delay(300);
- noTone(PIN_BEEP); //关闭蜂鸣器
- }
- }
- if (29>=wd && wd>20)
- {
- ptr += "<div class=\"foot_2\"> 天气晴朗,适合玩耍 </div>";
- }
- if (wd<10)
- {
- ptr += "<div class=\"foot_2\"> 天气酷寒,注意保暖 </div>";
- }
-
- ptr +="</body>\";
- ptr +="</html>\";
- return ptr;
- }
2、web端代码
- <!DOCTYPE html>
- <html lang="en">
-
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>监控系统</title>
- <style>
- * {
- margin: 0;
- padding: 0;
- }
-
- body {
- width: 100%;
- background-color: rgb(232, 232, 168);
- margin: 0;
- padding: 0;
- font-family: "montserrat";
- background-image: linear-gradient(125deg, rgb(232, 232, 168), rgb(188, 152, 210), #c2e9fb, #C2FFD8);
- background-size: 400%;
- animation: bganimation 15s infinite;
- }
-
- @keyframes bganimation {
- 0% {
- background-position: 0% 50%;
- }
- 50% {
- background-position: 100% 50%;
- }
- 100% {
- background-position: 0% 50%;
- }
- }
-
- .box .header {
- width: 500px;
- margin: 50px auto;
- padding: 50px;
- }
-
- .header h1 {
- text-align: center;
- border-radius: 25%;
- background-color: rgb(215, 226, 179);
- line-height: 100px;
- }
-
- .center ul {
- display: flex;
- justify-content: space-around;
- list-style: none;
- }
-
- .center ul li {
- width: 150px;
- height: 80px;
- text-align: center;
- line-height: 80px;
- background-color: antiquewhite;
- }
-
- .center ul li a {
- display: block;
- width: 100%;
- height: 100%;
- }
-
- .center ul li:hover {
- background-color: #c2e9fb;
- box-shadow: 10px 10px 5px grey;
- }
-
- .times {
- width: 300px;
- height: 50px;
- text-align: center;
- line-height: 50px;
- border-radius: 50px;
- padding: 0 auto;
- margin: 100px auto;
- background-color: rgb(232, 232, 168);
- background-color: rgb(254, 254, 254);
- }
-
- .foot {
- font-size: 20px;
- width: 300px;
- height: 70px;
- margin: 80px auto;
- text-align: center;
- line-height: 70px;
- padding: 15px;
- }
- </style>
- </head>
-
- <body>
- <div class="box">
- <div class="header">
- <h1>室内温室检测系统</h1>
- </div>
- <div class="center">
- <ul>
- <li><a href="http://192.168.205.49" style="text-decoration: none;">主人房</a></li>
- <li><a href="http://192.168.205.32" style="text-decoration: none;">客房</a></li>
- </ul>
- </div>
- <div class="times"></div>
- <div class="foot">
- 开发人员:伍家麒、邱宝滢
- </div>
- </div>
- </body>
- <script>
- const times = document.querySelector('.times')
-
- function getDate() {
- const date = new Date()
- let h = date.getHours()
- let m = date.getMinutes()
- let s = date.getSeconds()
- h = h < 10 ? '0' + h : h
- m = m < 10 ? '0' + m : m
- s = s < 10 ? '0' + s : s
- times.innerHTML = `时间:${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()} ${h}:${m}:${s}`
- }
- getDate()
- setInterval(getDate, 1000)
- </script>
- </html>
五、 实验测试、结果分析
室内温湿度检测系统设计完成后,对其功能进行测试。当手动握住温湿度传感器时,温度处于报警区间。在此过程中,通过wifi与web端连接,将数据实时传送到web界面,当数据改变时,web界面呈现的数据发生改变。经过以上测试,说明系统正常运行并满足其设计要求。实验结果图如下:
六、总结、心得体会
本系统以ESP 8266为核心部件的控制系统,利用web编程,最终基本上实现了各项要求。虽然系统还存在一些不足,不过大体能反映出设计的目的和要求,与理论计算的结果相进。空气质量检测系统已成为21世纪热门研究话题之一,无论是从生产还是生活方面,与人类都是息息相关的,而智能化的控制温湿度已经发展成为一种必然。