Best Practices for Using ESP-AT?

coopercm
Posts: 1
Joined: Wed Sep 23, 2020 9:20 pm

Best Practices for Using ESP-AT?

Postby coopercm » Thu Sep 24, 2020 5:49 pm

I'm using an ESP32 running the ESP-AT firmware (currently v1.3) in a device that reads a temperature every 15 minutes, sends the data to a server, and then it goes to sleep. We completely cut power to the radio when the device is asleep so we don't take advantage of the ESP32's sleep modes.

When things are working and connecting, I don't have any issues, but it's when things aren't connecting that my issues with the ESP32 seem to be compounded.

Here's a rundown of how the ESP32 operates within my device:

1. Initialization - This is where the WiFi radio's settings are set
AT Commands used:
AT+RESTORE - to erase the radio in case it's already programmed with older settings
AT+CWMODE=1 - to set the device as a station
AT+UART_DEF=115200,8,1,0,0 - setup the comm settings
AT+CWHOSTNAME=\"%c%c%c%c\"
AT+CIPDNS=1,"8.8.8.8","1.1.1.1"
AT+CWDHCP=1,1 - to set to DHCP mode
AT+CWJAP="SSID","passkey"

Are there any important settings here that I might be missing?

2. Connection check
I poll the device with AT+CIPSTATUS for ~30 times (once every second) or until I get 2 or 3. If at the end of 30 polls I still haven't gotten 2 or 3, I'll power cycle the radio and wait a set amount of time until I start polling with CIPSTATUS again.

Essentially the only method I'm using to attempt a reconnection is power cycling the radio with the AT+CWAUTOCONN (which is set to enabled by default). Is this sufficient? Is there any more direct way to getting the ESP32 to attempt to reconnect to the AP?

3. If I get a good response from CIPSTATUS, I'll open a socket with AT+CIPSTART and then send my data with AT+CIPSEND

I don't really ever have issues when I get to this point. It's more that I have issues when I get disconnected from the AP. I know there's a new firmware version for ESP-AT (v2.1) and it looks like CWJAP has some new additions for staying connected to the AP, but I'm wondering if there's anyway to improve getting reconnected on v1.3 other than power cycling the radio.

Thanks for your help in advance.

Who is online

Users browsing this forum: tomy983 and 255 guests