【Silicon Labs 开发套件评测】+温湿度传感器Si7021
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">我们开发套件上使用的温湿度集成一体的数字传感器</font><font face="Calibri">Si7021</font><font face="宋体">,</font><font face="Calibri">I2C</font><font face="宋体">接口,开发板上</font><font face="Calibri">I2C</font><font face="宋体">接口传感器都挂载一个总线上。</font></span></span></span></span></p><p style="text-indent:21.0000pt; text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">通过开关来使能是否使用总线。这里使用的</font><font face="Calibri">TS3A4751</font><font face="宋体">是</font><font face="Calibri">Ti</font><font face="宋体">的</font><font face="Calibri">4</font><font face="宋体">通道模拟开关。</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">温湿度传感器使用的是自家的传感器芯片。要了解详细的资料关注官网:</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><a href="https://www.silabs.com/sensors/humidity/si7006-13-20-21-34/device.si7021-a20-gm"><u><span class="15" style="font-family:Calibri"><span style="color:#0000ff"><span style="text-decoration:underline"><span style="text-underline:single">https://www.silabs.com/sensors/humidity/si7006-13-20-21-34/device.si7021-a20-gm</span></span></span></span></u></a></span></span></p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">从</font><font face="Calibri">Si7021</font><font face="宋体">传感器数据表中我们获取信息:</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">湿度感应范围是</font><font face="Calibri">0~100%</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">温度感应范围是</font><font face="Calibri">-40~+125</font><font face="宋体">摄氏度。</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">参考电路</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="Calibri">I2C</font><font face="宋体">接口从机地址是</font><font face="Calibri">0x40</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">湿度计算公式</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">温度计算公式</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">基本信息了解之后,我们开始在</font><font face="Calibri">SSv5</font><font face="宋体">上操作了。</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">我们还在在前面的工程上实现,打开</font><font face="Calibri">control.slcp</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">在</font><font face="Calibri">Board Control</font><font face="宋体">下进入</font><font face="Calibri">configure</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">打开温湿度传感器开关,控制</font><font face="Calibri">GPIO</font><font face="宋体">是</font><font face="Calibri">PC06</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">然后在</font><font face="Calibri">platform->board Drivers</font><font face="宋体">下找到</font><font face="Calibri">Si70xx-</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">点击</font><font face="Calibri">install</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">这样</font><font face="Calibri">Si7021</font><font face="宋体">传感器的驱动就添加上了。</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">然后安装</font><font face="Calibri">I2C</font><font face="宋体">总线驱动</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">点击</font><font face="Calibri">install</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">点击</font><font face="Calibri">Done</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">安装完成之后点击</font><font face="Calibri">configure</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">可以看到</font><font face="Calibri">MCU</font><font face="宋体">外设配置信息</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">添加一个传感器任务</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">把读取的数据通过虚拟串口打印出来</font></span></span></span></span></p>
<p style="text-indent:21.0000pt; text-align:justify"> </p>
<p style="text-indent:21.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">不知道为什么不能打印浮点数,所有数据是乘了</font><font face="Calibri">100</font><font face="宋体">后打印的。到这里温湿度传感器数据正常显示出来了。</font></span></span></span></span></p>
<p>ide工程配置里面设置下就可以打印浮点数了</p> 本帖最后由 anger0925 于 2021-8-3 09:18 编辑
<div class="quote">
<blockquote><font size="2"><a href="forum.php?mod=redirect&goto=findpost&pid=3081827&ptid=1174452" target="_blank"><font color="#999999">dql2016 发表于 2021-8-3 06:55</font></a></font> ide工程配置里面设置下就可以打印浮点数了</blockquote>
</div>
<p>我已经设置了的还不行</p>
<p> printf("Humi:%.2f\r\n",(float)temp_data/10.0f);<br />
printf("Humi:%.2f\r\n",(float)rh_data/10.0f);<br />
</p>
<p>感谢分享,还不错,浮点型那个确实是个问题。多试试一些解决方案。</p>
<p>nano C Library换一个试试。</p>
页:
[1]