3641 views|5 replies

28

Posts

10

Resources
The OP
 

Online dust monitoring system [Copy link]

With the vigorous development of national real estate construction and the increase in construction projects, the dust pollution problem caused by construction is becoming more and more serious. In order to effectively and quickly monitor the dust conditions at the construction site, we use the hardware platform to collect the PM2.5/PM10 content information of the construction site. The dot matrix screen displays the content information on site, and transmits the PM particle content information (PM10/PM2.5) to China Mobile OneNet platform through the GPRS network. The dust supervision department can view the dust content information through the platform and can view it through the mobile phone, which greatly facilitates the monitoring and control of dust pollution.
  • System Block Diagram
2.Function introductionOverall hardware physical picture: OneNet platform creates equipment (communication protocol adopts MQTT format): View PM10 and PM2.5 content data through the platform: Mobile terminal data viewing (China Mobile OnetNet platform provides mobile APP installation package, use PC registered account to log in to APP): Component 1: GD32F350 Little Red Board (onboard CMSIS-DAP download and debug interface, USB virtual serial port, all IO leads, user buttons, indicator lights) Component 2: PMS3003 particle sensor (produced by Pan Teng, can detect and output PM1.0/PM2.5/PM10 particle content, interface mode is TTL serial port, active output (1S)) Connect core board PA10 (serial port 0 RXd) Serial port receiving sensor data processing:
  1. void USART0_IRQHandler(void) { if(RESET != usart_interrupt_flag_get(EVAL_COM1, USART_INT_FLAG_RBNE)) { /* receive data */ receiver_buffer[rxcount] = (usart_data_receive(EVAL_COM1) & 0x7F); if(receiver_buffer[0]==0x42)//The first byte of sensor data { rxcount++; if(rxcount==2) { if(receiver_buffer[1]!=0x4d)//The second byte of sensor data rxcount=0; } if(rxcount==24)//One frame of data reception completed { rxcount=0; Rec_Uart0_Flag=1; } } } }
复制代码
Receive and parse to obtain data:
  1. if(Rec_Uart0_Flag==1) //Receive one frame of sensor data { Rec_Uart0_Flag=0; Pm1_0=receiver_buffer[10]<<8|receiver_buffer[11]; Pm2_5=receiver_buffer[12]<<8|receiver_buffer[13]; Pm10=receiver_buffer[14]<<8|receiver_buffer[15]; }
复制代码
Composition 3:AIR202GPRS module (from Hezhou, a cost-effective module with a price of more than ten yuan, with adaptive serial port baud rate, supports China Mobile and China Unicom cards, and plays an interactive role in this system) connected to the core board PA15/PA3 (Rxd/Txd of serial port 1) When debugging serial port 1, I encountered a problem: the core board hardware converts PA2/PA3 through CH340. At first, I connected the serial port of the GPRS module to PA2/PA3 and found that when the receiving end of serial port 1 transmits data, the level cannot be pulled down to 0V when the level is low. Later, I suspected that it was a problem of using it as a virtual serial port, so I removed the resistor R31 connecting the receiving port IO and CH340 to avoid it being affected by CH340. After removing it, the problem was solved, but the reason is not clear yet! The microcontroller communicates with AIR202. To process the data received by the serial port, it is more reasonable to use idle interrupt processing, that is, when the serial port receives a frame of data, a flag is set. According to this flag, the data reception is judged to be completed, and then the data parsing and processing judgment are started. The serial port interrupt processing code is as follows:
  1. void USART1_IRQHandler(void) { if(RESET != usart_interrupt_flag_get(EVAL_COM2, USART_INT_FLAG_RBNE))//Receive one byte completed interrupt { if(m6312_cnt>=128) m6312_cnt=0; /* receive data */ m6312_buf[m6312_cnt] = (usart_data_receive(EVAL_COM2) & 0x7F); m6312_cnt++; } if(RESET != usart_interrupt_flag_get(EVAL_COM2, USART_INT_FLAG_IDLE)) //Serial port idle interrupt { usart_interrupt_flag_clear(EVAL_COM2,USART_INT_FLAG_IDLE); //Clear flag /* receive data */ RecUart1Finish=1; //Set flag for judgment } }
复制代码
Composition four: dot matrix screen Two HUB-08 interface 16*64 dot matrix screens (monochrome red) Driving single screen principle: four groups of IO control enable sixteen lines of dot matrix, one group of IO transmits data to each line, CLK One IO, one latch IO, and one data enable IO. To drive two single screens, except for the data IO, other control IO can be shared. [attach]379777 [/attach] The dot matrix screen driver core needs to continuously send data to the two screens, so a timer must be turned on and the timer interrupt service is used to execute the data sending function. This system uses the timer1 timer, The timing time is 4ms. The timer configuration code is as follows:
  1. /* The time to count a number = (sys/prescaler)/TIMER_CKDIV_DIV1 Timing time = The time to count a number * automatic reload value = 100us*500=50ms; */ void timer1_init() { timer_parameter_struct timer_initpara; rcu_periph_clock_enable(RCU_TIMER1); timer_deinit(TIMER1); timer_initpara.prescaler = 10800-1; //Prescaler timer_initpara.alignedmode = TIMER_COUNTER_EDGE; //Edge alignment mode timer_initpara.counterdirection = TIMER_COUNTER_UP; //Count up timer_initpara.period = 10; //Auto reload value timer_initpara.clockdivision = TIMER_CKDIV_DIV1; //Division timer_initpara.repetitioncounter = 0; //Counter repetition value 0-255 timer_init(TIMER1, &timer_initpara); timer_interrupt_enable(TIMER1, TIMER_INT_UP); nvic_irq_enable(TIMER1_IRQn, 1, 1); timer_enable(TIMER1); }
复制代码
The dot matrix driver code executed in the timer interrupt is as follows: (Note: The function executed in the interrupt must be completed within the interrupt time, otherwise it will affect the execution of the main program code. Therefore, this example uses only one line of dot matrix data to be sent each time an interrupt is entered, and the next line of data will be sent the next time.The purpose is to ensure that the code can be executed within the interrupt time)
  1. //4ms interrupt once void TIMER1_IRQHandler() { timer_interrupt_flag_clear(TIMER1, TIMER_INT_FLAG_UP); gd_eval_led_toggle(LED1); test_led(); //Enable a row of dot matrix and send the row data create_show(0);//Generate the screen data }
复制代码
Next, I will write about uploading the MQTT protocol to the OneNet platform........To be continuedWork demonstration video link: https://training.eeworld.com.cn/video/15939


点阵显示.jpg (2.55 MB, downloads: 0)

点阵显示.jpg
This post is from GD32 MCU

Latest reply

Do I need an IoT mobile phone card?  Details Published on 2018-9-28 16:35
 

229

Posts

0

Resources
2
 
Good, this construction site needs
This post is from GD32 MCU
 
 
 

111

Posts

0

Resources
3
 
Do I need an IoT mobile phone card?
This post is from GD32 MCU
 
 
 

28

Posts

10

Resources
4
 
serialworld posted on 2018-9-28 16:35 Do you need an IoT mobile phone card?
Yes, a physical network card is best, as long as the traffic is enabled.
This post is from GD32 MCU
 
 
 

28

Posts

10

Resources
5
 
Work demonstration video link: https://training.eeworld.com.cn/video/15939
This post is from GD32 MCU
 
 
 

28

Posts

10

Resources
6
 
Source code files:

GD32F3x0_Firmware_Library_V1.0.0.rar

8.61 MB, downloads: 744

工程源代码

This post is from GD32 MCU
 
 
 

Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list