当前位置:网站首页>小熊派开发板实践:智慧路灯沙箱实验之真实设备接入
小熊派开发板实践:智慧路灯沙箱实验之真实设备接入
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
边栏推荐
- ES6 learning notes (5): easy to understand ES6's built-in extension objects
- 2020年数据库技术大会助力技术提升
- Junit测试出现 empty test suite
- Application insights application insights use application maps to build request link views
- EOS founder BM: what's the difference between UE, UBI and URI?
- ORA-02292: 违反完整约束条件 (MIDBJDEV2.SYS_C0020757) - 已找到子记录
- Summary of front-end interview questions (C, s, s) that front-end engineers need to understand (2)
- To Lianyun analysis: why is IPFs / filecoin mining so difficult?
- 美团内部讲座|周烜:华东师范大学的数据库系统研究
- Python basic data type -- tuple analysis
猜你喜欢
2020-09-03:裸写算法:回形矩阵遍历。
Some operations kept in mind by the front end foundation GitHub warehouse management
美团内部讲座|周烜:华东师范大学的数据库系统研究
Novice guidance and event management system in game development
ORA-02292: 违反完整约束条件 (MIDBJDEV2.SYS_C0020757) - 已找到子记录
How to understand Python iterators and generators?
list转换map(根据key来拆分list,相同key的value为一个list)
2020-08-30:裸写算法:二叉树两个节点的最近公共祖先。
Will blockchain be the antidote to the global epidemic accelerating the transformation of Internet enterprises?
Use modelarts quickly, zero base white can also play AI!
随机推荐
Take you to learn the new methods in Es5
Python basic variable type -- list analysis
list转换map(根据key来拆分list,相同key的value为一个list)
ES6 learning notes (4): easy to understand the new grammar of ES6
Look! Internet, e-commerce offline big data analysis best practice! (Internet disk link attached)
Bitcoin once exceeded 14000 US dollars and is about to face the test of the US election
Staying up late summarizes the key points of report automation, data visualization and mining, which is different from what you think
C# 调用SendMessage刷新任务栏图标(强制结束时图标未消失)
Diamond standard
Python 100 cases
Xmppmini project details: step by step from the principle of practical XMPP technology development 4. String decoding secrets and message package
Outsourcing is really difficult. As an outsourcer, I can't help sighing.
What is the tensor in tensorflow?
Application of restful API based on MVC
2020-08-29:进程线程的区别,除了包含关系之外的一些区别,底层详细信息?
Call analysis of start method in JNI thread and callback analysis of run method
Elasticsearch Part 6: aggregate statistical query
CCR coin frying robot: the boss of bitcoin digital currency, what you have to know
An article taught you to use HTML5 SVG tags
【:: 是什么语法?】