【无线传感器】使用 MATLAB和 XBee连续监控温度传感器无线网络研究(Matlab代码实现)

这篇具有很好参考价值的文章主要介绍了【无线传感器】使用 MATLAB和 XBee连续监控温度传感器无线网络研究(Matlab代码实现)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

💥💥💞💞欢迎来到本博客❤️❤️💥💥

🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。

⛳️座右铭:行百里者,半于九十。

📋📋📋本文目录如下:🎁🎁🎁

目录

💥1 概述

📚2 运行结果

🎉3 参考文献

🌈4 Matlab代码及数据


💥1 概述

在本文中,MATLAB 用于通过与使用 XBee 系列 2 模块构建的温度传感器无线网络进行交互,连续监控整个公寓的温度。每个XBee边缘节点从多个温度传感器读取模拟电压(与温度成线性比例)。读数通过协调器XBee模块传输回MATLAB。本文说明了如何操作、获取和分析来自连接到多个 XBee 边缘节点的多个传感器网络的数据。数据采集时间从数小时到数天不等,以帮助设计和构建智能恒温器系统。

📚2 运行结果

【无线传感器】使用 MATLAB和 XBee连续监控温度传感器无线网络研究(Matlab代码实现)

 【无线传感器】使用 MATLAB和 XBee连续监控温度传感器无线网络研究(Matlab代码实现)

 【无线传感器】使用 MATLAB和 XBee连续监控温度传感器无线网络研究(Matlab代码实现)

 【无线传感器】使用 MATLAB和 XBee连续监控温度传感器无线网络研究(Matlab代码实现)

 【无线传感器】使用 MATLAB和 XBee连续监控温度传感器无线网络研究(Matlab代码实现)

【无线传感器】使用 MATLAB和 XBee连续监控温度传感器无线网络研究(Matlab代码实现)【无线传感器】使用 MATLAB和 XBee连续监控温度传感器无线网络研究(Matlab代码实现)【无线传感器】使用 MATLAB和 XBee连续监控温度传感器无线网络研究(Matlab代码实现) 【无线传感器】使用 MATLAB和 XBee连续监控温度传感器无线网络研究(Matlab代码实现)

 【无线传感器】使用 MATLAB和 XBee连续监控温度传感器无线网络研究(Matlab代码实现)

 【无线传感器】使用 MATLAB和 XBee连续监控温度传感器无线网络研究(Matlab代码实现)

 【无线传感器】使用 MATLAB和 XBee连续监控温度传感器无线网络研究(Matlab代码实现)

 【无线传感器】使用 MATLAB和 XBee连续监控温度传感器无线网络研究(Matlab代码实现)

 【无线传感器】使用 MATLAB和 XBee连续监控温度传感器无线网络研究(Matlab代码实现)

 【无线传感器】使用 MATLAB和 XBee连续监控温度传感器无线网络研究(Matlab代码实现)

【无线传感器】使用 MATLAB和 XBee连续监控温度传感器无线网络研究(Matlab代码实现)

【无线传感器】使用 MATLAB和 XBee连续监控温度传感器无线网络研究(Matlab代码实现) 【无线传感器】使用 MATLAB和 XBee连续监控温度传感器无线网络研究(Matlab代码实现)

【无线传感器】使用 MATLAB和 XBee连续监控温度传感器无线网络研究(Matlab代码实现) 部分代码:

%% Overview of Data
% As I mentioned in a previous post, I collected the temperature every two
% minutes over the course of 9 days. I placed 14 sensors in my apartment: 9
% located inside, 2 located outside, and 3 located in radiators. The data
% is stored in the file <../twoweekstemplog.txt |twoweekstemplog.txt|>.

[tempF,ts,location,lineSpecs] = XBeeReadLog('twoweekstemplog.txt',60);
tempF = calibrateTemperatures(tempF);
plotTemps(ts,tempF,location,lineSpecs)
legend('off')
xlabel('Date')
title('All Data Overview')

%%
% _Figure 1: All temperature data from a 9 day period._
%
% That graph is a bit too cluttered to be very meaningful. Let me remove
% the radiator data and the legend and see if that helps.

notradiator = [1 2 3 5 6 7 8 9 10 12 13];
plotTemps(ts,tempF(:,notradiator),location(notradiator),lineSpecs(notradiator,:))
legend('off')
xlabel('Date')
title('All Inside and Outside Temperature Data')

