当前位置:网站首页>基于51单片机的温湿度监测+定时报警系统(c51源码)
基于51单片机的温湿度监测+定时报警系统(c51源码)
2022-04-23 06:14:00 【锦官城外w】
功能说明:
1.DS1302模块实时显示时间(可通过程序初始化显示时间)
2.DHT11温湿度测量
3.按键设定定时报警时间,并将设定值存储至24C02中(掉电后可恢复之前设定数据)
4.LCD1602显示相关信息
注意事项:
处理器:STC89C51/STC89C52
显示屏:LCD1602
ROM存储:24C02
时间显示:DS1302
温湿度测量:DHT11
按键调整报警时间
相关引脚连线中文注释
//---定义lcd1602使用的IO口---//
#define LCD_DATA P0
sbit RS=P2^7;
sbit RW=P2^6;
sbit EN=P2^5;
//---定义 按键 使用的IO口---//
sbit key1=P1^5;
sbit key2=P1^6;
sbit key3=P1^7;
//---定义ds1302使用的IO口---//
sbit SCLK=P1^2;
sbit DSIO=P1^3;
sbit RST=P1^4;
//---DS1302写入和读取时分秒的地址命令---//
//---秒分时日月周年 最低位读写位;-------//
uchar code READ_RTC_ADDR[7] = {
0x81, 0x83, 0x85, 0x87, 0x89, 0x8b, 0x8d};
uchar code WRITE_RTC_ADDR[7] = {
0x80, 0x82, 0x84, 0x86, 0x88, 0x8a, 0x8c};
//--- DS1302时钟初始化2021年3月8日16点46分00秒 ---//
//--- 秒 分 时 日 月 周 年 ---//
uchar TIME[7] = {
0, 0x46, 0x16, 0x08, 0x03, 0x01, 0x21};
uchar warn_hour,real_hour;//报警时间,通过读取flash获取
//---定义 dh11 使用的IO口---//
sbit dat=P2^2;
uchar DHT11[5],RTflag=0;
uchar FLAG;
//---定义 2402 使用的IO口---//
sbit SDA=P1^1;
sbit SCL=P1^0;
//---定义 beep 使用的IO口---//
sbit beep=P2^0;
uchar beep_state=1;
//---定义 led 使用的IO口---//
sbit led=P2^1;
主函数代码
void
main()
{
lcd_init(); //1602初始化
init_2402(); //2402初始化
warn_hour =read_data(0); //读出24c02保存的值赋于报警时间
// Ds1302Init(); //需要设时间时开启,默认不需设置时间
while(1) //循环读取 并更新数据显示
{
Ds1302ReadTime(); //读取时间
LcdDisplay(); //显示时间
key_scan(); //扫描按键
DHT11_5(); //读数据
dis_str(12,0,"H:");dis_shu(14,0,warn_hour); //显示报警时间
dis_str(9,1,"S");dis_shu(10,1,DHT11[0]); //湿度
dis_str(13,1,"T");dis_shu(14,1,DHT11[2]); //温度
warn(); //报警
}
}
全部资料链接见评论区,有问题请留言~
作者:amusen
时间:2022.4
祝好!
版权声明
本文为[锦官城外w]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_41740659/article/details/124328867
边栏推荐
- onnxruntime-gpu 1.7 出现的警告“Force fallback to CPU execution for node: Gather_191”等
- Chapter 3 pytoch neural network toolbox
- 直观理解 torch.nn.Unfold
- RISCV MMU 概述
- 【动态规划】三角形最小路径和
- 画 ArcFace 中的 margin 曲线
- 【点云系列】Pointfilter: Point Cloud Filtering via Encoder-Decoder Modeling
- Wechat applet uses wxml2canvas plug-in to generate some problem records of pictures
- torch. mm() torch. sparse. mm() torch. bmm() torch. Mul () torch The difference between matmul()
- 【Tensorflow】共享机制
猜你喜欢

PyMySQL连接数据库
![[Point Cloud Series] SG - Gan: Adversarial Self - attachment GCN for Point Cloud Topological parts Generation](/img/1d/92aa044130d8bd86b9ea6c57dc8305.png)
[Point Cloud Series] SG - Gan: Adversarial Self - attachment GCN for Point Cloud Topological parts Generation

【点云系列】点云隐式表达相关论文概要

第1章 NumPy基础

FATFS FAT32学习小记

EasyUI combobox determines whether the input item exists in the drop-down list

rearrange 和 einsum 真的优雅吗

Mysql database installation and configuration details

Device Tree 详解

Summary of image classification white box anti attack technology
随机推荐
Résolution du système
Solution to slow compilation speed of Xcode
scons 搭建嵌入式arm编译
【点云系列】Relationship-based Point Cloud Completion
Mysql database installation and configuration details
Compression and acceleration technology of deep learning model (I): parameter pruning
PyTorch 21. PyTorch中nn.Embedding模块
【技术规范】:如何写好技术文档?
【期刊会议系列】IEEE系列模板下载指南
画 ArcFace 中的 margin 曲线
PyTorch 20. PyTorch技巧(持续更新)
torch.where能否传递梯度
Systrace 解析
【点云系列】点云隐式表达相关论文概要
【动态规划】不同路径2
【点云系列】FoldingNet:Point Cloud Auto encoder via Deep Grid Deformation
【点云系列】Fully-Convolutional geometric features
Face_ Recognition face detection
【点云系列】Pointfilter: Point Cloud Filtering via Encoder-Decoder Modeling
安装 pycuda 出现 PEP517 的错误