[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 506
  • Last Modified:

How to display realtime meter reading data from TCP or serial on web

I may need to display realtime meter reading values on the web site. The data will be received by the server through TCP or serial port.

I plan to make one program A on server to receive the realtime data and pass them to web server, and save to DB also. But I am not sure how to let the program A pass the data to the web server, or through whcih way.

When the end user start a web page, all and only the meters in this page need refresh the realtime display. The web server need to pass this meters ID to program A, and A start to polling these meters realtime value with faster speed. Can this be done in the web server.

  • 3
  • 2
1 Solution
If your "realtime" data isn't to quick, you could have your program A send data to it using a simple GET request, and create a page on the server to process the request and write the data to the database.  For example:
  program A would GET www.server.com/update_value.cgi?value1=5&value2=10
  Then update_value.cgi would write the new values to the database.

To have the web browser display the data, you could use AJAX to get new data from the web server, and update the page.

I'd guess this would work for about 1 update/second.  Much faster than this, and you'll some other method.
turbot_yuAuthor Commented:
1 update/second is fine. May you give details about GET request.

Please see the attached screen.
In your picture, program A writes to the database, but the webserver does not interface with the database.  Is this how it will work?  If so, I misunderstood your requirements.

I thought that the program A would interface with the web server and the polling data back - not the database - and the web server with interface with the database.  If so, how you send the GET request will depend on the language.  If you are using perl for program A, you can use the LWP::Simple module, and the request is just 1 line (plus 1 line to include the module):
    use LWP::Simple;   #Include module
    #whatever code to read from polling data back goes here
    my $content = get("http://www.your-server-here.com/update_value.cgi?value1=$value1");
turbot_yuAuthor Commented:
Sorry, I forgot to draw the link from DB to web server.

Most of the data that web client want to view is not realtime data, just the data in the DB.

Actually, there are 2 kinds of data. One is trending data, which refresh every 10 mins, another realtime data, which refresh every second.

I am new to the GET. Is it from the web server? Any syntax of it.
GET is one of the methods a web client communicates with a web server.

This is what is used when you type an address in a web browser - the web browser sends a GET request to the web server, and the server responds with the data for that page.

On the web server, if the page is just plain html, the web server will just send the page to the client.  If the page is a program (perl, php, whatever), the web server runs the program, and sends the results to the client.

Depending on the language, you may not need to know the detailed syntax of the protocol - the language has a library that implements it for you.  The example I gave is in perl, and uses the LWP::Simple module.  With this module, you call the "get" function, with handles all of the protocol with the server.  If the language you choose does not have any libraries to help with this, the basic syntax is "GET page\r\n" where "page" is replaced with whatever page you want.

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now