导航:首页 > 操作系统 > 单片机湿度检测

单片机湿度检测

发布时间:2022-12-21 14:24:44

Ⅰ 基于C52单片机温湿度监测系统 求高手指点迷津

1、加红外收发装置与其系统通讯
2、扩展块FLASH存储检测数据本存储
3、加钟采用专用历芯片反显示1602便

Ⅱ Proteus仿真单片机测量空气湿度

几点说明:

1.主要是分以下几个模块写的:SHT10,LCD1602,主函数,头文件。

2.每支SHTxx传感器都在25℃(77 °F)和 3.3V条件下进行过标定并且完全符合精度指标.因为考虑到实际硬件5V的电压比较好操作,所以SHT10用的精度采用的为5V时的参数。其他的都采取默认值(14bit湿度, 12bit 温度)。

3.SHT10中所以部分我都编写了。有的部分在本次程序中没用到,也可以作为参考。

4.所有程序都已经加了注释,且有仿真图。

5.个人认为还可以在此基础上添加个中断。

6.程序编写keil 4 ,仿真 protues7.5

/***********************************************************************************************************************************************************/

头文件(tou.h):

#ifndef __TOU_H__

#define __TOU_H__

#include<reg52.h>

#include <intrins.h>

//#include <math.h> //Keil library

#define uchar unsigned char

enum {TEMP,HUMI};

sbit DATA = P1^7;

sbit SCK = P1^6;

sbit LcdRs= P2^4;

sbit LcdRw= P2^5;

sbit LcdEn= P2^6;

sfr DBPort= 0x80; //P0=0x80,P1=0x90,P2=0xA0,P3=0xB0.数据端口

/******** DS1602函数声明 ********/

void LCD_Initial();

void GotoXY(unsigned char x, unsigned chary);

void Print(unsigned char *str);

void LCD_Write(bit style, unsigned charinput);

/******** SHT10函数声明 ********/

void s_connectionreset(void);

char s_measure(unsigned char *p_value,unsigned char *p_checksum, unsigned char mode);

void calc_sth10(float *p_humidity ,float*p_temperature);

//float calc_dewpoint(float h,float t);

#endif

/***********************************************************************************************************************************************************/

SHT10程序(SHT10.c):

#include<tou.h>

#define noACK 0 //继续传输数据,用于判断是否结束通讯

#define ACK 1//结束数据传输;

//地址命令 读/写

#define STATUS_REG_W 0x06 //0000011 0

#define STATUS_REG_R 0x07 //0000011 1

#define MEASURE_TEMP 0x03 //0000001 1

#define MEASURE_HUMI 0x05 //0000010 1

#define RESET 0x1e//000 1111 0

//写字节程序

char s_write_byte(unsigned char value)

{

unsignedchar i,error=0;

for(i=0x80;i>0;i>>=1)//高位为1,循环右移

{

if(i&value) DATA=1; //和要发送的数相与,结果为发送的位

else DATA=0;

SCK=1;

_nop_();_nop_();_nop_(); //延时3us

SCK=0;

}

DATA=1; //释放数据线

SCK=1;

error=DATA; //检查应答信号,确认通讯正常

_nop_();_nop_();_nop_();

SCK=0;

DATA=1;

returnerror; //error=1 通讯错误

}

//读字节程序

char s_read_byte(unsigned char ack)

//----------------------------------------------------------------------------------

{

unsignedchar i,val=0;

DATA=1; //释放数据线

for(i=0x80;i>0;i>>=1) //高位为1,循环右移

{

SCK=1;

if(DATA) val=(val|i); //读一位数据线的值

SCK=0;

}

DATA=!ack; //如果是校验,读取完后结束通讯;

SCK=1;

_nop_();_nop_();_nop_(); //延时3us

SCK=0;

_nop_();_nop_();_nop_();

DATA=1; //释放数据线

returnval;

}

//启动传输

void s_transstart(void)

// generates a transmission start

//_____ ________

// DATA: |_______|

//___ ___

// SCK : ___| |___||______

{

DATA=1; SCK=0; //准备

_nop_();

SCK=1;

_nop_();

DATA=0;

_nop_();

SCK=0;

_nop_();_nop_();_nop_();

SCK=1;

_nop_();

DATA=1;

_nop_();

SCK=0;

}

//连接复位

void s_connectionreset(void)

// communication reset: DATA-line=1 and atleast 9 SCK cycles followed by transstart

//_____________________________________________________ ________

// DATA:|_______|

