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

stm32+HTU21D温湿度传感器

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

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

stm32+HTU21D温湿度传感器通过usart1发送温湿度数据在串口助手显示_第1张图片

看一下串口助手显示的图片
stm32+HTU21D温湿度传感器通过usart1发送温湿度数据在串口助手显示_第2张图片

另外把里面的详细数据放出来给大家细品
前面的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多了
代码是按照文档来写的可能和文档里面的算法有关
在这里插入图片描述
在这里插入图片描述

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

你可能感兴趣的:(stm32f103vet6)