%%
% _Figure 2: Just inside and outside temperature data, with radiator data removed._
%
% Now I can see some places where one of the outdoor temperature sensors
% (blue line) gave erroneous data, so let's remove those data points. This
% data was collected in March in Massachusetts, so I can safely assume the
% outdoor temperature never reached 80 F. I replaced any values above 80 F
% with |NaN| (not-a-number) so they are ignored in further analysis.

outside = [3 10];
outsideTemps = tempF(:,outside);
toohot = outsideTemps>80;
outsideTemps(toohot) = NaN;
tempF(:,outside) = outsideTemps;

plotTemps(ts,tempF(:,notradiator),location(notradiator),lineSpecs(notradiator,:))
legend('off')
xlabel('Date')
title('Cleaned-up Inside and Outside Temperature Data')

%%
% _Figure 3: Inside and outside temperature data with erroneous data removed._
%
% I'll also remove all but one inside sensor per room, and give the
% remaining sensors shorter names, to keep the graph from getting too
% cluttered.

show = [1 5 9 12 10 3];
location(show) = ...
    {'Bedroom','Kitchen','Living Room','Office','Front Porch','Side Yard'}';

plotTemps(ts,tempF(:,show),location(show),lineSpecs(show,:))
ylim([0 90])
legend('Location','SouthEast')
xlabel('Date')
title('Summary of Temperature Data')

%%
% _Figure 4: Summary of temperature data with only one inside temperature
% sensor per room with outside temperatures._
%
% That looks much better. This data was collected over the course of 9
% days, and the first thing that stands out to me is the periodic outdoor
% temperature, which peaks every day at around noon. I also notice a sharp
% spike in the side yard (green) temperature on most days. My front porch
% (blue) is located on the north side of my apartment, and does not get
% much sun. My side yard is on the east side of my apartment, and that
% spike probably corresponds to when the sun hits the sensor from between
% my apartment and the building next door.

%% When do my radiators start to heat up?
% The radiator temperature can be used to measure how long it takes for my
% boiler and radiators to warm up after the heat has been turned on. Let's
% take a look at 1 day of data from the living room radiator:

% Grab the Living Room Radiator Temperature (index 11) from the |tempF| matrix.
radiatorTemp = tempF(:,11);

% Fill in any missing values:
validts = ts(~isnan(radiatorTemp));
validtemp = radiatorTemp(~isnan(radiatorTemp));
nants = ts(isnan(radiatorTemp));
radiatorTemp(isnan(radiatorTemp)) = interp1(validts,validtemp,nants);

% Plot the data
oneday = [ts(1) ts(1)+1];
figure
plot(ts,radiatorTemp,'k.-')
xlim(oneday)
xlabel('Time')
ylabel('Radiator Temperature (\circF)')
title('Living Room Radiator Temperature')
datetick('keeplimits')
snapnow

%%
% _Figure 5: One day of temperature data from the living room radiator._
%
% As expected, I see a sharp rise in the radiator temperature, followed by
% a short leveling off (when the radiator temperature maxes out the
% temperature sensor), and finally a gradual cooling of the radiator. Let
% me superimpose the rate of change in temperature onto the plot.

tempChange = diff([NaN; radiatorTemp]);

hold on
plot(ts,tempChange,'b.-')
legend({'Temperature', 'Temperature Change'},'Location','Best')

%%
% _Figure 6: One day of data from the living room radiator with temperature change._
%
% It looks like I can detect those peaks by looking for large jumps in the
% temperature. After some trial and error, I settled on three criteria to
% identify when the heat comes on:
%
% # Change in temperature greater than four times the previous change in temperature.
% # Change in temperature of more than 1 degree F.
% # Keep the first in a sequence of matching points (remove doubles)

fourtimes = [tempChange(2:end)>abs(4*tempChange(1:end-1)); false];
greaterthanone = [tempChange(2:end)>1; false];
heaton = fourtimes & greaterthanone;
doubles = [false; heaton(2:end) & heaton(1:end-1)];
heaton(doubles) = false;

%%
% Let's see how well I detected those peaks by superimposing red dots over
% the times I detected.

figure
plot(ts,radiatorTemp,'k.-')
hold on
plot(ts(heaton),radiatorTemp(heaton),'r.','MarkerSize',20)
xlim(oneday);
datetick('keeplimits')
xlabel('Time')
ylabel('Radiator Temperature (\circF)')
title('Heat On Event Detection')
legend({'Temperature', 'Heat On Event'},'Location','Best')

