Hello everyone,
Hope you can shed some light for me.
I have the Lilygo sim7000g board (made up of the ESP32-WROVER-E and the SIM7000G).
My goal is to obtain the GPS coordinates using AT commands and using a SIM card to send that information via MQTT.
I have achieved this using Arduino IDE (using TinyGsmClient, PubSubClient and ArduinoJson) and I want to try to replicate it in ESP-IDF.
I'm currently using the Espressif IDE with esp-idf 4.4.2 and esp_modem 0.1.23.
It seems that esp_modem provides support for SIM7600 and SIM800. Reviewing the code maybe in the future also for SIM7000, but for now I haven't been able to make it work.
Has anyone achieved something similar using libraries other than esp_modem or in some other way?
Thank you very much.
Lilygo SIM7000G and ESP-IDF
Re: Lilygo SIM7000G and ESP-IDF
Hello,
SIM7000 is support is now integrated. But I'm also in the same situation. Arduino libraries like TinyGSM work with the Lillygo sim7000g without any problems. But we also want to use the ESP-IDF API for a more mature project setup.
As far as I can tell, the esp_modem component issues seems to be the UART connection setup using GPIO 26 and 27. The serial port setup does not seem to be successful. So each modem command will timeout.
The log level is set on verbose, but no real error appear, only the timeout.
The example pppos_client, from esp_modem, also has the same issue on this lillygo board.
Hope anybody has some more info about the esp_modem component and how the serial port is setup. Reading through the code the uart code is platform specific, as they also ported it to linux etc, and I'm unable to find how this is done on the ESP32 with source code.
Kind regards and thanks.
SIM7000 is support is now integrated. But I'm also in the same situation. Arduino libraries like TinyGSM work with the Lillygo sim7000g without any problems. But we also want to use the ESP-IDF API for a more mature project setup.
As far as I can tell, the esp_modem component issues seems to be the UART connection setup using GPIO 26 and 27. The serial port setup does not seem to be successful. So each modem command will timeout.
The log level is set on verbose, but no real error appear, only the timeout.
The example pppos_client, from esp_modem, also has the same issue on this lillygo board.
Hope anybody has some more info about the esp_modem component and how the serial port is setup. Reading through the code the uart code is platform specific, as they also ported it to linux etc, and I'm unable to find how this is done on the ESP32 with source code.
Kind regards and thanks.
Re: Lilygo SIM7000G and ESP-IDF
Initialising the SIM7000G using TinyGsm, so that the serial communication is working, and afterwards flashing the firmware using esp_modem will allow for serial communication to work.
Something is definitely not OK during serial setup using the esp_modem component (in combination with the lillygo board?).
Using the uart_driver directly I was more successful. The test code was a simple loop of AT commands. That made clear the first command after boot would always fail.
The dirty solution is to keep sending commands until the response is ESP_OK. Also be aware that the modem requires a power toggle on GPIO_NUM_4 after boot.
The modem power toggle code:
Hope this may help anyone in the future.
Something is definitely not OK during serial setup using the esp_modem component (in combination with the lillygo board?).
Using the uart_driver directly I was more successful. The test code was a simple loop of AT commands. That made clear the first command after boot would always fail.
The dirty solution is to keep sending commands until the response is ESP_OK. Also be aware that the modem requires a power toggle on GPIO_NUM_4 after boot.
Code: Select all
char resp[32];
esp_err_t err = esp_modem_at(dce, "ATI\r", resp, 1000);
while (err != ESP_OK) {
ESP_LOGE(TAG, "ATI failed with %d", err);
vTaskDelay(1010 / portTICK_PERIOD_MS);
err = esp_modem_at(dce, "ATI\r", resp, 1000);
if (err == ESP_ERR_TIMEOUT) {
// command timeout, modem may not be active
power_modem_on();
err = esp_modem_at(dce, "ATI\r", resp, 1000);
}
}
if (err == ESP_OK) {
ESP_LOGI(TAG, "ATI response=%s", resp);
}
The modem power toggle code:
Code: Select all
void power_toggle_modem() {
ESP_LOGI(TAG, "toggling modem power...");
gpio_set_direction(MODEM_PWKEY, GPIO_MODE_OUTPUT);
gpio_set_level(MODEM_PWKEY, GPIO_LOW);
vTaskDelay(10 / portTICK_PERIOD_MS);
gpio_set_level(MODEM_PWKEY, GPIO_HIGH);
vTaskDelay(1010 / portTICK_PERIOD_MS);
gpio_set_level(MODEM_PWKEY, GPIO_LOW);
ESP_LOGI(TAG, "waiting for modem...");
vTaskDelay(6510 / portTICK_PERIOD_MS);
ESP_LOGI(TAG, "toggled modem power.");
}
Re: Lilygo SIM7000G and ESP-IDF
For my setup it was also required to set the network mode to GSM only:
void configure_network_mode_gsm_only(esp_modem_dce_t* dce) {
ESP_LOGI(TAG, "Setting network mode...");
char resp[32];
esp_err_t err = esp_modem_at(dce, "AT+CNMP=13\r", resp, 1000);
if (err != ESP_OK) {
ESP_LOGE(TAG, "esp_modem setting network mode failed with %d", err);
}
}
void configure_network_mode_gsm_only(esp_modem_dce_t* dce) {
ESP_LOGI(TAG, "Setting network mode...");
char resp[32];
esp_err_t err = esp_modem_at(dce, "AT+CNMP=13\r", resp, 1000);
if (err != ESP_OK) {
ESP_LOGE(TAG, "esp_modem setting network mode failed with %d", err);
}
}
Who is online
Users browsing this forum: Bing [Bot] and 116 guests