【RVB2601 Creative Application Development】Work Submission
[Copy link]
Cold chain intelligent management system based on CH2601
Author: Liu Jianhua
The author has been engaged in immunization planning for a long time. The top priority of immunization planning is the cold chain management of vaccines. From production to transportation, and finally to the recipient's body, vaccines have strict storage requirements. After the promulgation of the "Vaccine Management Law of the People's Republic of China", vaccine storage was regulated by law. We immunization planners often joke that we will violate the law if we are not careful. In the past, temperature monitoring was carried out manually, so vaccine management personnel did not rest, did not go to work and leave work, and were worried about what problems would occur in the storage of vaccines. Although there are many vaccine temperature monitoring systems now, the products are extremely expensive, and a temperature monitoring point costs thousands. The management software is not very standardized. The author, a physician who has no knowledge of single-chip microcomputers, started to learn single-chip microcomputer knowledge from scratch, from the original stm8L, to ESP8266, to the current flat head brother RVB2601, to provide cheap solutions for this field. Moreover, the current temperature monitoring system does not monitor the working status of cold chain equipment, and some alarm functions only have alarm actions when the temperature exceeds the alarm conditions. My work this time considers temperature monitoring + continuous monitoring of power supply voltage, current, and power consumption of cold chain equipment. Analyze the operating status of the equipment on the server side and issue early warning.
This work is designed to collect the temperature of cold chain equipment, the working voltage, current, power consumption, and temperature of cold chain equipment, and upload them to the server through the Internet. The server also pushes them to the user's APP.
RVB2601 renderings:
thermometer:
Power Monitoring:
APP effect picture:
- Functional description and analysis of each part (combined with pictures and text)
- Equipment information collection part: It is composed of power collection module + wireless serial port module. RVB sends collection data signal to the module, and the collection module returns real-time information.
- Temperature collection part: It consists of GD32F310G, NTC thermistor, and wireless serial port transparent transmission module. It collects data every 1 second and uploads it to RVB2601.
- Data receiving, displaying and uploading part: After RVB2601 receives the temperature, voltage, current and power consumption information from the wireless serial port module, it uploads it to the Alibaba Cloud IOT platform via wireless wifiW800.
- Alibaba Cloud IOT platform part: responsible for receiving data uploaded by RVB2601 and distributing it to user APP in real time.
- User APP: Public panel APP (Cloud Intelligence) provided by Alibaba Cloud, providing users with real-time data query and historical data browsing. Receive abnormal information.
/*
* Copyright (C) 2019-2020 Alibaba Group Holding Limited
*/
#include <stdlib.h>
#include <string.h>
#include <aos/aos.h>
#include "aos/cli.h"
#include "main.h"
#include "app_init.h"
#include "oled.h"
#include "aos/hal/uart.h"
#include "drv/rtc.h"
#include "http.h"
#define TAG "app"
extern int w800_living_wjap(const char *myssid,const char *mypassword);
extern int w800_living_idmau(const char *mykey,const char *myname,const char *mysecret,const char *mypsecretconst);
extern int w800_living_idmcon(void);
#define UART_BUF_SIZE 40
#define UART_TX_TIMEOUT 100
#define UART_RX_TIMEOUT 500
extern uart_dev_t uart1;
u8g2_t u8g2;
char disp_buff[40];
void w800_data_receive_callback(int linkid, void *data, size_t len, char remote_ip[16], uint16_t remote_ports);
static csi_rtc_t g_rtc;
static aos_task_t app_task1_handle;
static aos_task_t app_task2_handle;
char disp_Vrms[10]; //显示电压值
char disp_Irms[10]; //显示电流值
char disp_PActive[10]; //显示功耗值
char disp_Frequency[10]; //显示频率值
char disp_Temper[10];//显示温度
/* data buffer */
char uart_data_buf[UART_BUF_SIZE];
int iot_connect_dome(void)
{
char *my_ssid = " ";//2.4GHZ WiFi ssid
char *my_password = " ";//2.4GHZ WiFi password
char *my_key = " ";//ProductKey
char *my_name = " ";//DeviceName
char *my_secret = " ";//DeviceSecret
char *my_p_secret = "";//Product Secret
int ret1 = -1;
int ret2 = -1;
int ret3 = -1;
ret1 = w800_living_wjap(my_ssid,my_password);
if (ret1 == 0){
printf("AT+WJAP:OK!\n");
}
else{
printf("AT+WJAP:ERROR!\n");
}
ret2 = w800_living_idmau(my_key,my_name,my_secret,my_p_secret);
if (ret2 == 0){
printf("AT+IDMAU:OK!\n");
}
else{
printf("AT+IDMAU:ERROR!\n");
}
ret3 = w800_living_idmcon();
if (ret3 == 0){
printf("AT+IDMCON:OK!\n");
}
else{
printf("AT+IDMCON:ERROR!\n");
}
if(ret1 == 0 && ret2 == 0 && ret3 == 0){
return 0;
}else{
return -1;
}
}
/*
* 功能:创建串口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[128];
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[0]);
if (rx_size == 24)
{
if((uart_data_buf[0] == 0x55) && (uart_data_buf[1] == 0x55))
{
Vrms=(double)(((uint32_t)uart_data_buf[6]<<24)|((uint32_t)uart_data_buf[7]<<16)|((uint32_t)uart_data_buf[8]<<8)|((uint32_t)uart_data_buf[9]<<0))/1000.0;
Irms=(double)(((uint32_t)uart_data_buf[10]<<24)|((uint32_t)uart_data_buf[11]<<16)|((uint32_t)uart_data_buf[12]<<8)|((uint32_t)uart_data_buf[13]<<0))/1000.0;
PActive=(double)(((uint32_t)uart_data_buf[14]<<24)|((uint32_t)uart_data_buf[15]<<16)|((uint32_t)uart_data_buf[16]<<8)|((uint32_t)uart_data_buf[17]<<0))/1000.0;
Frequency=(double)(((uint32_t)uart_data_buf[18]<<24)|((uint32_t)uart_data_buf[19]<<16)|((uint32_t)uart_data_buf[n++]<<8)|((uint32_t)uart_data_buf[20]<<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,"{\\\"LightVolt\\\":%.1f,\\\"ActivePower\\\":%.2f,\\\"LightCurrent\\\":%.2f}",Vrms,PActive,Irms);
w800_living_idmpp(dev_id, report_buf, &pkt_id);
memset(uart_data_buf,0,24);
}
else if((uart_data_buf[0] == 0x66) && (uart_data_buf[1] == 0x66))
{
if(uart_data_buf[2] == 0x01)
{
sprintf(disp_Temper,"-%d.%d C",uart_data_buf[3],uart_data_buf[4]);
snprintf(report_buf,60,"\\\"temperature\\\":-%d.%d}",uart_data_buf[3],uart_data_buf[4]);
}
else
{
sprintf(disp_Temper,"%d.%d C",uart_data_buf[3],uart_data_buf[4]);
snprintf(report_buf,60,"{\\\"temperature\\\":%d.%d}",uart_data_buf[3],uart_data_buf[4]);
}
w800_living_idmpp(dev_id, report_buf, &pkt_id);
}
}
aos_msleep(50);
}
aos_task_exit(0);
}
/*
* 功能:创建串口1发送任务,向电源监控模块发送获取监控数据的命令
*
*
*
*/
static void application_task2_entry(void *arg)
{
int ret = -1;
uint8_t uart_tx_buf[] = {0x55,0x55,0x01,0x02,0x00,0x00,0xAD};
while (1) {
ret = hal_uart_send(&uart1, uart_tx_buf, sizeof(uart_tx_buf), UART_TX_TIMEOUT);
if (ret == 0) {
//printf("uart1 data send succeed !\n");
}
aos_msleep(1000);
}
aos_task_exit(0);
}
void test_getIP_task()
{
char ssid[32];
int bssid[6];
int channel;
int rssi;
char disp[40];
//先获取AP信息,判断是否联网
//偿试连接到服务器
//发送数据
char ip[16];
char gw[16];
char mask[16];
csi_rtc_time_t this_time;
csi_error_t ret;
int ipinfo = -1;
while(1){
//获取时间
u8g2_ClearBuffer(&u8g2);
u8g2_SetFont(&u8g2,u8g2_font_7x13_tr);
u8g2_DrawStr(&u8g2,12,12,"Cold Manage SYS");//字符显示
//u8g2_SendBuffer(&u8g2);
u8g2_SetFont(&u8g2,u8g2_font_7x13_tr);
u8g2_DrawStr(&u8g2,4,30,disp_Vrms);//显示电压值
u8g2_DrawStr(&u8g2,80,30,disp_Irms);//显示电压值
u8g2_DrawStr(&u8g2,4,50,disp_PActive);//显示功率值
u8g2_DrawStr(&u8g2,80,50,disp_Temper);//显示频率值
u8g2_SendBuffer(&u8g2);
aos_msleep(500);
}
}
void w800_data_receive_callback(int linkid, void *data, size_t len, char remote_ip[16], uint16_t remote_ports)
{
uint8_t *buf;
buf = (uint8_t *)data;
if(len == 0)
{
return;
}
printf("receive data len: %d\r\n",len);
printf("receive data:");
for(uint16_t i = 0; i < len; i++)
{
printf("%c ",buf);
}
printf("\r\n");
}
int main(void)
{
board_yoc_init();
LOGD(TAG, "%s\n", aos_get_app_version());
u8g2Init(&u8g2);
u8g2_SetFontMode(&u8g2, 1);
u8g2_SetFont(&u8g2, u8g2_font_unifont_t_symbols);
u8g2_ClearBuffer(&u8g2);
u8g2_DrawStr(&u8g2,0,12,"RVB2601");//字符显示
u8g2_SendBuffer(&u8g2);
sleep(5);
aos_task_new("test_get ip", test_getIP_task,NULL, 1024);
aos_task_new_ext(&app_task1_handle, "app_task1", application_task1_entry,
NULL, 4096, AOS_DEFAULT_APP_PRI);
aos_task_new_ext(&app_task2_handle, "app_task2", application_task2_entry,
NULL, 4096, AOS_DEFAULT_APP_PRI);
iot_connect_dome();
while (1) {
aos_msleep(1000);
}
return 0;
}
VII. Project Summary
After more than two months of studying RVB2601, I learned about Pingtou Ge's operating system, wifi networking, the operation of Alibaba IOT cloud platform, etc., and I have a certain understanding of the various performances of Pingtou Ge RVB2601. This is a very promising chip.
Although I have achieved basic functions with this platform, there is still a certain gap between what I envisioned at the time, because I already have a real project running. Here I want to talk about this series of shortcomings, hoping to help the future development of the Alibaba Cloud platform.
1. Work order system: When you encounter a problem, it is very good to have a work order system, but this work order system is really depressing. I sent a work order, but there was no reply for a long time. When I replied, there was a series of questions. I kept questioning whether there was something wrong with me when I submitted the work order (Why would I contact you if I have no problem? I am an old engineer with more than ten years of experience. Would I contact you if I have nothing to do?). The efficiency is extremely low. I also wanted to return the board and interrupt the evaluation, but the staff persuaded me to continue to complete the project. I submitted a lot of work orders, which were basically completed after a week. Later, I asked for a DingTalk system for instant contact, and the processing effect was better. Here I say that Alibaba's technical support really needs to be strengthened.
2. The MQTT protocol has been open in other places of the W800 WiFi chip, but Pingtou Ge did not integrate the AT protocol this time. Compared with http, MQTT is lighter and more convenient for users to use.
3. My original design was to use my own server, but Pingtou Ge did not provide a solution for the https protocol, so it was very different from my original design.
4. NTP is a big pitfall. I spent several days trying to figure it out.
5. CDK also cost me a lot of time. There are so many versions, it's hard to adapt to them all at once. Engineers now have to use several IDEs, but CDK is the most frustrating IDE. For example: the file is clearly there and included, but it just says it doesn't exist. Also, when I first used it, it took more than ten minutes to start CDK, and it would get stuck at any time. And so on. I hope Pingtouge will improve this in future versions.
6. There is also a blog post system. You are asked to revise a blog post more than ten times before it is approved. We reviewers are not paid by your family. Isn’t this requirement too strict? It makes people upset just thinking about it!
7. APP update problem. After the panel is modified, it takes one hour to one day to update in real time on the mobile phone. I sent a work order, and the technical support said that I did not operate it correctly, so why did nothing change? The next day, or half a day later, it was updated by itself. It seems that the technical support of Alibaba work orders also needs to learn some business knowledge by themselves. It makes developers waste a lot of precious time.
In general, I have 20 years of programming experience, 6 years of MCU development, and have successfully developed more than a dozen chips. Although I am not a programming expert, I am not a novice. This time using Pingtou Ge was the most unpleasant experience. I spent a lot of useless work and handed in a lot of homework purely for the promise I made when I submitted the application.
Finally, I would like to thank all the friends who tried RVB2601 this time. I learned a lot from your excellent works. Thank you!
PS: Demonstration video
WeChat_20220622123148
|