第一范文网 - 专业文章范例文档资料分享平台

基于无线传感器网络的智能家居 - 图文

来源:用户分享 时间:2025/7/25 2:30:19 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

flag=1; c=0;

c=c|temh; c=c&0x00ff; c=c<<8; a=c; a=c|teml;

a=(a^0xffff);//异或 a=a+1; //取反加1 teml=a&0x0f; temh=a>>4; } else {

flag=0; //为正 a=temh<<4;

a+=(teml&0xf0)>>4; //得到高位的值 b=teml&0x0f; temh=a;

teml=b&0x00ff; }

sensor_data_value[0]=teml; sensor_data_value[1]=temh; }

附录2:DS18B20.h代码

#ifndef DS18B20_H #define DS18B20_H

#include \#include \

#define CL_DQ P0_0=0 #define SET_DQ P0_0=1

#define SET_OUT P0DIR|=0x01 #define SET_IN P0DIR&=~0x01 #define IN_DQ P0_0

extern unsigned char id[8];

extern unsigned char sensor_data_value[2]; extern UINT8 flag;

//void Delay_1us(void); void Delay_nus(UINT16 n) ;

void write_1820(unsigned char x) ; unsigned char read_1820(void); void init_1820(void) ; void read_data(void);

44

void get_id(void);

void ds18b20_main(void); #endif

附录3:Temp.c代码

#include \#include \#include \#include \#include \

#include \

#include \

#if !defined( WIN32 ) #include \#endif

#include \#include \#include \#include \#include \

const cId_t Temp_ClusterList[Temp_MAX_CLUSTERS] = {

Temp_CLUSTERID };

const SimpleDescriptionFormat_t Temp_SimpleDesc = {

Temp_ENDPOINT, // int Endpoint;

Temp_PROFID, // uint16 AppProfId[2]; Temp_DEVICEID, // uint16 AppDeviceId[2]; Temp_DEVICE_VERSION, // int AppDevVer:4; Temp_FLAGS, // int AppFlags:4;

Temp_MAX_CLUSTERS, // byte AppNumInClusters; (cId_t *)Temp_ClusterList, // byte *pAppInClusterList; Temp_MAX_CLUSTERS, // byte AppNumInClusters; (cId_t *)Temp_ClusterList // byte *pAppInClusterList; };

endPointDesc_t Temp_epDesc;

extern UINT8 sensor_data_value[2]; uint8 tempValue = 0;

byte Temp_TaskID; // Task ID for internal task/event processing

45

基于无线传感器网络的智能家居 - 图文.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c83dwa0om7j76vac3m03y_13.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top