Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[General] ESP8266 module with PIC18F

Status
Not open for further replies.

Deexith Hasan

Advanced Member level 4
Joined
Oct 24, 2014
Messages
111
Helped
4
Reputation
8
Reaction score
3
Trophy points
18
Activity points
740
i tested my ESP8266 wifi module and send a command AT+ CWJAP =<ssid>,< 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?
 

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:
Code:
<html><body>
<form action="change.php" >
<input type="radio" name="relay" value="0" checked>off
<br>
<input type="radio" name="relay" value="1">on
<br>
<input type="submit" value="Send">
</form> 
</body></html>
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...
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top