Reading my serial port through a web page?

Hello,
i have a ready and working circuit that i am using to measure certain values and i am sending those values into a serial port. Right now, what i would like to do is to set up a server on my computer, so i can create a webpage with a script that is listening to my serial port arduino is connected to and then maybe visualise those values in a graph or table. My main question is what is the easiest way to listen to serial port in your opinion? I don't know whether i should do it with php, java, cpp, python, or basically anything. I don't have a problem using unknown languague, since i know already a few of them and learning a new one is the least of my problems.

Use what ever language YOU are comfortable with! This is NOT a question for us!!!

missdrew:
Use what ever language YOU are comfortable with! This is NOT a question for us!!!

one language can be good for some purpose and not so good for other. Even though i can be comfortable with language A, it can be pain to do certain things this language isn’t as good for. This is a reason i asked this question.

bergerino:
what i would like to do is to set up a server on my computer, so i can create a webpage with a script that is listening to my serial port arduino is connected to and then maybe visualise those values in a graph or table.

With the Python Bottle web framework you can get a very simple server working in 10 or 15 minutes and it is also straightforward to use Python to communicate with your Arduino over a serial port.

This Simple Python - Arduino demo should giet you started. The Python code should work on Windows if you edit it to use the Windows style of COM ports. I believe you also have to change the line where it says rtscts = True to rtscts = False

...R

Robin2:
With the Python Bottle web framework you can get a very simple server working in 10 or 15 minutes and it is also straightforward to use Python to communicate with your Arduino over a serial port.

This Simple Python - Arduino demo should giet you started. The Python code should work on Windows if you edit it to use the Windows style of COM ports. I believe you also have to change the line where it says rtscts = True to rtscts = False

…R

Hey, thanks for the tip :slight_smile: Will i be able to visualize matplotlib graph on a website built with this as well?

bergerino:
Will i be able to visualize matplotlib graph on a website built with this as well?

I have no idea.

I believe there are several Javascript graphing libraries

...R

Robin2:
I have no idea.

I believe there are several Javascript graphing libraries

...R

okay, thanks

When I've done this kind of thing, I split it into two pieces: the presentation layer doesn't need to know how the data is gathered - it's a web page pulling from a data source.

The other half consumes the data - serial in this case and stores it.

Another alternative is Node-RED. Most people use it on a Raspberry Pi. You create flow graphs using a browser GUI and can add additional functionality using Javascript. The result is displayed on a web page.

There are ready made nodes for Serial, access to databases, graphs, gauges, MQTT, buttons, email, twitter and all kind of other stuff.

It comes preinstalled on Raspberry Pi OS.

https://nodered.org/

wildbill:
When I've done this kind of thing, I split it into two pieces: the presentation layer doesn't need to know how the data is gathered - it's a web page pulling from a data source.

The other half consumes the data - serial in this case and stores it.

That's very good advice - it makes almost all programming much easier.

However I have been under the impression that Serial is producing the data rather than consuming.

...R

Processing may offer another option. Haven't used it yet but it looks very promising.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.