%%
% _Figure 7: Radiator temperature with heating events marked with red dots._
%
% Looks pretty good, which means now I have a list of all the times that
% the heat came on in my apartment.
heatontimes = ts(heaton);

%% How long does it take for my heat to turn on?
% I currently have a programmable 5/2 thermostat, which means I can set
% one program for weekdays (Monday through Friday) and one program for both
% Saturday and Sunday. I know my thermostat is set to go down to 62 at
% night, and back up to 68 at 6:15am Monday through Friday and 10:00am on
% Saturday and Sunday. I used that knowledge to determine how long after my
% thermostat activates that my radiators warm up.
%
% I started by creating a vector of all the days in the test period. I
% removed Monday because I manually turned on the thermostat early that day.
mornings = floor(min(ts)):floor(max(ts));
mornings(2) = []; % Remove Monday

%%
% Then I added either 6:15am or 10:00am to each day depending on whether it
% was a weekday or a weekend.
isweekend = weekday(mornings) == 1 | weekday(mornings) == 7;
mornings(isweekend) = mornings(isweekend)+10/24; % 10:00 AM
mornings(~isweekend) = mornings(~isweekend)+6.25/24; % 6:15 AM

%%
% Next I looked for the first time the heat came on after the programmed
% time each morning.
heatontimes_mat = repmat(heatontimes,1,length(mornings));
mornings_mat = repmat(mornings,length(heatontimes),1);
timelag = heatontimes_mat - mornings_mat;
timelag(timelag<=0) = NaN;

