Maker Pro
Maker Pro

Serial port communication

Hello
I want to send data from Web page to the serial port of my computer. I did Google search and I found two method, first access serial port by using visual studio. Net and another is, access serial port using PHP script. I don't understand which method is use to transfer data from Web page to port of computer please help me
 
Either you host the webserver or the webserver runs a script which connects to your computer (port forwarding required on your router)
 

Harald Kapp

Moderator
Moderator
Either you host the webserver or the webserver runs a script which connects to your computer (port forwarding required on your router)
That's if teh website wants to access the serial port.

The question can be interpreted in another way, too: The PC is connected to any server displaying a website from the server. The task is to extract information from this website and send it via the serial port to another device.
In this case I'd split the task in two:
  1. get the information from the website (e.g. by interpreting the HTML code receied from that site). This is called web scraping.
  2. send the information via the serial port.
The programming language used is of lesser importance. Use what you are most familiar with.
 
In this case I'd split the task in two:
  1. get the information from the website (e.g. by interpreting the HTML code receied from that site). This is called web scraping.
  2. send the information via the serial port.
.
1. We can use PHP script to make Web Pag
2. It's not clear for me. how to send information via serial port. I have two method, how to complete task, which program language should I have to use
 

Harald Kapp

Moderator
Moderator
2. It's not clear for me. how to send information via serial port. I have two method, how to complete task, which program language should I have to use
I couldn't recommend any specific programming language. Most languages have some way to access a serial port, possibly via a supplied library. Examples:

PHP: PHP Serial
.NET: SerialPortClass

You'll find lots of examples browsing the internet.
 
OK that means I need to make Web page using the PHP and next I have to make program using visual studio. Net to access the serial port of computer I am just asking for confirmation,
 

Harald Kapp

Moderator
Moderator
Right, that is one way to do it.

But: If you "make" the web page, then you have all the information already at hand (or in some database). You can directly send teh information via the serial port without the need for a webpage.
Or what do you mean by 'I need to make Web page'?
 
Right, that is one way to do it.

But: If you "make" the web page, then you have all the information already at hand (or in some database). You can directly send teh information via the serial port without the need for a webpage.
Or what do you mean by 'I need to make Web page'?

PC is connected with server that display Web page. I want to control any device via web page so that's why I need to create a web page , there should be buttons on web page , start and stop, if I press start button on web page , device should be “on’’ and If I press stopbutton on web page ,device should be turn “off’’ supppose I am controlling home appliances like fan motor etc via web

I am not getting way to do it, I don't understand weather I need only PHP script or I have to use. NET program and PHP script
 

Harald Kapp

Moderator
Moderator
You should be able to do it from the PHP script using the PHP serial library. I gave you the link to this library. Check it out.
 
do you really have to use a pc just to control things from a website?

you can use an ethernet controller chip the one posted above or an ethernet shield and arduino or an arduino yun or ENC28J60 + mcu, or just the popular esp8266 wifi module.
 
You should be able to do it from teh PHP script using the PHP serial library. I gave you the link to this library. Check it out.
I don't have much knowledge, I have installed WAMP server to run php program but I am not sure that it will suitable for project, any suggestions
 

CDRIVE

Hauling 10' pipe on a Trek Shift3
You seem to have only a vague idea of the various building blocks that could be used to complete this assignment. I say "assignment" because some of your replies seem to indicate that this is a class assignment.

Regardless of that this image may help you visualize at least one possible method of accomplishing your task. I used VB6 controls as an example only because it's my language of choice. VBNET would be just as applicable.

Chris
upload_2016-6-4_9-31-16.png
 
if you really need to do it with a computer, here is a working php example.
extract the attached zip file to your wamp document folder. make sure php is properly configured.

/example folder has text.html and configport.php files.

Serial port set up:
set comm port properties from configport.php. specify the comport to use.
205bl78.png


text.html
dtch4.png

run in your browser and you will find 2 buttons.
ON button will send "1" on serial port connected. OFF button will send "0"
If TX RX of serial port is shorted (loop back test), you will see 1 or 0 text on the page.

original php serial lib taken from this link: https://github.com/Xowap/PHP-Serial
 

Attachments

  • PHPSerial.zip
    25.9 KB · Views: 68

CDRIVE

Hauling 10' pipe on a Trek Shift3
Hello Peter and welcome to EP!

I've never worked with PHP so I Googled it and read through Wikipedia's description. It was quite an interesting read.

Here's a humorous clip from the article:
During the 2010s there have been increased efforts towards standardization and code sharing in PHP applications by projects such as....<snip>

I didn't know that there was more than one year of 2010! o_O

Chris
 
Hi CDRIVE,
Thanks!

I shifted to web applications for i find it will be the easiest way for me to do cross platform applications. (windows, mac, linux, android, iOS)

here is one of my sample video with wifi modules and a raspberry pi server:

floor plan image flashing indicators on the webpage turn green or red when my wifi sensors are powered up. the small lcd is the raspberry pi server.
 
Top