stm32+HTU21D温湿度传感器通过usart1发送温湿度数据在串口助手显示

stm32+HTU21D温湿度传感器

这里就不拍实物图了,我用的是下面这款HTU21D
在这里插入图片描述
ic是stm32f103vet6
工程代码是io口模拟i2c和传感器通讯
PB6—SCL,PB7—SDA
usart1发送温湿度数据在串口助手显示

工程是按照HTU21D的英文手册来写的,用的No Hold master模式
为了避免麻烦没有使用Hold master
也是简单的对HTU21D进行测试,还有很多待修改的地方
之后我也会上传SCDN链接放在评论区,没有积分的小伙伴可以微信扫码回复HTU21D获得百度网盘链接自行下载

在这里插入图片描述

看一下串口助手显示的图片
在这里插入图片描述

另外把里面的详细数据放出来给大家细品
前面的1234打印是我调试的过程,不要在意

1234The htu measure temp is :28.65C 

1234The htu measure humi is :62.36RH 
1234The htu measure temp is :28.65C 

1234The htu measure humi is :57.96RH 
1234The htu measure temp is :28.65C 

1234The htu measure humi is :65.29RH 
1234The htu measure temp is :29.34C 

1234The htu measure humi is :63.34RH 
1234The htu measure temp is :29.34C 

1234The htu measure humi is :62.85RH 
1234The htu measure temp is :29.34C 

1234The htu measure humi is :57.96RH 
1234The htu measure temp is :29.34C 

1234The htu measure humi is :58.45RH 
1234The htu measure temp is :29.34C 

1234The htu measure humi is :57.48RH 
1234The htu measure temp is :29.34C 

1234The htu measure humi is :57.48RH 
1234The htu measure temp is :29.34C 

1234The htu measure humi is :57.96RH 
1234The htu measure temp is :30.71C 

1234The htu measure humi is :97.03RH 
1234The htu measure temp is :31.40C 

1234The htu measure humi is :89.70RH 
1234The htu measure temp is :32.09C 

1234The htu measure humi is :89.21RH 
1234The htu measure temp is :32.09C 

1234The htu measure humi is :57.48RH 
1234The htu measure temp is :31.40C 

1234The htu measure humi is :50.64RH 
1234The htu measure temp is :31.40C 

1234The htu measure humi is :51.13RH 
1234The htu measure temp is :31.40C 

1234The htu measure humi is :53.08RH 
1234The htu measure temp is :30.71C 

1234The htu measure humi is :51.13RH 
1234The htu measure temp is :30.03C 

1234The htu measure humi is :50.64RH 
1234The htu measure temp is :29.34C 

1234The htu measure humi is :50.64RH 
1234The htu measure temp is :29.34C 

1234The htu measure humi is :60.41RH 
1234The htu measure temp is :29.34C 

1234The htu measure humi is :54.55RH 
1234The htu measure temp is :28.65C 

1234The htu measure humi is :54.06RH 
1234The htu measure temp is :28.65C 

1234The htu measure humi is :56.01RH 
1234The htu measure temp is :27.97C 

1234The htu measure humi is :58.45RH 
1234The htu measure temp is :27.97C 

1234The htu measure humi is :61.38RH 
1234The htu measure temp is :28.65C 

1234The htu measure humi is :57.48RH 
1234The htu measure temp is :28.65C 

1234The htu measure humi is :76.03RH 
1234The htu measure temp is :30.71C 

1234The htu measure humi is :102.40RH 
1234The htu measure temp is :29.34C 

1234The htu measure humi is :59.92RH 
1234The htu measure temp is :28.65C 

1234The htu measure humi is :55.52RH 
1234The htu measure temp is :28.65C 

1234The htu measure humi is :57.96RH 
1234The htu measure temp is :27.97C 

1234The htu measure humi is :58.94RH 
1234The htu measure temp is :27.97C 

1234The htu measure humi is :59.92RH 

这组数据你仔细品会发现,温度只能精确到整数,小数后面一定和其他相同整数的相同
不过湿度数据我没有在意,湿度挺灵敏的,手指放上去一下就从50到90多了
代码是按照文档来写的可能和文档里面的算法有关
在这里插入图片描述
在这里插入图片描述

好吧这种细节问题就不去深究了
大家一起加油啊!
在这里插入图片描述

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值