Reasons for esp_modem_dte_send_cmd() Timeout
There can be many reasons that cause AT commands to time out where it is not expected. This can be an error or malfunction on the modem end (though this is very rare). Make sure you rule out any hardware issues by checking how we interface an ESP32 with cellular modems.
In most cases, timeouts occur because the timeout period set in the ESP32 firmware is not sufficient as per the AT command manual. 4G CAT1 modems tend to take longer to boot and respond to AT commands after power-up than 2G modems do.
Listed below are some reasons and proposed methods for fixing the timeout error. We have tried these fixes in diffierent products, mainly with ESP32 and SIM7600 or A7670 4G LTE modems from Simcom.
1. Bad Modem Reset or Power-Up
2. Not Waiting for AT Firmware to be Ready
There are three ways to solve this:
- Wait for the “RDY” message or similar indicator to ensure that the modem can accept AT commands before sending one.
- After modem is powered up and re-started and STATS becomes high to signal end of boot process, re-send AT command up to 10 times with 5 second delay in between attempts. This ensures that the modem receives the AT command when it is ready.
- After STATUS becomes high to signal that the modem is ready, wait an additional 15 seconds to make sure that the AT firmware is ready.
3. Short Default Timeout Setting
Considering the PPPoS examples provided in ESP32 ESP-IDF examples directory, there are some standard timeout values that are defined within the file “esp_modem_dce.h”. The “default” timeout setting of 500ms is too little for many 4G modems.
These timeout values can be changed and should be set to something that covers most command-response timelines specified in the modem datasheet. For SimCom 4G LTE modems, we like to use these values:
Feel free to ask away via the Quick Contact form in the sidebar, or leave a comment below.
- Initial Release: 23 October 2022
- Reference 1: SIM7600 AT Command Reference Manual
- Reference 2: ESP32 PPPoS Client Crash – ESP-IDF GitHub Issue Report