The use of the ESP8266 in the world of IoT
User avatar
By farmerz24
#73814 Hi guys I am running into some issues with the ESP8266 and combined AP_STA modes.

The setup is as follows: I have an ESP8266 acting as the master node, which is connected to the internet to my server. To test his AP_STA mode, I connected my iphone to its softAP, sent a HTML request for a server endpoint i had created and i can see that the message is sent up to my server while my phone is connected to its SOFTAP.

So this is working well. I can simply refresh my browser to re-send the request and each time i see the ESP blink its lights 6 times to show that the request was successful being sent up to my server.

The problem happens when i add a second ESP into the mix. I set this one up exactly as the first, except it connects to the SOFTAP of the 1st ESP rather than to the my home router.
Then I connect my phone to the 2nd ESP and try to initate the web request on the 2nd esp.
What this does is relay my message to the 1st ESP, then the 1st esp relays this back up to the server.

HOWEVER, the request fails always when the 2nd ESP connects to the 1st. The response always come back with an httpcode greater than 0. ( http.GET(); )

If I point the second ESP to the router rather than the 1st, esp the 1st esp is able to send up the response 100% of the time. My phone is also always able to send a request when connected to the first ESP's wifi.

It seems like its an issue with the 2nd ESP. Note that if i only use station mode and don't setup a softAP then this code works. My work around is to have the esp switch from AP mode to station mode each time a request comes in but then i notice it takes up to like 5-10 seconds to connect to the AP each time. As this is a battery powered solution, any watt savings are needed.

I have read about the 1 channel issue for combined AP_STA mode, however it appears everything is always on channel 11. The only way i have got this to work is by shutting down AP mode and going into station.

However, i know it must work in both combined AP + STA modes as the 1st ESP is doing just that.
When i hit refresh in my browser, the request is sent almost instantaneously. When doing the connect/reconnect to switch between modes its taking 5-10 seconds which is too long.

now perhaps having the radio in AP mode uses less power than always being connected to a server in Station mode. I can test that, but ideally would like to know why the above occurs.. Have also tried setting up the Soft AP with hardcoded channel #'s to no avial.

can post code if needed, any advice appreciated.