Link to home
Start Free TrialLog in
Avatar of turbot_yu
turbot_yuFlag for Singapore

asked on

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.

Thanks.
Avatar of Adam314
Adam314

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.
Avatar of turbot_yu

ASKER

1 update/second is fine. May you give details about GET request.

Please see the attached screen.
meter.png
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");
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.
meter-1-.png
ASKER CERTIFIED SOLUTION
Avatar of Adam314
Adam314

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial