ESP32 in AP and STA mode is bad for your network - Page 1
Forum section: electronics / general

author: JustMeHere
author_rank: Frequent Contributor
timestamp: August 16, 2023, 06:29:31 pm
content: I just discovered that having an ESP32 in AP and STA mode is bad for your network. The AP mode will be on the same channel as STA. This is the same effect as having two APs on the same channel. I'm going to avoid thisI had my ESP32 set up this way for debugging/troubleshooting. But it looks like it should be avoided in production.

author: thm_w
author_rank: Super Contributor
timestamp: August 16, 2023, 09:00:03 pm
content: Is that an issue though? It just means the bandwidth will be shared.https://www.upesy.com/blogs/tutorials/how-create-a-wifi-acces-point-with-esp32#Of course if you are releasing a production product the debugging capabilities should generally be disabled.

author: Shonky
author_rank: Frequent Contributor
timestamp: August 16, 2023, 09:38:38 pm
content: 2 APs on the same channel is completely workable. Multiple APs can coexist together.Obviously they have to share the channel bandwidth but that's about it.

author: JustMeHere
author_rank: Frequent Contributor
timestamp: August 17, 2023, 12:25:37 am
content: It kills range. It's workable, but signal quality suffers. I've set up wifi networks that host 100+ phones. Separation of the channels is important. I've seen two APs jam each other. Unplugging the ESP32 device added 20 dB to my signal. quality.

author: Shonky
author_rank: Frequent Contributor
timestamp: August 17, 2023, 12:59:15 am
content: Quote from: JustMeHere on August 17, 2023, 12:25:37 amIt doesn't affect signal quality. Two devices can transmit on the same frequency and that's exactly what one AP and multiple STAs do all day every day.APs shouldn't be "jamming each other" and if they are then they are very poor quality units. People run separate APs on the same channel in dense areas all the time.You don't lose 20dB by plugging in a second AP.If you insist on separating your AP and STA, you essentially need two radios and any basic WiFi device like an ESP32 will just not have that.

author: dare
author_rank: Contributor
timestamp: August 18, 2023, 03:04:03 am
content: Quote from: Shonky on August 17, 2023, 12:59:15 amYep, pretty common for a lot of WiFi chipsets I expect. We (Nest) shipped a product that relied on simultaneous station / AP mode for set up. Hardest part was getting iPhones to follow along during the inevitable channel hop when the device connected to the user's home AP.

author: SiliconWizard
author_rank: Super Contributor
timestamp: August 18, 2023, 05:00:12 am
content: Quote from: JustMeHere on August 16, 2023, 06:29:31 pmGood to know, but indeed that would be a relatively odd configuration - I would even guess that most users of ESP32's are not aware of the possibility of using both modes at the same time.

author: bookaboo
author_rank: Frequent Contributor
timestamp: August 18, 2023, 05:07:56 am
content: It’s a fairly common mode used to set WiFi credentials. Though that use case is infrequent and brief.

author: Shonky
author_rank: Frequent Contributor
timestamp: August 18, 2023, 05:39:00 am
content: Quote from: bookaboo on August 18, 2023, 05:07:56 amYou don't have to have AP and STA running simultaneously and I think most do not.You put device in "setup mode". It then changes to an AP only. Your mobile device connects to that new AP to configure the SSID and PSK. The device then switches back to STA mode and connects to the user's AP. So no need to run them at the same time.

author: bookaboo
author_rank: Frequent Contributor
timestamp: August 18, 2023, 07:39:34 am
content: That's true but by having both you can run a webpage server on the ESP32 that informs the user of the status of connection to the WiFi router.

author: dare
author_rank: Contributor
timestamp: August 18, 2023, 02:40:25 pm
content: Quote from: Shonky on August 18, 2023, 05:39:00 amSure you can do it this way, but the user experience is pretty bad when they inevitably mistype the WiFi password. Certainly not suitable for a consumer product, but possibly fine in a more technical (e.g. industrial) setting.

author: artag
author_rank: Super Contributor
timestamp: August 18, 2023, 06:53:07 pm
content: Quote from: bookaboo on August 18, 2023, 07:39:34 amYou can do that even if the ESP32 is STA only. The webserver doesn't need to be on the AP. Of course, the status can't be 'disconnected'.

author: thm_w
author_rank: Super Contributor
timestamp: August 18, 2023, 09:28:29 pm
content: Quote from: dare on August 18, 2023, 02:40:25 pmIf the device can't connect to the AP (wrong password, not powered, etc.) it brings up the STA mode again. This is typical behavior for ESP8266/32 arduino.Of course with a Nest it might be a pain in the ass to power the thing off and on again, so there might be some specific scenarios it could get stuck in and having both available is good.

author: dare
author_rank: Contributor
timestamp: August 21, 2023, 03:07:40 am
content: Quote from: thm_w on August 18, 2023, 09:28:29 pmThe problem is the turn around time it takes the device to drop the AP, scan for the target network, connect to the network, attempt to auth, then bring up the AP again when something goes wrong. Add on top of this need for the user to recognize that the device hasn't connected (presumably via some visual signal on the device), manually re-connect their phone to the device's AP, get back to the configuration screen and try again. Even with support for simultaneous AP/STA mode, the various hiccups and delays that can happen during wifi setup often lead to user frustration and high product return rates. We battled with this quite a bit in the early days at Nest. That's one reason why so many devices use BLE during the setup process (although it's not without its own issues).

author: SiliconWizard
author_rank: Super Contributor
timestamp: August 21, 2023, 07:56:33 pm
content: Quote from: dare on August 21, 2023, 03:07:40 amTrue.