无线传感器网络实验3
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
*/
event TOS_MsgPtr ResetCounterMsg.receive(TOS_MsgPtr m) {
atomic {
readingNumber = 0;
}
return m;
}
}
五、实验现象
经USB连接,经过对程序的编译即将其下载到节点,得到以下的图片。发现改变其温度会得到波动性变化显著地图形。可见传感器对温度还是比较敏感的。
* failure immediately if the packet could not be queued for
* transmission.
*/
if (call DataMsg.send(TOS_UART_ADDR, sizeof(struct OscopeMsg),
&msg[currentMsg]))
* BUFFER_SIZE readings have been taken.
* @return Always returns SUCCESS.
*/
async event result_t ADC.dataReady(uint16_t data) {
struct OscopeMsg *pack;
atomic {
atomic {
currentMsg = 0;
packetReadingNumber = 0;
readingNumber = 0;
}
dbg(DBG_BOOT, "OSCOPE initialized\n");
return SUCCESS;
}
/**
* Starts the SensorControl and CommControl components.
packetReadingNumber = 0;
pack->lastSampleNumber = readingNumber;
}
pack->channel = 1;
pack->sourceMoteID = TOS_LOCAL_ADDRESS;
/* Try to send the packet. Note that this will return
{
atomic {
currentMsg ^= 0x1;
}
call Leds.yellowToggle();
}
}
/**
* Signalled when data is ready from the ADC. Stuffs the sensor
* reading into the current packet, and sends off the packet when
interface StdControl as CommControl;
interface SendMsg as DataMsg;
interface ReceiveMsg as ResetCounterMsg;
}
}
implementation
{
uint8_t packetReadingNumber;
实验报告
实验名称光照温度和湿度传感器控制
课程名称无线传感器网络实验
院 系 部:专业班级:
学生姓名:学 号:
同 组 人:学 号:
指导教师:成 绩:
实验日期:2015年5月5日
华北电力大学
一、实验目的及要求
了解一下温度和湿度传感器的运行原理及数wk.baidu.com处理过程。测定温度和湿度值的传感器。
二、实验仪器
主电脑、一个Mote设备、ISP工具、USB连接线
* @return Always returns SUCCESS.
*/
command result_t StdControl.start() {
call SensorControl.start();
call Timer.start(TIMER_REPEAT, 125);
call CommControl.start();
三、实验原理
照度传感器通过周围关照的改变而改变其电阻值。
1-1
把可以测定周围温度及湿度值传感器直接连接在CPU上。电路原理如下图所示:
1-2
为了读取测定的传感器值,通过与CPU连接的2条线,输入一定的时钟和指令,下图显示了在CPU中能够从传感器接受以测定的数据的时钟计时器和命令的输入方式。
1-3
四、实验程序
return SUCCESS;
}
/**
* Stops the SensorControl and CommControl components.
* @return Always returns SUCCESS.
*/
command result_t StdControl.stop() {
call SensorControl.stop();
1-4
经USB连接,经过对程序的编译即将其下载到节点,得到以下的图片。发现改变其光照会得到波动性变化显著地图形。可见传感器对光照还是比较敏感的。
1-5
六、讨论与结论
图上显示的是温度,如何将其改成湿度。修改程序的定义即可
对于已经知道波形的传感器如何衡量其温度的敏感度是否符合要求。
pack = (struct OscopeMsg *)msg[currentMsg].data;
pack->data[packetReadingNumber++] = data;
readingNumber++;
dbg(DBG_USR1, "data_event\n");
if (packetReadingNumber == BUFFER_SIZE) {
uint16_t readingNumber;
TOS_Msg msg[2];
uint8_t currentMsg;
/**
* Used to initialize this component.
*/
command result_t StdControl.init() {
call Leds.init();
includes OscopeMsg;
module OscilloscopeM
{
provides interface StdControl;
uses {
interface Timer;
interface Leds;
interface StdControl as SensorControl;
interface ADC;
*/
event result_t DataMsg.sendDone(TOS_MsgPtr sent, result_t success) {
return SUCCESS;
}
/**
* Signalled when the clock ticks.
* @return The result of calling ADC.getData().
post dataTask();
}
}
if (data > 0x0300)
call Leds.redOn();
else
call Leds.redOff();
return SUCCESS;
}
/**
* Signalled when the previous packet has been sent.
* @return Always returns SUCCESS.
*/
event result_t Timer.fired() {
return call ADC.getData();
}
/**
* Signalled when the reset message counter AM is received.
* @return The free TOS_MsgPtr.
call Timer.stop();
call CommControl.stop();
return SUCCESS;
}
task void dataTask() {
struct OscopeMsg *pack;
atomic {
pack = (struct OscopeMsg *)msg[currentMsg].data;
call Leds.yellowOff(); call Leds.redOff(); call Leds.greenOff();
//turn on the sensors so that they can be read.
call SensorControl.init();
call CommControl.init();
event TOS_MsgPtr ResetCounterMsg.receive(TOS_MsgPtr m) {
atomic {
readingNumber = 0;
}
return m;
}
}
五、实验现象
经USB连接,经过对程序的编译即将其下载到节点,得到以下的图片。发现改变其温度会得到波动性变化显著地图形。可见传感器对温度还是比较敏感的。
* failure immediately if the packet could not be queued for
* transmission.
*/
if (call DataMsg.send(TOS_UART_ADDR, sizeof(struct OscopeMsg),
&msg[currentMsg]))
* BUFFER_SIZE readings have been taken.
* @return Always returns SUCCESS.
*/
async event result_t ADC.dataReady(uint16_t data) {
struct OscopeMsg *pack;
atomic {
atomic {
currentMsg = 0;
packetReadingNumber = 0;
readingNumber = 0;
}
dbg(DBG_BOOT, "OSCOPE initialized\n");
return SUCCESS;
}
/**
* Starts the SensorControl and CommControl components.
packetReadingNumber = 0;
pack->lastSampleNumber = readingNumber;
}
pack->channel = 1;
pack->sourceMoteID = TOS_LOCAL_ADDRESS;
/* Try to send the packet. Note that this will return
{
atomic {
currentMsg ^= 0x1;
}
call Leds.yellowToggle();
}
}
/**
* Signalled when data is ready from the ADC. Stuffs the sensor
* reading into the current packet, and sends off the packet when
interface StdControl as CommControl;
interface SendMsg as DataMsg;
interface ReceiveMsg as ResetCounterMsg;
}
}
implementation
{
uint8_t packetReadingNumber;
实验报告
实验名称光照温度和湿度传感器控制
课程名称无线传感器网络实验
院 系 部:专业班级:
学生姓名:学 号:
同 组 人:学 号:
指导教师:成 绩:
实验日期:2015年5月5日
华北电力大学
一、实验目的及要求
了解一下温度和湿度传感器的运行原理及数wk.baidu.com处理过程。测定温度和湿度值的传感器。
二、实验仪器
主电脑、一个Mote设备、ISP工具、USB连接线
* @return Always returns SUCCESS.
*/
command result_t StdControl.start() {
call SensorControl.start();
call Timer.start(TIMER_REPEAT, 125);
call CommControl.start();
三、实验原理
照度传感器通过周围关照的改变而改变其电阻值。
1-1
把可以测定周围温度及湿度值传感器直接连接在CPU上。电路原理如下图所示:
1-2
为了读取测定的传感器值,通过与CPU连接的2条线,输入一定的时钟和指令,下图显示了在CPU中能够从传感器接受以测定的数据的时钟计时器和命令的输入方式。
1-3
四、实验程序
return SUCCESS;
}
/**
* Stops the SensorControl and CommControl components.
* @return Always returns SUCCESS.
*/
command result_t StdControl.stop() {
call SensorControl.stop();
1-4
经USB连接,经过对程序的编译即将其下载到节点,得到以下的图片。发现改变其光照会得到波动性变化显著地图形。可见传感器对光照还是比较敏感的。
1-5
六、讨论与结论
图上显示的是温度,如何将其改成湿度。修改程序的定义即可
对于已经知道波形的传感器如何衡量其温度的敏感度是否符合要求。
pack = (struct OscopeMsg *)msg[currentMsg].data;
pack->data[packetReadingNumber++] = data;
readingNumber++;
dbg(DBG_USR1, "data_event\n");
if (packetReadingNumber == BUFFER_SIZE) {
uint16_t readingNumber;
TOS_Msg msg[2];
uint8_t currentMsg;
/**
* Used to initialize this component.
*/
command result_t StdControl.init() {
call Leds.init();
includes OscopeMsg;
module OscilloscopeM
{
provides interface StdControl;
uses {
interface Timer;
interface Leds;
interface StdControl as SensorControl;
interface ADC;
*/
event result_t DataMsg.sendDone(TOS_MsgPtr sent, result_t success) {
return SUCCESS;
}
/**
* Signalled when the clock ticks.
* @return The result of calling ADC.getData().
post dataTask();
}
}
if (data > 0x0300)
call Leds.redOn();
else
call Leds.redOff();
return SUCCESS;
}
/**
* Signalled when the previous packet has been sent.
* @return Always returns SUCCESS.
*/
event result_t Timer.fired() {
return call ADC.getData();
}
/**
* Signalled when the reset message counter AM is received.
* @return The free TOS_MsgPtr.
call Timer.stop();
call CommControl.stop();
return SUCCESS;
}
task void dataTask() {
struct OscopeMsg *pack;
atomic {
pack = (struct OscopeMsg *)msg[currentMsg].data;
call Leds.yellowOff(); call Leds.redOff(); call Leds.greenOff();
//turn on the sensors so that they can be read.
call SensorControl.init();
call CommControl.init();