[家庭智慧照明控制与室内环境监测系统] --10. 结项贴
本帖最后由 传媒学子 于 2021-7-17 18:12 编辑<p style="text-align: center;"><span style="font-size:26px;"><strong>家庭智慧照明控制与室内环境监测系统 </strong></span></p>
<p style="text-align: center;"> </p>
<p style="text-align: center;"><iframe allowfullscreen="true" frameborder="0" height="510" src="https://training.eeworld.com.cn/shareOpenCourseAPI?isauto=true&lessonid=30539" style="background:#eee;margin-bottom:10px;" width="750"></iframe></p>
<p style="text-align: center;"> </p>
<p><span style="font-size:24px;"><span style="font-family:宋体;"><strong>0.前言</strong></span></span></p>
<p><span style="font-size:16px;"> <span style="font-family:宋体;"> 本次大赛是对自我知识盲区的又一次挑战,从对蓝牙一窍不通,到基本能够读懂例程,修改例程,移植例程实现自己的想法;整个过程让人既痛苦又兴奋。BLE作为蓝牙技术的低功耗场景技术,已经融入到了我们生活中的方方面面。非常有幸能参加这次由安森美半导体和安富利赞助,EEWorld论坛举办的这场设计大赛。当能用手机通过BLE无线控制灯光开合的时候,我感觉到了自我突破的乐趣。希望我的作品能给大家带来乐趣,同时也希望相关代码能帮助到其它开发者。</span></span></p>
<p> </p>
<p><span style="font-size:10.5pt"><span style="font-family:"Times New Roman",serif"><span style="font-size:16.0pt"><span style="font-family:"微软雅黑",sans-serif">一、作品简介</span></span></span></span></p>
<p> </p>
<p style="text-indent:21.0pt; text-align:justify"><span style="font-size:10.5pt"><span style="125%"><span style="font-family:"Times New Roman",serif"><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">房间内有3个灯,均是传统的按压开关;而房子的开关位置设计的不太合理,因此,晚上睡觉时,需要下床去关灯,略显不便;结合RSL10的BLE通信能力,本作品设计了一个小型系统,通过手机app来实现对3个开关的无线控制,并且获取RSL10的beacon温度。</span></span></span></span></span></span></p>
<p> </p>
<p style="text-indent:21.0pt; text-align:justify"><span style="font-size:10.5pt"><span style="125%"><span style="font-family:"Times New Roman",serif"><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">如果按照商用标准来开发,需要软件工程师,结构工程师,显然是不太现实的。因此,本作品从技术原理上,实现了预期的功能:手机app通过BLE控制室内3个开关并读取温度。三个开关的作品图如下,读取温度用的是COIN-GEVB.</span></span></span></span></span></span></p>
<p style="text-indent:21.0pt; text-align:justify"> </p>
<p style="text-indent:21.0pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:"Times New Roman",serif"><span lang="EN-US" style="font-size:12.0pt"><span style="font-family:"微软雅黑",sans-serif"><strong>3</strong></span></span><strong><span style="font-size:12.0pt"><span style="font-family:"微软雅黑",sans-serif">个自制的智能开关</span></span></strong></span></span></p>
<p style="text-align:justify"> <span style="font-size:10.5pt"><span style="font-family:"Times New Roman",serif"> </span></span></p>
<p style="margin-bottom:10px; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:"Times New Roman",serif"><span style="font-size:16.0pt"><span style="font-family:"微软雅黑",sans-serif">二、系统框图</span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:"Times New Roman",serif"><b><span lang="EN-US" style="font-size:12.0pt"><span style="font-family:"微软雅黑",sans-serif">2.1</span></span></b><b><span style="font-size:12.0pt"><span style="font-family:"微软雅黑",sans-serif">系统原理图</span></span></b></span></span></p>
<p style="text-indent:21.0pt; text-align:justify"><span style="font-size:10.5pt"><span style="125%"><span style="font-family:"Times New Roman",serif"><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">本项目实现采用RSL10 BLE通信技术,实现对开关节点的无线控制;通过手机蓝牙作为Central设备,而开关节点作为server设备,进行双向通信。系统原理图如下所示;</span></span></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:"Times New Roman",serif"><b><span lang="EN-US" style="font-size:12.0pt"><span style="font-family:"微软雅黑",sans-serif">2.2 </span></span></b><b><span style="font-size:12.0pt"><span style="font-family:"微软雅黑",sans-serif">软件流程图</span></span></b></span></span></p>
<p style="text-indent:21.0pt; text-align:justify"><span style="font-size:10.5pt"><span style="125%"><span style="font-family:"Times New Roman",serif"><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">软件部分分为2个部分,外围设备和手机APP。外围设备为3个无线开关和1个COIN-GEVB。COIN-GEVB板子程序为demo程序,这里不再赘述。手机app和无线开关的程序流程图如下所示。</span></span></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:"Times New Roman",serif"><span style="font-size:16.0pt"><span style="font-family:"微软雅黑",sans-serif">三、各部分功能说明</span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:"Times New Roman",serif"><b><span lang="EN-US" style="font-size:12.0pt"><span style="font-family:"微软雅黑",sans-serif">3.1 </span></span></b><b><span style="font-size:12.0pt"><span style="font-family:"微软雅黑",sans-serif">开关硬件模块</span></span></b></span></span></p>
<p style="text-indent:21.0pt; text-align:justify"><span style="font-size:10.5pt"><span style="125%"><span style="font-family:"Times New Roman",serif"><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">目前的家用开关,基本上都是机械的单火线控制开关,而且是220V的市电,有一定的危险性;因此,决定利用采用外接机械进行控制;舵机驱动板子的供电电源,可以外接光伏发电设备,结合RSL10的低功耗特性,可实现家庭清洁自循环。</span></span></span></span></span></span></p>
<p style="text-indent:21.0pt; text-align:justify"><span style="font-size:10.5pt"><span style="125%"><span style="font-family:"Times New Roman",serif"><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">舵机可以实现较为精确的角度控制,可以用来控制机械开关的开合。RSL10自带了I2C外设,通过I2C来控制PCA9685生成PWM来驱动舵机;对于机械开关的开合,可以设定2个角度。而角度的设定需要针对每个开关进行整定。</span></span></span></span></span></span></p>
<p style="text-indent:21.0pt; text-align:justify"> </p>
<p style="text-align:justify"><strong>开关硬件模块原理图</strong></p>
<p><strong>单节点实物图</strong></p>
<p></p>
<p style="text-align:justify"> <span style="font-size:10.5pt"><span style="font-family:"Times New Roman",serif"><b><span lang="EN-US" style="font-size:12.0pt"><span style="font-family:"微软雅黑",sans-serif">3.2</span></span></b><b><span style="font-size:12.0pt"><span style="font-family:"微软雅黑",sans-serif"> 程序设计</span></span></b></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="125%"><span style="font-family:"Times New Roman",serif"><b><span lang="EN-US" style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">3.2.1 I2C</span></span></span></b><b><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">程序移植</span></span></span></b></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="125%"><span style="font-family:"Times New Roman",serif"><span lang="EN-US" style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">I2C</span></span></span><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">的移植花费了一些时间,需要对官方提供的库进行深入的理解;</span></span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="125%"><span style="font-family:"Times New Roman",serif"><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">该部分代码移植可以参考<a href="https://bbs.eeworld.com.cn/thread-1166483-1-1.html" style="color:#0563c1; text-decoration:underline">https://bbs.eeworld.com.cn/thread-1166483-1-1.html</a>;</span></span></span></span></span></span></p>
<p style="text-align:justify"><strong><span style="font-size:10.5pt"><span style="125%"><span style="font-family:"Times New Roman",serif"><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">基本的原子函数write_u8:</span></span></span></span></span></span></strong></p>
<p style="text-align:justify"></p>
<p style="text-align:justify"><strong><span style="font-size:10.5pt"><span style="font-family:"Times New Roman",serif"><span style="font-size:12.0pt"><span style="font-family:宋体">基本的原子函数read_u8:</span></span></span></span></strong></p>
<p style="text-align:justify"></p>
<p align="center" style="text-align:center"> </p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="125%"><span style="font-family:"Times New Roman",serif"><b><span lang="EN-US" style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">3.2.2 BLE</span></span></span></b><b><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">处理函数</span></span></span></b></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="125%"><span style="font-family:"Times New Roman",serif"><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">为了调试方便,将舵机的转动角度用数值表示,从0~0x50进行变化,舵机角度会发生对应的变化。</span></span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="125%"><span style="font-family:"Times New Roman",serif"><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">因此相应的程序如下:</span></span></span></span></span></span></p>
<p style="text-align:justify"></p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="125%"><span style="font-family:"Times New Roman",serif"><b><span lang="EN-US" style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">3.2.3 </span></span></span></b><b><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">手机app</span></span></span></b></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="125%"><span style="font-family:"Times New Roman",serif"><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">手机app支持Android和iOS两种,最终的调试是基于light blue软件进行的,这是一款基于iOS的开源BLE客户端。</span></span></span><span lang="EN-US" style="font-size:12.0pt"><span style="125%"> <a href="https://github.com/Pluto-Y/Swift-LightBlue" style="color:#0563c1; text-decoration:underline">https://github.com/Pluto-Y/Swift-LightBlue</a></span></span><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">,</span></span></span><span lang="EN-US" style="font-size:12.0pt"><span style="125%">AppStore</span></span><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">可以下载到相应的</span></span></span><span lang="EN-US" style="font-size:12.0pt"><span style="125%">demo app</span></span><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">;本人对于</span></span></span><span lang="EN-US" style="font-size:12.0pt"><span style="125%">app</span></span><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">开发比较陌生,采用了</span></span></span><span lang="EN-US" style="font-size:12.0pt"><span style="125%">demo app</span></span><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">,进行调试,</span></span></span><span lang="EN-US" style="font-size:12.0pt"><span style="125%">APP</span></span><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">如下:</span></span></span></span></span></span></p>
<p style="text-align:justify"></p>
<p align="center" style="text-align:center"> </p>
<p style="margin-bottom:10px; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:"Times New Roman",serif"><b><span style="font-size:16.0pt"><span style="font-family:"微软雅黑",sans-serif">四、作品源码</span></span></b></span></span></p>
<p style="text-indent:21.0pt; text-align:justify"><span style="font-size:10.5pt"><span style="125%"><span style="font-family:"Times New Roman",serif"><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">见附件。</span></span></span></span></span></span></p>
<p style="text-indent:21.0pt; text-align:justify"> </p>
<p style="margin-bottom:10px; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:"Times New Roman",serif"><b><span style="font-size:16.0pt"><span style="font-family:"微软雅黑",sans-serif">五、作品功能演示视频</span></span></b></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:"Times New Roman",serif"><b><span style="font-size:12.0pt"><span style="font-family:宋体">温度获取功能可参阅帖子:</span></span></b></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:"Times New Roman",serif"><b><span style="font-size:12.0pt"><span style="font-family:宋体"><a href="https://bbs.eeworld.com.cn/thread-1164149-1-1.html#pid3060943" style="color:#0563c1; text-decoration:underline">https://bbs.eeworld.com.cn/thread-1164149-1-1.html#pid3060943</a>;</span></span></b></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:"Times New Roman",serif"><b><span lang="EN-US" style="font-size:12.0pt"><span style="font-family:宋体">App</span></span></b><b><span style="font-size:12.0pt"><span style="font-family:宋体">控制三个开关的作品视频链接:<a href="https://training.eeworld.com.cn/video/30539" style="color:#0563c1; text-decoration:underline">https://training.eeworld.com.cn/video/30539</a>;</span></span></b></span></span></p>
<p style="text-align:justify"> </p>
<p style="margin-bottom:10px; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:"Times New Roman",serif"><b><span style="font-size:16.0pt"><span style="font-family:"微软雅黑",sans-serif">六、项目总结</span></span></b></span></span></p>
<p style="text-indent:21.0pt; text-align:justify"><span style="font-size:10.5pt"><span style="125%"><span style="font-family:"Times New Roman",serif"><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">本项目基本上完成了预期的设想,但碍于自身缺乏App设计等能力,无法将作品完美呈现,只能是以demo形式展现出来。总体来讲,安森美的这款RSL10 BLE解决方案是非常棒的,超低功耗的无线连接;完成的开发环境,以及多样化的demo都极大的方便了开发者。</span></span></span></span></span></span></p>
<p style="text-indent:21.0pt; text-align:justify"> </p>
<p style="text-align:justify"><strong><span style="font-size:10.5pt"><span style="125%"><span style="font-family:"Times New Roman",serif"><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">发帖链接:</span></span></span></span></span></span></strong></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="125%"><span style="font-family:"Times New Roman",serif"><span lang="EN-US" style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">1. </span></span></span><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">开箱贴&暖场贴</span></span></span><span style="font-size:12.0pt"><span style="125%"> <a href="https://bbs.eeworld.com.cn/thread-1162962-1-1.html" style="color:#0563c1; text-decoration:underline">https://bbs.eeworld.com.cn/thread-1162962-1-1.html</a></span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="125%"><span style="font-family:"Times New Roman",serif"><span lang="EN-US" style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">2. </span></span></span><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">玩转RSL10-COIN-GEVB </span></span></span><span class="MsoHyperlink" style="color:#0563c1"><span style="text-decoration:underline"><span lang="EN-US" style="font-size:12.0pt"><span style="125%">https://bbs.eeworld.com.cn/thread-1164149-1-1.html</span></span></span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="125%"><span style="font-family:"Times New Roman",serif"><span lang="EN-US" style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">3. RSL10</span></span></span><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">开发环境熟悉 </span></span></span><span class="MsoHyperlink" style="color:#0563c1"><span style="text-decoration:underline"><span lang="EN-US" style="font-size:12.0pt"><span style="125%">https://bbs.eeworld.com.cn/thread-1164619-1-1.html</span></span></span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="125%"><span style="font-family:"Times New Roman",serif"><span lang="EN-US" style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">4.</span></span></span><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">【RSL10】I2C控制PCA9685 PWM输出 </span></span></span><span lang="EN-US" style="font-size:12.0pt"><span style="125%"><a href="https://bbs.eeworld.com.cn/thread-1166483-1-1.html" style="color:#0563c1; text-decoration:underline">https://bbs.eeworld.com.cn/thread-1166483-1-1.html</a></span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="125%"><span style="font-family:"Times New Roman",serif"><span lang="EN-US" style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">5.</span></span></span><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">【RSL10】蓝牙BLE上位机开发1 </span></span></span><span lang="EN-US" style="font-size:12.0pt"><span style="125%"><a href="https://bbs.eeworld.com.cn/thread-1167287-1-1.html" style="color:#0563c1; text-decoration:underline">https://bbs.eeworld.com.cn/thread-1167287-1-1.html</a></span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="125%"><span style="font-family:"Times New Roman",serif"><span lang="EN-US" style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">6. </span></span></span><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">蓝牙BLE上位机开发2 </span></span></span><span lang="EN-US" style="font-size:12.0pt"><span style="125%"><a href="https://bbs.eeworld.com.cn/thread-1170343-1-1.html" style="color:#0563c1; text-decoration:underline">https://bbs.eeworld.com.cn/thread-1170343-1-1.html</a></span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="125%"><span style="font-family:"Times New Roman",serif"><span lang="EN-US" style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">7. </span></span></span><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">修改蓝牙设备名字和地址 </span></span></span><span lang="EN-US" style="font-size:12.0pt"><span style="125%"><a href="https://bbs.eeworld.com.cn/thread-1170344-1-1.html" style="color:#0563c1; text-decoration:underline">https://bbs.eeworld.com.cn/thread-1170344-1-1.html</a></span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="125%"><span style="font-family:"Times New Roman",serif"><span lang="EN-US" style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">8. </span></span></span><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">在ON-SEMI开发软件中合并2个工程 </span></span></span><span lang="EN-US" style="font-size:12.0pt"><span style="125%"><a href="https://bbs.eeworld.com.cn/thread-1170345-1-1.html" style="color:#0563c1; text-decoration:underline">https://bbs.eeworld.com.cn/thread-1170345-1-1.html</a></span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="125%"><span style="font-family:"Times New Roman",serif"><span lang="EN-US" style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">9. </span></span></span><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">单节点蓝牙BLE灯光开关设计 </span></span></span><span lang="EN-US" style="font-size:12.0pt"><span style="125%"><a href="https://bbs.eeworld.com.cn/thread-1170525-1-1.html" style="color:#0563c1; text-decoration:underline">https://bbs.eeworld.com.cn/thread-1170525-1-1.html</a></span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="125%"><span style="font-family:"Times New Roman",serif"><span lang="EN-US" style="font-family:宋体">10. </span><span style="font-family:宋体">作品提交</span><span class="MsoHyperlink" style="color:#0563c1"><span style="text-decoration:underline"><span lang="EN-US" style="font-size:12.0pt"><span style="125%"><a href="https://bbs.eeworld.com.cn/forum.php?mod=post&action=newthread&fid=269" style="color:#0563c1; text-decoration:underline">https://bbs.eeworld.com.cn/forum.php?mod=post&action=newthread&fid=269</a></span></span></span></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:"Times New Roman",serif"><b><span style="font-size:16.0pt"><span style="font-family:"微软雅黑",sans-serif">七、致谢</span></span></b></span></span></p>
<p style="text-indent:21.0pt; text-align:justify"><span style="font-size:10.5pt"><span style="125%"><span style="font-family:"Times New Roman",serif"><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">感谢论坛举办这次大赛,感谢安森美和安富利能够提供开发板和赛前培训。同时,感谢@just0_do等坛友以及论坛管理员的鼓励和帮助;希望大家能够以我的分享,获得灵感;也同时,希望我的作品能给大赛增添些许乐趣。</span></span></span></span></span></span></p>
<p style="text-indent:21.0pt; text-align:justify"><span style="font-size:10.5pt"><span style="125%"><span style="font-family:"Times New Roman",serif"><span style="font-size:12.0pt"><span style="125%"><span style="font-family:宋体">感谢各位!</span></span></span></span></span></span><br />
</p>
<p style="text-align: center;"> </p>
<p>BLE无线控制照明和环境监测都有了,效果还是挺好</p>
<p> </p>
<p>学习了,不错</p>
<p>真不错!考虑好供电问题就更完美了!</p>
页:
[1]