//_ _ __ _ __ _ ____ ___

// SCK : __| |__| |__| |__| |__| |__| |__||__| |__| |______| |___| |______

{

unsignedchar i;

DATA=1;SCK=0; //准备

for(i=0;i<9;i++) //DATA保持高,SCK时钟触发9次,发送启动传输,通迅即复位

{

SCK=1;

SCK=0;

}

s_transstart(); //启动传输

}

//软复位程序

char s_softreset(void)

// resets the sensor by a softreset

{

unsignedchar error=0;

s_connectionreset(); //启动连接复位

error+=s_write_byte(RESET); //发送复位命令

returnerror; //error=1 通讯错误

}

/*读状态寄存器

char s_read_statusreg(unsigned char*p_value, unsigned char *p_checksum)

//----------------------------------------------------------------------------------

// reads the status register with checksum(8-bit)

{

unsignedchar error=0;

s_transstart(); //transmission start

error=s_write_byte(STATUS_REG_R);//send command to sensor

*p_value=s_read_byte(ACK); //read status register (8-bit)

*p_checksum=s_read_byte(noACK); //read checksum (8-bit)

returnerror; //error=1 incase of no response form the sensor

}

Ⅲ 51单片机的温湿度检测中加入一个PM值检测模块,两个模块是并行的吗

单片机的程序不是并行的.
每个检测都是分先后次序进行的.

Ⅳ 51单片机c语言编程的温湿度检测控制程序

/********************************************************************
*
文件名

温度采集DS18B20.c
*
描述
:
该文件实现了用温度传感器件DS18B20对温度的采集,并在数码管上显示出来。
*
创建人

东流,2009年4月10日
*
版本号

2.0
***********************************************************************/
#include<reg52.h>
#define
uchar
unsigned
char
#define
uint
unsigned
int
#define
jump_ROM
0xCC
#define
start
0x44
#define
read_EEROM
0xBE
sbit
DQ
=
P2^3;
//DS18B20数据口
unsigned
char
TMPH,TMPL;
uchar
code
table[10]
=
{0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
/********************************************************************
*
名称
:
delay()
*
功能
:
延时,延时时间大概为140US。
*
输入
:

*
输出
:

***********************************************************************/
void
delay_1()
{
int
i,j;
for(i=0;
i<=10;
i++)
for(j=0;
j<=2;
j++)
;
}
/********************************************************************
*
名称
:
delay()
*
功能
:
延时函数
*
输入
:

*
输出
:

***********************************************************************/
void
delay(uint
N)
{
int
i;
for(i=0;
i<N;
i++)
;
}
/********************************************************************
*
名称
:
Delay_1ms()
*
功能
:
延时子程序,延时时间为
1ms
*
x
*
输入
:
x
(延时一毫秒的个数)
*
输出
:

***********************************************************************/
void
Delay_1ms(uint
i)//1ms延时
{
uchar
x,j;
for(j=0;j<i;j++)
for(x=0;x<=148;x++);
}
/********************************************************************
*
名称
:
Reset()
*
功能
:
复位DS18B20
*
输入
:

*
输出
:

***********************************************************************/
uchar
Reset(void)
{
uchar
deceive_ready;
DQ
=
0;
delay(29);
DQ
=
1;
delay(3);
deceive_ready
=
DQ;
delay(25);
return(deceive_ready);
}
/********************************************************************
*
名称
:
read_bit()
*
功能
:
从DS18B20读一个位值
*
输入
:

*
输出
:
从DS18B20读出的一个位值
***********************************************************************/
uchar
read_bit(void)
{
uchar
i;
DQ
=
0;
DQ
=
1;
for(i=0;
i<3;
i++);
return(DQ);
}
/********************************************************************
*
名称
:
write_bit()
*
功能
:
向DS18B20写一位
*
输入
:
bitval(要对DS18B20写入的位值)
*
输出
:

***********************************************************************/
void
write_bit(uchar
bitval)
{
DQ=0;if(bitval==1)
DQ=1;
delay(5);
DQ=1;
}
/********************************************************************
*
名称
:
read_byte()
*
功能
:
从DS18B20读一个字节
*
输入
:

*
输出
:
从DS18B20读到的值
***********************************************************************/
uchar
read_byte(void)
{
uchar
i,m,receive_data;
m
=
1;
receive_data
=
0;
for(i=0;
i<8;
i++)
{
if(read_bit())
{
receive_data
=
receive_data
+
(m
<<
i);
}
delay(6);
}
return(receive_data);
}
/********************************************************************
*
名称
:
write_byte()
*
功能
:
向DS18B20写一个字节
*
输入
:
val(要对DS18B20写入的命令值)
*
输出
:

***********************************************************************/
void
write_byte(uchar
val)
{
uchar
i,temp;
for(i=0;
i<8;
i++)
{
temp
=
val
>>
i;
temp
=
temp
&
0x01;
write_bit(temp);
delay(5);
}
}
/********************************************************************
*
名称
:
Main()
*
功能
:
主函数
*
输入
:

*
输出
:

***********************************************************************/
void
main()
{
float
tt;
uint
temp;
P2
=
0x00;
while(1)
{
Reset();
write_byte(jump_ROM);
write_byte(start);
Reset();
write_byte(jump_ROM);
write_byte(read_EEROM);
TMPL
=
read_byte();
TMPH
=
read_byte();
temp
=
TMPL
/
16
+
TMPH
*
16;
P0
=
table[temp/10%10];
P2
=
6;
Delay_1ms(5);
P0
=
table[temp%10];
P2
=
7;
Delay_1ms(5);
}
}

Ⅳ 单片机C语言编程 用DHT11进行湿度检测

嵌入式的编程对硬件依赖较大,不同硬件结构编出来的程序时序上差别很大。不知道你使用的是什么单片机?怎么连线驱动DHT11的?

Ⅵ 基于单片机的温湿度检测系统设计

<<pic单片机应用系统开发典型实例〉〉有差不多的例子,不过 是数码显示,不是液晶显示。液晶程序上网上找就行啊,www.pic16.com上有很多程序,或许有现成的。

Ⅶ 单片机温度湿度光照检测,能问下这5各部分是什么吗。。。

1:电位器 调液晶亮度的
2:蜂鸣器 报警音
3:继电器 隔离控制高压端
4:不知道是个什么模块,看不到正面
5:温湿度传感器

Ⅷ 温湿度传感器为什么要接单片机的中断口才可以监测

因为单片机在温湿度传感器中是以最小系统作为核心控制电路的,同时控制传感器采集的温湿度的转换。
单片机是一种集成电路芯片,是采用超大规模集成电路技术把具有数据处理能力的中央处理器CPU、随机存储器RAM、只读存储器ROM、多种I/O口和中断系统、定时器/计数器等功能(可能还包括显示驱动电路、脉宽调制电路、模拟多路转换器、A/D转换器等电路)集成到一块硅片上构成的一个小而完善的微型计算机系统,在工业控制领域广泛应用。

Ⅸ 基于单片机温湿度测量系统(摘要翻译)

Along with the humiture examination system's widespread utilization, the different profession and the domain have the various requirement and the standard to the humiture examination. This design mainly uses in the ordinary indoor humiture survey. Uses the DS2438, HIH3605B integration chip to take the humiture sensor. In the article has analyzed the humiture survey principle of work and the process, proposed the humiture examination system design's overall plan, has carried on the plan proof to each submole design and compares. The hardware design uses protel the 99se software, has completed the monolithic integrated circuit smallest system, the LCD display circuit, sensor's schematic diagram and the PCB chart. The software design uses Keil uVision2, has completed the program mole each mole design programming, has realized to the humiture signal processing process programming and the debugging. This measurement system humidity measuring range 0%~100%, resolution ±2%; Temperature survey scope - 40~+125℃, resolution ±0.5℃. Can meet the daily life humiture survey requirements.

key words: AT89S52; HIH3605B; DS2438; LCD; Data acquisition; Data processing

阅读全文

与单片机湿度检测相关的资料

热点内容
能否给隐藏相册加密 浏览:596
糖心app改什么名 浏览:823
战地1控服务器如何部署 浏览:394
xp还原系统输入命令 浏览:323
mysql命令行版本 浏览:303
如何进入itunes找文件夹 浏览:832
CAD中重复命令使用 浏览:477
心智pdf 浏览:475
网站电台直播间源码 浏览:852
文件夹14c和18c的区别 浏览:34
android隐式调用 浏览:667
plc的编程指令边沿继电器 浏览:723
voc文件夹 浏览:865
租广东联通服务器注意什么云空间 浏览:934
javascript高级程序设计pdf 浏览:292
pwm单片机原理 浏览:348
ai算法在线修复图片 浏览:982
scratch编程中如何做射击游戏 浏览:479
at89c51编程器 浏览:344
项目经理叫醒程序员 浏览:344