Beginner Questions: ESP8266 as webserver

I have some general questions about the ESP and how it can be used (or not)…
(hopefully someone can/will answer)

Goal:
Use ESP8266 01 as a ‘wi-fi’ connection… paired with an Arduino Pro-Micro.

  • Yes, I know you can use the ESP module standalone… but in this case, the Pro-Micro is needed so I use it as a HID device connected to a PC…

more or less,…
I want to HOST a webpage on the ESP module with a few links (maybe 10 ‘links’).
that when clicked, send a url/query param back to the ESP … this parameter will then be echo’d/mirror’d out via serial to the connected pro-micro…
Pro-Micro parses this ‘parameter’ (serial data) as send an HID command to the PC…

(seems simple enough in theory… but I dont have much exposure to the ESP modules yet)

I’m guessing I’ll need ‘2’ skecthes.

1 x for the ESP module to host the webpage, and send out the $_GET/$_POST data from the response via serial to the connect Arduino

1 x for the Arduino to listen/parse this serial data and send out the matching HID action to the connected PC.

Question 1:

Is there any flaws in the approach I intend to take above?

Moving on… I have some questions about the usage/set-up of the ESP module.

Needs: (wants)

Have the ESP host the webpage itself… (I dont want to make an HTML file hosted on my domain… that reaches out to the ESP via IP address/port fowarding…etc…etc… I want the page itself to be hosted on the ESP)

  • I have read and saw mention of this in other posts/articles… I need to use/flash the ESP module with nodeMCU? ← is this correct?

So the ESP module needs to be set up as ‘webserver’ (correct?)…

  • this is where I’m getting a bit confused.

If I set it up as a webserver… do I assign it an IP address?
From a quick look at some random sketches/code posted… I see people are connecting to an existing network? (via SSID/PASSWORD)… is this needed? Can a device (cell phone for example) just connect directly to the ESP module? Or does it -NEED- to connect to an existing network?

(I’m not quite clear how the ESP works in this respect to getting an IP address…and connecting to it directly)
Client vs Server vs Both vs Access Point…etc

  • anyone chime in and clear this up for me!? :slight_smile:

If I -do- need to connect to an existing network… how will I know the IP address of the device once connected?

ie: I build the device at home… test… works… I bring it to work… update the SSID/password to connect to that wi-fi network… how can I get the IP address of the ESP device then? (will it just show up in my cell phone when searching for new available wi-fi networks??)

I’ll stop here, as there is already a handful or questions…

I have read things here & there… but want to get some feedback to eliminate doubt and for clarification!

thanks!

Overview | ESP8266 Temperature / Humidity Webserver | Adafruit Learning System may be helpful
they upload new firmware to the ESP8266

http://www.martyncurrey.com/arduino-esp8266-web-server/
is a tutorial that retains the ESP8266 AT firmware

The ESP8266 can be configured either as an access point or as a client or server on an existing WLAN. If you go the access point route, the project linked below is an example of configuring the ESP8266 as an access point and directing any traffic on the network to itself, so you wouldn't need to discover the device IP address.

ESP8266 Captive Portal

The author frequents this forum, so perhaps he will add to this.

Thanks guys...

Yes, I know I'll need to upload new firmware to the ESP if I want to set it up as a webserver..

I also upnderstand that I will need to re-flash the AT firmware if I want to throw AT commands at it.. and set any 'low level' settings..

@MrMark -

Thanks for the link.. I'll check it out now.

before I do.. (maybe a little clarification for myself is needed)

If I set up the ESP as an 'Access Point' (AP).. can I still HOST (serve) the the 'web page' on the ESP itself?

I guess I'm not really clear on the real world uses/examples for each of the ESP configuration states

CLIENT:
The ESP module is used to 'reach out' (send) to other 'on-line' assets.. (such a .php script to dump/send some data to a database)

SERVER:
a.) Can HOST a 'web page'.. that a wi-fi devfice can connect to and see this 'content
b.) Used to 'RECEIVE' data from another on-line asset/resource (ie: a web page located on some domain on the internet, sends some data to the ESP for it to parse and behave accordingly)

ACCESS POINT: (AP)
Lets the ESP module itself show up in 'available wi-fi networks'??
Can be configured to forward any/all traffic back to ITSELF (hence serving up its own 'web page', so to speak)...

Question: What happens when I POST http data back to itself?

Im assuming I create an HTML form (of sorts).. but when I click on any of the 'links'.. I send it BACK to the ESP to grab this parameter, and forward over to the Arduino via serial?

If this is correct, this looks to be the approach I am looking for.

Other real world use/example?

