【平头哥RVB2601创意应用开发】成功连上阿里云
<p style="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">@4489@</font></span></span><a href="https://home.eeworld.com.cn/space-uid-499042.html"><span class="15" style="font-size:10.5000pt"><span style="background:#f7f9ff"><span style="font-family:微软雅黑"><span style="color:#333333"><span style="letter-spacing:0.0000pt"><span style="font-style:normal"><font face="微软雅黑">xinmeng_wit</font></span></span></span></span></span></span></a><span style="font-size:10.5000pt"><span style="background:#f7f9ff"><span style="font-family:微软雅黑"><span style="color:#333333"><span style="letter-spacing:0.0000pt"><span style="font-style:normal"><font face="微软雅黑">@</font></span></span></span></span></span></span><a href="https://home.eeworld.com.cn/space-uid-383818.html"><span class="15" style="font-size:10.5000pt"><span style="background:#f7f9ff"><span style="font-family:微软雅黑"><span style="color:#333333"><span style="letter-spacing:0.0000pt"><span style="font-style:normal"><font face="微软雅黑">sipower</font></span></span></span></span></span></span></a><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">经验,今天把监控数据上传到阿里云平台了,这里分享一下成果吧:</font></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:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">上网的代码,前面的网友已经写得很清楚了,我这里主要是说一下我的实现思路:</font></span></span></span></span></p>
<p style="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">u8g2</font><font face="宋体">在本地的</font><font face="Calibri">OLED</font><font face="宋体">屏展示,同时上报服务器:</font></span></span></span></span></p>
<pre>
<code>/*
* 功能:创建串口1接收任务,接收数据并把数据解析出来,存放在buff中,由U8g2显示函数定时刷新。上传服务器
*
*
*/
static void application_task1_entry(void *arg)
{
int ret = -1;
uint32_t rx_size = 0;
float Irms=0; //电流有效值
float Vrms=0; //电压有效值
float Frequency=0;//频率
float PowerFactor=1;//功率因数
float PActive=0; //有功功率
double W_KWH=0; //累积功耗
int n=0;
const char *dev_id = "0";
int pkt_id = 0;
char report_buf;
while (1) {
ret = hal_uart_recv_II(&uart1, uart_data_buf, 24,
&rx_size, UART_RX_TIMEOUT);
// LOGD(TAG, "RECV len:%d data:%x",rx_size,uart_data_buf);
if (rx_size ==24)
{
if((uart_data_buf == 0x55) && (uart_data_buf == 0x55))
{
Vrms=(double)(((uint32_t)uart_data_buf<<24)|((uint32_t)uart_data_buf<<16)|((uint32_t)uart_data_buf<<8)|((uint32_t)uart_data_buf<<0))/1000.0;
Irms=(double)(((uint32_t)uart_data_buf<<24)|((uint32_t)uart_data_buf<<16)|((uint32_t)uart_data_buf<<8)|((uint32_t)uart_data_buf<<0))/1000.0;
PActive=(double)(((uint32_t)uart_data_buf<<24)|((uint32_t)uart_data_buf<<16)|((uint32_t)uart_data_buf<<8)|((uint32_t)uart_data_buf<<0))/1000.0;
Frequency=(double)(((uint32_t)uart_data_buf<<24)|((uint32_t)uart_data_buf<<16)|((uint32_t)uart_data_buf<<8)|((uint32_t)uart_data_buf<<0))/1000.0;
sprintf(disp_Vrms,"%.1fV",Vrms);
sprintf(disp_Irms,"%.2fA",Irms);
sprintf(disp_PActive,"%.2fW",PActive);
sprintf(disp_Frequency,"%.2fHz",Frequency);
snprintf(report_buf,128,"{\\\"temperature\\\":8,\\\"LightVolt\\\":%.1f,\\\"ActivePower\\\":%.2f,\\\"LightCurrent\\\":%.2f}",Vrms,PActive,Irms);
w800_living_idmpp(dev_id, report_buf, &pkt_id); }
}
aos_msleep(50);
}
aos_task_exit(0);
}</code></pre>
<p>非常感谢好人的帮忙,原来想用http给我自己的服务器发数据来展示数据的,结果连上一看,我的服务器是https,这样还需要带证书。唉,只好屈服阿里吧,用着他的服务器先完成作业。</p>
<p>支持,学习啦!</p>
<p>楼主说的要带”证书“是什么呀?</p>
梦溪开物 发表于 2022-5-11 15:36
楼主说的要带”证书“是什么呀?
<p>就是,https相对http要多带一个东西。</p>
自己的服务器是在哪建立的? full_stack 发表于 2022-6-5 01:34
自己的服务器是在哪建立的?
<p>阿里云</p>
页:
[1]