当前位置:网站首页>小熊派开发板实践:智慧路灯沙箱实验之真实设备接入
小熊派开发板实践:智慧路灯沙箱实验之真实设备接入
2020-11-06 22:01:00 【华为云开发者社区】
摘要:尝试用小熊派开发板(E53_SC1、NB35)真实设备代替模拟器完成构建智慧路灯应用实验体验。
智慧路灯是城市智能化道路上重要一环,智慧路灯的实施具有节约公共照明能耗、减少因照明引起的交通事故等多种社会意义。路灯也是大家在日常生活中可以强烈感知到的公共设施,更易理解其智能化的场景。
基于物理网解决方案,我们可以实现路灯的远程监控与控制,实现远程控制、按需照明等功能,降低路灯运行成本。
体验《沙箱实验:基于IoT平台构建智慧路灯应用》实验后,有些小伙伴总觉得模拟器体验没有真实设备好,故小主尝试用小熊派开发板(E53_SC1、NB35)真实设备代替模拟器完成实验体验。其中,大部分操作步骤相同,本文仅列出需要修改及注意的地方。
平台侧:
1、创建产品:
- 模拟器:协议类型为MQTT
- 真实设备:协议类型为LwM2M/CoAP,且需要开发部署编解码插件。
2、配置智慧路灯应用(注册设备):
- 模拟器:设备标识可自定义,如123456789f。
- 真实设备:设备标识填写为NB35通信模组IMEI,可使用串口工具+AT指令(AT+CGSN=1)查询获取设备IMEI。
应用侧:
1、编译构建智慧路灯应用:
创建代码仓库后,需要修改部分代码适配真实设备。
① 修改src/main/java/com/huawei/service/RegisterDirectConnectedDevice.java,添加如下代码。
paramReg.put("device_name", deviceInfo.getVerifyCode());
② 修改src/main/java/com/huawei/service/CreateDeviceCommand.java,变更及添加如下代码。
③ 修改src/main/java/com/huawei/controller/PushReceiver.java,变更及添加如下代码。
2、完成如上修改,重新编译构建出包;再基于新构建的包重新部署路灯应用到ECS服务器。
设备侧:
1、资源准备:
- 模拟器:HubSimulator.jar
- 真实设备:小熊派开发板(E53_SC1、NB35)
2、真实设备需要端侧开发,代码编译、烧录。推荐IDE:VS Code+IoT Link插件
3、基于示例工程创建:oc_streetlight_template
4、修改Demos\oc_streetlight_template\oc_streetlight_template.c,填写对接的IoT平台的实际IP、端口。
#define cn_endpoint_id "BearPi_0001"
#define cn_app_server "119.3.250.80"
#define cn_app_port "5683"
5、完成如上修改,编译烧录即可。
结果验证:
1、请将开发板拨码开关拨到AT+MCU侧,并通过USB连接PC上电,进行数据上报。
2、等待1-2分钟查看应用界面,页面应该显示“环境亮度”为设备上报数值,“灯状态”为toggle状态。
3、“路灯控制”选择“终端联控模式”,开关选择“开”,单击“设置”。
- 查看开发板路灯状态,灯应该点亮。
4、“路灯控制”选择“自动调光模式”,设置亮度阈值为100。
- 若此时设备上报的光感强度大于100,应用会自动下发关灯命令,指示路灯关闭。
- 用手遮住路灯扩展板上的光强传感器,使光强小于100,若路灯是关闭状态,则应用会下发开灯命令,指示路灯开启。
5、“路灯控制”选择“分段定时模式”,设置关灯时间段为06:00-18:30。
- 如果系统当前时间位于关灯时间段内,且路灯状态为开,应用会自动下发关灯命令,指示路灯关闭。
- 如果系统当前时间位于关灯时间段外,且路灯状态为关,应用会自动下发开灯命令,指示路灯开启。
综上,通过路灯开发板作为真实设备的接入体验即完成。
版权声明
本文为[华为云开发者社区]所创,转载请带上原文链接,感谢
https://my.oschina.net/u/4526289/blog/4703547
边栏推荐
- ES中删除索引的mapping字段时应该考虑的点
- 2020年数据库技术大会助力技术提升
- The legality of IPFs / filecoin: protecting personal privacy from disclosure
- Python basic data type -- tuple analysis
- 【ElasticSearch搜索引擎】
- IPFs rudder filecoin landing at the same time, fil currency price broke a thousand
- The native API of the future trend of the front end: web components
- ES6 learning notes (4): easy to understand the new grammar of ES6
- 2020-08-30:裸写算法:二叉树两个节点的最近公共祖先。
- To teach you to easily understand the basic usage of Vue codemirror: mainly to achieve code editing, verification prompt, code formatting
猜你喜欢
Multi robot market share solution
To teach you to easily understand the basic usage of Vue codemirror: mainly to achieve code editing, verification prompt, code formatting
A small goal in 2019 to become a blog expert of CSDN
Look! Internet, e-commerce offline big data analysis best practice! (Internet disk link attached)
非易失性MRAM存储器应用于各级高速缓存
Pn8162 20W PD fast charging chip, PD fast charging charger scheme
Junit测试出现 empty test suite
GitHub: the foundation of the front end
Event monitoring problem
实用工具类函数(持续更新)
随机推荐
2020-08-15:什么情况下数据任务需要优化?
Staying up late summarizes the key points of report automation, data visualization and mining, which is different from what you think
Top 5 Chinese cloud manufacturers in 2018: Alibaba cloud, Tencent cloud, AWS, telecom, Unicom
An article will introduce you to HTML tables and their main attributes
Stickinengine architecture 12 communication protocol
2020-08-19:TCP是通过什么机制保障可靠性的?
C and C / C + + mixed programming series 5 - GC collaboration of memory management
2020-08-29:进程线程的区别,除了包含关系之外的一些区别,底层详细信息?
检测证书过期脚本
Kubernetes and OAM to build a unified, standardized application management platform knowledge! (Internet disk link attached)
Hdu3974 assign the task segment tree DFS order
上海巨微专用蓝牙广播芯片
An article takes you to understand CSS pagination examples
window系统 本机查找端口号占用方法
ORA-02292: 违反完整约束条件 (MIDBJDEV2.SYS_C0020757) - 已找到子记录
意派Epub360丨你想要的H5模板都在这里,电子书、大转盘、红包雨、问卷调查……
How does filecoin's economic model and future value support the price of fil currency breaking through thousands
2020-09-03:裸写算法:回形矩阵遍历。
File download manager realized by electron
With this artifact, quickly say goodbye to spam messages