+ Post New Thread
Results 1 to 2 of 2
  1. #1
    Full Member level 1
    Points: 923, Level: 6

    Join Date
    Oct 2014
    3 / 3

    ESP8266 module with PIC18F

    i tested my ESP8266 wifi module and send a command AT+ CWJAP =,< pwd > and joined with my wifi router.. atfer that how can i control devices with it?

    i want to control a relay from internet..i got many tutorials with arduino not with pic18f...i dont know much abt arduino......

    how can i create a button in my wifi module's ip address do i need to know HTML code for creating it?

    •   AltAdvertisment


  2. #2
    Advanced Member level 2
    Points: 6,608, Level: 19
    Kurenai_ryu's Avatar
    Join Date
    Jun 2006
    161 / 161

    Re: ESP8266 module with PIC18F

    sadly this module doesn't have a HTTP stack so you need to implement one by yourself,

    you don't need to connect to the wifi AP every time, but maybe implement a way to get the ip address assigned to the module (with command AT+CIFSR)

    then you need to configure your module to accept multiple connections (AT+CIPMUX=1) and enable the server at port 80 (AT+CIPSERVER=1,80)

    then you wait and wait a connection, if you browse to the module's ip address from your browser you stablish a basic GET connection
    in the module it will say 0,CONNECT (if other connections are established they could be identified by 1,2,3,4)

    in this moment the browser wiil send the HTTP request that you will see in the module as an IPD event (+IPD, 0, n: xxxxxxxxx) indicating the connection number (0), the bytes it sended (n) and the bye contents sended (xxxxx)... a common browser send a looot of information, but the important part is the HTTP GET / where it specifies the basic GET request. for your example a simple GET / request should send the html code for the button form, but the button request will generate anothet GET request (check by yourself but it should be something like GET /change.php?relay=1 )

    after the IPD you have to send the HTML content with AT+CIPSEND command (AT+CIPSEND=0,n where 0 is the connection and n the amount of bytes you want to send) then you wait for the caret ( the > symbol) and send the n bytes of content (basically the html form, but you can include some headers or extra http stuff...)

    lastly you need to close the connection with the AT+CIPCLOSE=0 command, (it would autclose after some time but better if you close after sending your html data...

    you basic html code should be something like this:
    off on
    which are 220 characters for your +CIPSEND command...

    when the GET Request isn't "/" but instead "/change.php" it will have extra information, the relay value, from the html code... it will be "?relay=0" or "?relay=1" so receive the GET request in the IPD event and turn on or off your relay according this value...

    in other words, you don't need to know HTML only, but also HTTP...

    the esp8266 is cheap but hard to work with...
    K~ Ryu
    ~"Sorry my bad english, my native language is C "

    1 members found this post helpful.

--[[ ]]--