plot(ts,radiatorTemp,'k.-')
hold on
plot(heatontimes,heatontemp,'r.','MarkerSize',20)
plot(heatontimes(heatind),heatontemp(heatind),'bo','MarkerSize',10)
plot([mornings;mornings],repmat(ylim',1,length(mornings)),'b-');
xlim(onemorning);
datetick('keeplimits')
xlabel('Time')
ylabel('Radiator Temperature (\circF)')
title('Detection of Scheduled Heat On Events')
legend({'Temperature', 'Heat On Event', 'Scheduled Heat On Event',...
    'Scheduled Event'},'Location','Best')

%%
% _Figure 8: Six hours of radiator data, with a blue line indicating when
% the thermostat turned on in the morning, and blue circle indicating the
% corresponding heat on event of the radiator._
%
% Let's look at a histogram of those delays:
figure
hist(delay,min(delay):max(delay))
xlabel('Minutes')
ylabel('Frequency')
title('How long before the radiator starts to warm up?')

%%
% _Figure 9: Histogram showing delay between thermostat activation and the
% radiators starting to warm up._
%
% It looks like the delay between the thermostat coming on in the morning
% and the radiators starting to warming up can range from 7 minutes to as
% high as 24 minutes, but on average this delay is around 12-13 minutes.
heatondelay = 12;

%% How long does it take for the radiators to warm up?
% Once the radiators start to warm up, it takes a few minutes for them to
% reach full temperature. Let's look at how long this takes. I'll look for
% times when the radiator temperature first maxes out the temperature
% sensor after having been below the maximum for at least 10 minutes (5
% samples).

maxtemp = max(radiatorTemp);
radiatorhot = radiatorTemp(6:end)==maxtemp & ...
    radiatorTemp(1:end-5)<maxtemp &...
    radiatorTemp(2:end-4)<maxtemp &...
    radiatorTemp(3:end-3)<maxtemp &...
    radiatorTemp(4:end-2)<maxtemp &...
    radiatorTemp(5:end-1)<maxtemp;
radiatorhot = [false(5,1); radiatorhot];
radiatorhottimes = ts(radiatorhot);
%
% Now I'll match the |radiatorhottimes| to the |heatontimes| using the same
% technique I used above.
radiatorhottimes_mat = repmat(radiatorhottimes',length(heatontimes),1);
heatontimes_mat = repmat(heatontimes,1,length(radiatorhottimes));
timelag = radiatorhottimes_mat - heatontimes_mat;
timelag(timelag<=0) = NaN;
[delay, foundmatch] = min(timelag);
delay = round(delay*24*60);

%%
% Let's look at a histogram of those delays:
figure
hist(delay,min(delay):2:max(delay))
xlabel('Minutes');
ylabel('Frequency')
title('How long does the radiator take to warm up?')

%%
% _Figure 11: Histogram showing time required for the radiators to warm up._
%
% It looks like the radiators take between 4 and 8 minutes from when they
% start to warm up until they are at full temperature.
radiatorheatdelay = 6;

%%
% Later on in my analysis, I will only want to use times that the heat came
%
% Although it isn't perfect, it looks close to a linear relationship. Since
% I am interested in the time it takes to reach the desired temperature
% (what could be considered the "specific heat capacity" of the room), let
% me replot the data with time on the y-axis and temperature on the x-axis
% (swapping the axes from the previous figure). I'll also plot the data as
% individual points instead of lines, because that is how the data is going
% to be fed into |polyfit| later.

% Remove temperatures occuring before the minimum temperature.
segmentTempsShifted(segmentTimesShifted<0) = NaN;

figure
h1 = plot(segmentTempsShifted',segmentTimesShifted','k.');
xlabel('Temperature Increase (\circF)')
ylabel('Minutes since minimum temperature')
title('Time to Heat Living Room')
snapnow

%%
% _Figure 17: The time it takes to heat the living room (axes flipped from
% Figure 16)._
%
% Now let me fit a line to the data so I can get an equation for the time
% it takes to heat the living room.

%%
% First I collect all the time and temperature data into a single column
% vector and remove |NaN| values.

allTimes = segmentTimesShifted(:);
allTemps = segmentTempsShifted(:);
allTimes(isnan(allTemps)) = [];
allTemps(isnan(allTemps)) = [];

%%
% Then I can fit a line to the data.
linfit = polyfit(allTemps,allTimes,1);

%%
% Let's see how well we fit the data.

hold on
h2 = plot(xlim,polyval(linfit,xlim),'r-');
linfitstr = sprintf('Linear Fit (y = %.1f*x + %.1f)',linfit(1),linfit(2));
legend([ h1(1), h2(1) ],{'Data',linfitstr},'Location','NorthWest')

%%
% _Figure 18: The time it takes to heat the living room along with a linear fit to the data._
%
% Not a bad fit. Looking closer at the coefficients from the linear fit, it
% looks like it takes about 3 minutes after the radiators start to heat up
% for the room to start to warm up. After that, it takes about 5 minutes
% for each degree of temperature increase.

%% What room takes the longest to warm up?
% I can apply the techniques above to each room to find out how long each
% room takes to warm up. I took the code above and put it into a separate
% function called <../temperatureAnalysis.m |temperatureAnalysis|>, and
% applied that to each inside temperature sensor.

inside = [1 5 9 12];

figure
xl = [0 14];
for s = 1:size(inside,2)
    linfits(s,1:2) = temperatureAnalysis(tempF(:,inside(s)), heaton, heatoff);
    y = polyval(linfits(s,1:2),xl) + heatondelay;
    plot(xl, y, lineSpecs{inside(s),1}, 'Color',lineSpecs{inside(s),2},...
        'DisplayName',location{inside(s)})
    hold on
end
legend('Location','NorthWest')
xlabel('Desired temperature increase (\circF)')
ylabel('Estimated minutes to heat')
title('Estimated Time to Heat Each Room')

%%
% _Figure 19: The estimated time it takes to heat each room in my apartment._

🎉3 参考文献

部分理论来源于网络,如有侵权请联系删除。

[1]王晓银.基于XBee的瓦斯无线传感器网络节点的设计[J].自动化技术与应用,2018,37(08):46-49.

[2]王晓银.基于XBee的瓦斯无线传感器网络节点的设计[J].自动化技术与应用,2018,37(08):46-49.文章来源地址https://www.toymoban.com/news/detail-514069.html

🌈4 Matlab代码及数据

到了这里,关于【无线传感器】使用 MATLAB和 XBee连续监控温度传感器无线网络研究(Matlab代码实现)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 基于无线传感器网络的LC-DANSE波束形成算法matlab仿真

    目录 1.程序功能描述 2.测试软件版本以及运行结果展示 3.核心程序 4.本算法原理 4.1LC-DANSE算法原理 4.2 LCMV算法原理 5.完整程序         在无线传感器网络中,通过MATLAB对比LC-DANSE波束形成算法和LCMV波束形成算法。对比SNR,mse等指标。 MATLAB2022a版本运行        无线传感器网络

    2024年02月20日
    浏览(41)
  • 【完美复现】无人机无线传感器网络中的节能数据采集(Matlab代码实现)

    💥💥💞💞 欢迎来到本博客 ❤️❤️💥💥 🏆博主优势: 🌞🌞🌞 博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。 ⛳️ 座右铭: 行百里者,半于九十 📋📋📋 本文目录如下: 🎁🎁🎁 目录 💥1 概述 📚2 运行结果 🎉3 参考文献 🌈4 Matlab代码、数据、文章

    2024年02月03日
    浏览(45)
  • 基于MATLAB实现WSN(无线传感器网络)的LEACH(低能耗自适应集群层次结构)(Matlab代码实现)

        目录 💥1 概述 📚2 运行结果 🎉3 参考文献 👨‍💻4 Matlab代码 低能耗自适应集群层次结构(“LEACH”)是一种基于 TDMA 的 MAC 协议,它与无线传感器网络 (WSN) 中的集群和简单路由协议集成在一起。LEACH的目标是降低创建和维护集群所需的能耗,以延长无线传感器网络

    2024年02月02日
    浏览(41)
  • 【WSN覆盖】基于麻雀搜索算法的三维混合无线传感器网络覆盖优化 三维WSN覆盖空洞修复【Matlab代码#25】

    由于节点随机抛洒,而传感器节点的分布情况会影响网络覆盖率。在三维覆盖区域中,传感器节点的覆盖区域是某一半径确定的球。在三维监测区域中随机抛洒 N N N 个传感器节点,形成节点集合 ( s 1 , s 2 , s 3 , . . . , s N ) (s_{1},s_{2},s_{3},...,s_{N}) ( s 1 ​ , s 2 ​ , s 3 ​ , ... , s

    2024年02月06日
    浏览(52)
  • 无线传感器基础:获取手机传感器、加速度

    一些实验过程中的疑问: 如何知道设备上有哪些传感器? 如果手机不支持的传感器,程序运行往往不会抛出异常,只是无法获得传感器传回的数据。那么如何知道设备上有哪些传感器可用呢?有两种方式,一种是直接方式,一种是间接方式。直接方式就是遍历获取得到传感

    2024年02月02日
    浏览(64)
  • 无线传感器网络作业题

    超星无线传感器网络作业题 选择题 1【多选题】无线传感器网络的主要特点包括( BCD )。 A、节点位置固定 B、无中心 C、自组织 D、多跳路由 2【多选题】无线传感器网络节点包括( AB )。 A、传感器节点 B、汇聚节点 C、管理节点 3【多选题】无线传感器网络中的传感器节点具

    2024年02月11日
    浏览(46)
  • 01-无线传感器网络(WSN)简介

    01-1定义 无线传感器网络(WSN)集成了传感器技术、嵌入式技术、计算机网络和无线通信技术等,在各个领域的应用不断扩展,被认为是21世纪最有影响力的技术之一。无线传感器网络是由大量静止或移动的传感器以自组织和多跳的方式构成的无线网络,目的是协作地探测、处

    2024年02月06日
    浏览(48)
  • 无线传感器网络WSN覆盖优化问题

    无线传感器网络 (Wireless Sensor Networks,WSNs)是一种分布式传感网络,嵌入了传感器的智能设备感测、通信、处理、收集数据,然后通过互联网将数据传输给监测者进行进一步分析,是通过无线通信方式形成的一个多跳自组织网络,可用于大规模物联网应用。由于其传感器通

    2024年02月05日
    浏览(74)
  • 无线传感器网络底层平台的深层研究

    无线传感器网络应用一般需要无线操作系统的支撑,才能有效地管理和调度资源,提高系统的效率。无线传感器网络的底层平台是连接上层软件和底层硬件的桥梁,是无线操作系统研究的重要技术之一。合理的底层平台能够提高系统的兼容性、稳定性、可移植性和开发效率。

    2024年02月07日
    浏览(58)
  • 浅谈无线传感器网络的特点和挑战

    无线传感器网络中所有传感器节点地位对等,并构成一个对等式网络的无线传感网络的特点如下:   硬件资源有限:每个节点由于受价格、体积和功耗的限制,其计算能力、程序空间和内存空间等硬件资源有限,因此协议层次不能太复杂。 电源容量有限:在无线传感器网络

    2024年02月09日
    浏览(40)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包