【平头哥RVB2601创意应用开发】六。环境传感器数据上传阿里云服务器
本帖最后由 anni_zzg 于 2022-6-2 11:14 编辑<p><span style="font-size:14pt; text-align:justify; text-indent:37.3333px"><span style="overflow-wrap:break-word"><span style="color:#333333"><span style="font-family:等线"><span style="font-style:normal"><span style="font-variant-ligatures:normal"><span style="font-weight:400"><span style="white-space:normal"><span style="background-color:#ffffff"><span style="text-decoration-thickness:initial"><span style="text-decoration-style:initial"><span style="text-decoration-color:initial"><span style="overflow-wrap:break-word"><span style="font-family:黑体"><font face="黑体"><font style="overflow-wrap:break-word">利用RVB2601开发板从环境传感器SHT3X和SGP30采集到的</font></font></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span style="font-size:14pt; text-align:justify; text-indent:37.3333px"><span style="overflow-wrap:break-word"><span style="color:#333333"><span style="font-family:等线"><span style="font-style:normal"><span style="font-variant-ligatures:normal"><span style="font-weight:400"><span style="white-space:normal"><span style="background-color:#ffffff"><span style="text-decoration-thickness:initial"><span style="text-decoration-style:initial"><span style="text-decoration-color:initial"><span style="overflow-wrap:break-word"><span style="font-family:黑体"><font face="黑体"><font style="overflow-wrap:break-word">温度、湿度、eCO2,TVOC数据上传到阿里云平台,可以更充分的使用这些数据。下面是实现的主要流程:</font></font></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p>
<p> </p>
<p><strong><span style="font-size:20px;">一。<span style="text-align: justify; text-indent: 37.3333px;"><span style="overflow-wrap:break-word"><span style="color:#333333"><span style="font-family:等线"><span style="font-style:normal"><span style="font-variant-ligatures:normal"><span style="font-weight:400"><span style="white-space:normal"><span style="background-color:#ffffff"><span style="text-decoration-thickness:initial"><span style="text-decoration-style:initial"><span style="text-decoration-color:initial"><span style="overflow-wrap:break-word"><span style="font-family:黑体"><font face="黑体"><font style="overflow-wrap:break-word">在阿里云的飞燕平台创建设备</font></font></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></strong></p>
<p><span style="font-size:14pt; text-align:justify; text-indent:37.3333px"><span style="overflow-wrap:break-word"><span style="color:#333333"><span style="font-family:等线"><span style="font-style:normal"><span style="font-variant-ligatures:normal"><span style="font-weight:400"><span style="white-space:normal"><span style="background-color:#ffffff"><span style="text-decoration-thickness:initial"><span style="text-decoration-style:initial"><span style="text-decoration-color:initial"><span style="overflow-wrap:break-word"><span style="font-family:黑体"><font face="黑体"><font style="overflow-wrap:break-word"> <span style="font-size:16px;"> (1)在</span></font></font></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span style="font-size:16px;"><a href="https://living.aliyun.com/">项目管理 - 生活物联网平台 (aliyun.com)</a> 注册账号,并登录。</span></p>
<p> <span style="font-size:16px;"> (2)首先新建一个项目</span></p>
<p> </p>
<p> <span style="font-size:16px;">(3)新建一个产品,也就是一个设备,数据的上传是以设备为基本单位。</span></p>
<p> </p>
<p> </p>
<p><span style="font-size:16px;">(4)为设备定义具体功能,标准功能没有的可以自定义功能。</span></p>
<p> </p>
<p><span style="font-size:12px;">每个功能可以添加属性,服务或事件。 我的项目是上传温湿度值,CO2浓度,和TVOC浓度所以定义了四个属性。标识符,数据类型需要与程序对应。</span></p>
<p></p>
<p> <span style="font-size:20px;"><strong>二。 设备上网</strong></span></p>
<p> 设备网络连接前,需要设置设备五元组。</p>
<p> AT+IDMAU="PRODUCT_KEY","DEVICE_NAME","DEVICE_SECRET","PRODUCT_SECRET"<br />
AT+IDMPID=(TODO)<br />
</p>
<p>物联网平台连接</p>
<pre>
<code class="language-cpp">if (atparser_send(g_atparser_uservice_t, "AT+IDMCON") == 0) {
if (atparser_recv(g_atparser_uservice_t, "OK\n") == 0) {
ret = 0;
}</code></pre>
<p>状态显示在线,说明连接成功。</p>
<p><strong><span style="font-size:20px;">三。数据上传</span></strong></p>
<p> </p>
<table>
<tbody>
<tr>
<td width="238">AT+IDMPP=<device_id>,<message></td>
</tr>
</tbody>
</table>
<p> </p>
<pre>
<code class="language-cpp">snprintf(msg_buf,80,"{\\\"temperature\\\":%.2f,\\\"humidity\\\":%.2f,\\\"CO2\\\":%d,\\\"TVOC\\\":%d}",Temperature,Humidity,eco2,tvoc);
printf( "==> start attribute upload\n");
ret = w800_living_idmpp(dev_id, msg_buf, &pkt_id);</code></pre>
<p>上传完成后:</p>
<p> </p>
<p> </p>
<p><span style="font-size:20px;"><strong>四。总结</strong></span></p>
<p><span style="font-size:20px;"><strong> </strong></span><span style="font-size:12px;"><strong> </strong>我一边学习一边操作,飞燕平台非常人性化,操作几遍很快就能熟练掌握。在学习过程中参考学习了 网友sipower的帖子<a href="https://home.eeworld.com.cn/space-uid-383818.html">sipower的个人空间动态-电子工程世界 (eeworld.com.cn)</a>,他的几个帖子介绍的非常全面,有很高的参考价值。以后学习的地方还有很多,每天进步一点点。</span></p>
<p> </p>
网络应用不错,加油,希望继续分享精彩作品!
页:
[1]