HTML and PIC communication
+ Reply to Thread
Results 1 to 22 of 22
  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,813

    Default HTML and PIC communication

    I am trying to understand how can a PIC communicate to an HTML page for displaying and receive data.

    Say that on the HTML page there is a text box to enter a value and a button to send this value to PIC.

    Also a value from the PIC is to be send and displayed on the HTML page.

    Anyone done this?

    I attach the test HTML code I have done so far that displays buttons and input text boxes but have no clue how to use that.

    Ioannis

    html_test.zip

  2. #2
    Join Date
    Sep 2009
    Posts
    703

    Default Re: HTML and PIC communication

    First you need TCPIP communication.
    You can go with ethernet phy on pic eg PIC18F87j60. Any pic with external phy eg ENC28j60, and implement TCPIP on pic.
    Or go with w5500 with integrated TCPIP. Or go fuli integrated like some of microchip RN wifi modules, esp8266, or go with GSM/EDGE solution, with full TCPIP https etc...
    When you sort that, then it's easy. Like little more complicated serial port.
    Simplest would be using some modem with fully integrated IP application.
    I could give you more specific answer, but I need more details.

  3. #3
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    1,015

    Default Re: HTML and PIC communication

    It obviously isn’t PBP, but Microchip has an evaluation board and sample code that does exactly what you describe.
    It was later expanded by hobbyists to include Chan’s SD card library to host a web page, which is where I started on it,
    and made some demos, one of which could control a garage door with a smart phone, or other internet connected device.
    Not something I’d trust to use practically, but it worked.

    The code was a bit flaky, and didn’t work at all with some routers I’ve owned over the years, which is why I didn’t do much with it.

  4. #4
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,193

    Default Re: HTML and PIC communication

    Google for ESP8266 wifi module.
    There are many sample codes for posting button command to PIC with values from textbox.

    Then PIC responds back to the visitor.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  5. #5

    Default Re: HTML and PIC communication

    I agree with sayzer, wifi is definatly the easiest way to go.
    George

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,813

    Default Re: HTML and PIC communication

    Thanks for the replies. The phy layer is not difficult and either with cable or wireless will be OK. Even better a GSM modem (which is my final goal) as pedja089 pointed.

    My concern is on the html part and how to complete the communication. These examples I'm after right now.

    ESP examples is I guess a good starting point.

    Ioannis
    Last edited by Ioannis; - 18th March 2019 at 08:52.

  7. #7
    Join Date
    May 2013
    Location
    australia
    Posts
    1,603

    Default Re: HTML and PIC communication

    i think you need to add php or java to your repertoire .
    i went python , that does the whole lot in one go and be a/the server too . none of the options are easy or painless
    This is more entertaining than Free to Air TV

  8. #8
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,813

    Default Re: HTML and PIC communication

    I really hoped could get away with just html for now. Besides there are not much needed on such a project.

    Just receive and send some data, mostly numeric to set parameters on the PIC side and ON/OFF buttons to set or reset something.

    A simple html page might be enough for this.

    Can PBP handle all the TCP parameters and stack on a, say 18F87j60 chip? Or the ENC28J60 chip?

    I am a bit worry about it.

    Ioannis

  9. #9
    Join Date
    May 2013
    Location
    australia
    Posts
    1,603

    Default Re: HTML and PIC communication

    in this day and age it would seem a retrograde step to need a wired interface . those nodemcu esp8266 things are so cheap , heaps of pins to i/f to pic.
    i have been using raspberrypi's as a go between. next project i will look again at the esp offerings. i had a go with the esp-01 but found them unreliable and subject to lockups , surely they have improved
    This is more entertaining than Free to Air TV

  10. #10
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,813

    Default Re: HTML and PIC communication

    Agreed Ricahrd.

    But right now the physical layer is not my main concern. There are many options either wired or wireless (though I prefer wire for many reasons and all my devices are static IP, wired connected except my phone which has sometimes problems(!)).

    I have to succeed first communication of the PIC with the html page and the rest will follow.

    For example what is the html syntax to update a specific field in a specific page (if there are more than one)? Such things

    Ioannis

  11. #11
    Join Date
    May 2013
    Location
    australia
    Posts
    1,603

    Default Re: HTML and PIC communication

    you should be able to store/retrieve/edit data in an xml file with html ,i'm not sure how though its the blind leading the blind ,i'm watching with great interest
    afaik html has no native access to any physical comms layers , i/o is a client server type arrangement using put/get post etc.
    access to a tcpip socket needs java or similar

    where are all the perl php java experts when you need one
    Last edited by richard; - 18th March 2019 at 11:26.
    This is more entertaining than Free to Air TV

  12. #12
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,813

    Default Re: HTML and PIC communication

    Once I had a device (GSM remote controller) that was communicating to the PC via a RS-232 cable. On the PC side there was a small bridge program that opened the RS232 and a page in a browser.

    Then a connection was established to the device and a simple text page with buttons, input boxes and radio buttons was loaded from the device.

    All seemed just plain html. No java anything else was needed to load or use. And fast enough.

    I attach 3 screenshots of that interface which is represents exactly what I want to make.

    Ioannis
    Attached Images Attached Images    

  13. #13
    Join Date
    May 2013
    Location
    australia
    Posts
    1,603

    Default Re: HTML and PIC communication

    i guessing you don't have the source code . do you know what code language/s were used.
    python does that sort of thing fairly easily , it can do serial/ tcp sockets or just about anything else
    sql included
    This is more entertaining than Free to Air TV

  14. #14
    Join Date
    Apr 2014
    Location
    Northeast
    Posts
    271

    Default Re: HTML and PIC communication

    Microsoft has a forum dedicated to all things Visual Studio (Visual Basic in my case). I don't know if you're using VS but here is the link to the forum. Perhaps you can find answers there:

    https://social.msdn.microsoft.com/Fo...orum=vbgeneral
    I don't need the world to know my name, but I want to live a life so all my great-grandchildren proudly remember me.

  15. #15
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,813

    Default Re: HTML and PIC communication

    No code available. The MCU it had was something like NXP LPC series.

    Ioannis

  16. #16

    Default Re: HTML and PIC communication

    I don't think ESP was suggested because it saved wires rather that it was so easy to talk to a Pic device.

    Have a kook at this site https://randomnerdtutorials.com it's Arduino but so is pretty much everything these days.

    For example https://randomnerdtutorials.com/esp3...ather-station/ or ESP8266 Multisensor Shield with Node-RED

    There are several web site that do exactly what what you want, never used them myself. Goggle IOT (internet of things)
    Last edited by towlerg; - 18th March 2019 at 13:36.
    George

  17. #17

    Default Re: HTML and PIC communication

    B4X has a nice program "Basic for Java" or B4J to do desktop apps and it is free. I use the android version, very much like Visual Studio, object oriented.

    https://www.b4x.com/b4j.html

  18. #18
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,813

    Default Re: HTML and PIC communication

    Here is an interesting html tag:

    <meta http-equiv="Refresh" Content="3">

    that forces the browser to reload the page every 3 seconds.

    Makes the variables update kind of automated.

    The problem still is how to update that variable in the first place. Maybe the absolute way is to go for JAVA servlets or similar approach (a bit steep for me right now).

    Ioannis

  19. #19
    Join Date
    Apr 2011
    Location
    Portland, Oregon
    Posts
    212

    Default Re: HTML and PIC communication

    I think what you may be looking for is HTML forms.

    <FORM></FORM> tags define the boundaries and allow the definition of a method of transferring element content as a delimited list from inside an HTML document. The [Apply Changes] button (in your example above) is a [SUBMIT] button with a custom caption. To write values (default or otherwise) the "VALUE" property of the control is given a value. Here is an example (you may cut and paste this into Notepad, name with an .HTML extension, and open in a web browser:


    Code:
    <!DOCTYPE html>
    <html>
    <body>
    
    <h2>HTML Forms</h2>
    
    <form action="/action_page.php">
      First name:<br>
      <input type="text" name="firstname" value="Mickey">      'The value "Mickey" will appear as default text when the control is loaded. the "sent" value would be firstname&Mickey;[next name&value pair]; etc.
      <br>
      Last name:<br>
      <input type="text" name="lastname" value="Mouse">
      <br><br>
      <input type="submit" value="Apply Changes">
    </form> 
    
    <p>If you click the "Submit" button, the form-data will be sent to a page called "/action_page.php".</p>
    
    </body>
    </html>
    
    
    This is from https://www.w3schools.com/html/html_forms.asp - a competent tutorial, free and concise. It even allows you to test your code in a WYSIWYG environment. Quite nice.

    Other types of controls can return numerical values, true or false values, coordinates from image maps...
    Of course, this example is for the internet and a remote server, on a MCU, you might generate and evaluate your "page" in subroutines, transferring the created file/s back and fourth to a browser by wifi, serial link, or other other means.



    HTH -
    Amoque
    Last edited by Amoque; Yesterday at 00:59.

  20. #20
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,813

    Default Re: HTML and PIC communication

    Hi Amoque.

    Well, this is the general idea, but is not yet clear how this action will be performed on the PIC instead of a server.

    Ioannis

  21. #21
    Join Date
    Apr 2011
    Location
    Portland, Oregon
    Posts
    212

    Default Re: HTML and PIC communication

    Yes, I'm sorry that it is not so easy, from there.

    I think it may be necessary to visit forums for programming - depending on your operating system. The crux of your issue is the "bridge" program - it seems that it will be necessary to catch incoming serial data, then send it to an internal router address and port. It's quite easy to point your browser at an internal port, but how to route the serial... beyond me.

    Years ago I was a VB programmer and we had specific tools for capturing Com Port I/O and, likely there were/are similar internet gateway tools now. Unfortunately they aren't included in PB3.0. ;-)

  22. #22
    Join Date
    Apr 2011
    Location
    Portland, Oregon
    Posts
    212

    Default Re: HTML and PIC communication

    You know... Putty may be an answer.

    This: looks promising.

Similar Threads

  1. HTML design tool
    By ardhuru in forum WiFi
    Replies: 1
    Last Post: - 24th March 2016, 19:14
  2. I2C expressed in HTML I²C
    By Archangel in forum Off Topic
    Replies: 1
    Last Post: - 31st July 2008, 06:20
  3. Where did HTML Support GO?
    By Archangel in forum Forum Requests
    Replies: 4
    Last Post: - 4th July 2008, 10:40

Members who have read this thread : 14

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts