Configure esp as access point and server
Posted: Sat Mar 07, 2015 12:24 am
Instead of connecting this device to your access point you can instead configure the esp8266 as an access point and as a server. This allows connecting your pc to the esp provided AP and sending and receiving data from it. One advantage of this approach is that you don't have to hardcode your AP's password in your arduino sketch. It also allows multiple connections at the same time including connecting other esp devices.
Attached is example code that allows connecting a browser to 192.168.4.1:8000 and receiving a string counting the number of refreshes. This could be changed to sending temperature or other data or switching a device on and off, etc..
Procedure:
1. This sketch is configured to setup the esp as an AP on boot up.
2. you can then connect your PC to AP "esp826605", provided it has wireless access.
3. start up a terminal and ping 192.168.4.1 this is the default IP of all esp devices.
The ping will tell you if your accessing the esp AP. You can also type ipconfig to see what IP adr the esp AP assigned to your PC.
4. Now you should be able to launch a browser and connect to 192.168.4.1:8000
if you successfully connect you will see the following string displayed on the browser page.
Counter Value = 1
Each time you refresh the count will increment.
Additionally, you can use this sketch to time a round trip sent from another esp to this AP which sends it back to the sender.
i was getting average times of about 150ms for the round trip.
if anyone is interested in seeing that code, let me know and i will upload it.
Attached is example code that allows connecting a browser to 192.168.4.1:8000 and receiving a string counting the number of refreshes. This could be changed to sending temperature or other data or switching a device on and off, etc..
Procedure:
1. This sketch is configured to setup the esp as an AP on boot up.
2. you can then connect your PC to AP "esp826605", provided it has wireless access.
3. start up a terminal and ping 192.168.4.1 this is the default IP of all esp devices.
The ping will tell you if your accessing the esp AP. You can also type ipconfig to see what IP adr the esp AP assigned to your PC.
4. Now you should be able to launch a browser and connect to 192.168.4.1:8000
if you successfully connect you will see the following string displayed on the browser page.
Counter Value = 1
Each time you refresh the count will increment.
Additionally, you can use this sketch to time a round trip sent from another esp to this AP which sends it back to the sender.
i was getting average times of about 150ms for the round trip.
if anyone is interested in seeing that code, let me know and i will upload it.