Connect with us

Serial port communication

Discussion in 'Microcontrollers, Programming and IoT' started by vead, Jun 2, 2016.

Scroll to continue with content
  1. vead

    vead

    473
    14
    Nov 27, 2011
    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
     
  2. cjdelphi

    cjdelphi

    1,096
    104
    Oct 26, 2011
    Either you host the webserver or the webserver runs a script which connects to your computer (port forwarding required on your router)
     
  3. Harald Kapp

    Harald Kapp Moderator Moderator

    10,386
    2,270
    Nov 17, 2011
    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.
     
  4. vead

    vead

    473
    14
    Nov 27, 2011
    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
     
  5. Harald Kapp

    Harald Kapp Moderator Moderator

    10,386
    2,270
    Nov 17, 2011
    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.
     
    vead likes this.
  6. vead

    vead

    473
    14
    Nov 27, 2011
    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,
     
  7. Harald Kapp

    Harald Kapp Moderator Moderator

    10,386
    2,270
    Nov 17, 2011
    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'?
     
  8. vead

    vead

    473
    14
    Nov 27, 2011
    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
     
  9. Harald Kapp

    Harald Kapp Moderator Moderator

    10,386
    2,270
    Nov 17, 2011
    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.
     
  10. Amar Dhore

    Amar Dhore

    129
    12
    Dec 2, 2015
    This could be another option: WIZ105SR (google wiznet) device to send serial data to the server over HTTP.
     
  11. petercuenca

    petercuenca

    7
    5
    Jun 2, 2016
    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.
     
  12. vead

    vead

    473
    14
    Nov 27, 2011
    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
     
  13. CDRIVE

    CDRIVE Hauling 10' pipe on a Trek Shift3

    4,960
    648
    May 8, 2012
    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
     
  14. petercuenca

    petercuenca

    7
    5
    Jun 2, 2016
    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.
    [​IMG]

    text.html
    [​IMG]
    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
     

    Attached Files:

    vead and CDRIVE like this.
  15. CDRIVE

    CDRIVE Hauling 10' pipe on a Trek Shift3

    4,960
    648
    May 8, 2012
    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:
    I didn't know that there was more than one year of 2010! o_O

    Chris
     
    vead and davenn like this.
  16. petercuenca

    petercuenca

    7
    5
    Jun 2, 2016
    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.
     
    CDRIVE and vead like this.
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-