Welcome to “Algorithms and the Beauty of Programming” ↑ pay attention to us!

This article was first published on the wechat official account “Beauty of Algorithms and Programming”. Welcome to follow and learn more about this series of blogs in time.


Recently, the public account received the following question from a student:

 

The problem scenario is: data is collected through the single chip microcomputer, and then the data is uploaded to the server through the WIFI module of the single chip microcomputer. Finally, it wants to display the data in the form of web pages.

 

What are the solutions to this problem?

 

 

Solution a:

 

TCP protocol is used to transmit data between the microcontroller and the server. The server can write a processing program in C language to accept the data sent by the microcontroller, and then save the data in the MYSQL database of the server.

 

Write a simple Servlet in Tomcat to access the database and return HTML code to the browser.

 

The advantage of this method is that the amount of data transmission between the microcontroller and the server is relatively small, the disadvantage is that you need to write your own server-side program, and need to control the Socket Packet and a series of network abnormalities, the workload is large.

 

Scheme 2:

 

HTTP protocol is used to transmit data between SCM and server. The Tomcat server can provide an API interface. The SCM can use JSON data format and send data to the interface through HTTP POST request. The server then writes a web page that reads the data from the database and presents it.

 

The advantage of this method is that the workload is relatively small, but the disadvantage is that the data transmission efficiency between the single chip microcomputer and the server is much lower than the first method, because there are a lot of HTTP protocol control header information, there is a certain overhead.

 

To sum up the above two schemes, I suggest beginners to use the second scheme, which is relatively fast to achieve. If you have a better solution, welcome to leave a message.