(guess I'll know more once I read the link) :slight_smile:

Thanks

update:

@MrMark

Just wanted to say thanks again (this clears up some things.. and looks to be perfect reading for this project!)

Keep the comments coming guys!

I am not sure why I would want another access point if I already have one.

The main use case I see for ESP8266 as webserver is if you didn't have an AP at the site where the device was to be located - then you'd just connect to it with your wifi compatible laptop or mobile device to interact with it.

I'm not sure whether it can connect to a different WiFi network while still acting as an AP (of course, if it can, you might as well, unless power consumption is a big issue (The AP function increases power consumption - though the ESP8266 is kind of a hog no matter what.

If you're using it in AP mode, you can still interact with a webpage hosted on it just like if it were on another network. I'm confused as to what you think would be different about this case?

You probably don't need to use POST requests, btw - if the request doesn't contain much data, I just use GET requests with a url parameter.

xl97:
I have some general questions about the ESP and how it can be used (or not)…
(hopefully someone can/will answer)

Goal:
Use ESP8266 01 as a ‘wi-fi’ connection… paired with an Arduino Pro-Micro.

  • Yes, I know you can use the ESP module standalone… but in this case, the Pro-Micro is needed so I use it as a HID device connected to a PC…

more or less,…
I want to HOST a webpage on the ESP module with a few links (maybe 10 ‘links’).
that when clicked, send a url/query param back to the ESP … this parameter will then be echo’d/mirror’d out via serial to the connected pro-micro…
Pro-Micro parses this ‘parameter’ (serial data) as send an HID command to the PC…

(seems simple enough in theory… but I dont have much exposure to the ESP modules yet)

I’m guessing I’ll need ‘2’ skecthes.

1 x for the ESP module to host the webpage, and send out the _GET/_POST data from the response via serial to the connect Arduino

1 x for the Arduino to listen/parse this serial data and send out the matching HID action to the connected PC.

Question 1:

Is there any flaws in the approach I intend to take above?

Moving on… I have some questions about the usage/set-up of the ESP module.

Needs: (wants)

Have the ESP host the webpage itself… (I dont want to make an HTML file hosted on my domain… that reaches out to the ESP via IP address/port fowarding…etc…etc… I want the page itself to be hosted on the ESP)

  • I have read and saw mention of this in other posts/articles… I need to use/flash the ESP module with nodeMCU? ← is this correct?

So the ESP module needs to be set up as ‘webserver’ (correct?)…

  • this is where I’m getting a bit confused.

If I set it up as a webserver… do I assign it an IP address?
From a quick look at some random sketches/code posted… I see people are connecting to an existing network? (via SSID/PASSWORD)… is this needed? Can a device (cell phone for example) just connect directly to the ESP module?

Yes, it can. If you get the esp package for the Arduino ide, there are examples in the examples tab.

If I -do- need to connect to an existing network… how will I know the IP address of the device once connected?

ie: I build the device at home… test… works… I bring it to work… update the SSID/password to connect to that wi-fi network… how can I get the IP address of the ESP device then? (will it just show up in my cell phone when searching for new available wi-fi networks??)

You can tell the esp8266 which IP address to use.

I’d also recommend implementing OTA programming of the esp.

It’s super easy and allows you to program the ESP wirelessly. You can also program the Arduino wirelessly via the esp8266 with a few extra wires/resistors.

You can set up the esp as an ap while still connected to the main network using softAP.

@ieee488 -

I'm not following your comment?

everyone else..

thanks for the response.

I want to use AP mode.. so I dont have to much about connecting to any wi-fi networks.

TO me.. this means.. I can move my device form place to place.. connect to ANY pc.. and using a cell phone.. connect DIRECTLY to the ESP ('web page')... and using $_POST/$_GET send this 'command/action' back to the Arduino (which ihs tunr will send a HID (keyboard/mouse) command to the connected PC.

cell phone >> ESP/web page >> output to Arduino Pro Micro >> action sent to PC

Basically the ESP is ONLY acting a s wi-fi GUI..

I dont need not want to connect with any network (per se`).. there is no need for 'internet/intranet' access..

Just serve up the 'page' hosted on the ESP and parse data 'submitted' by the web page/form... pass on to the Pro-Micro

xl97:
@MrMark

Just wanted to say thanks again (this clears up some things.. and looks to be perfect reading for this project!)

Thanks is due to Ray, I'm just passing on a link that I found to be particularly helpful.

oh… I understand who wrote the tut/shared the project…

but I didnt know about it until you shared it.

I haven't ordered an esp8266 yet because when I follow the instructions here with IDE V 1.65, the esp8266 Comunity doesn't show up in the Board Manager.

I'm not sure about 1.65 but it works flawlessly >1.66

I followed these instructions.

Ok, I figured out what I did wrong. I didn't realize you actually have to click on the "Boards Manager" label when you go to "Boards" , then type in "esp8266" in the search bar to pull up the ESP8266 Community , then click on "ADD". It's installed now but Adafruit is out of the HUZZAH so I have to wait for them to notify me it's in stock. I don't know anything about webservers so I will probably have to learn how to use it once I get it. At the moment I have no idea how to use the Wifi.

raschemmel:
Adafruit is out of the HUZZAH so I have to wait for them to notify me it's in stock.

Take a punt and order one or two $4 ones on eBay, see how long they take to arrive.