Help with getting UART response from SIM7080G to ESP32-S3

stere0
Posts: 1
Joined: Thu Feb 20, 2025 2:33 am

Help with getting UART response from SIM7080G to ESP32-S3

Postby stere0 » Thu Feb 20, 2025 2:38 am

I'm not getting a response via UART from a M5Stack SIM7080G with a ESP32-S3-WROOM.

The wiring is attached (I tried to switch yellow and white), I'm sorry for the mess.

Status LEDS in the M5Stack SIM7080G blink blue and solid red. Which should mean that they work.

I only have a multi-meter which reads 3.2v on yellow (GPIO16) and 3.3v on white (GPIO17). Voltage is 5v.

My code follows below.

My feeling is that the software is failing somewhere, but I'm not sure what. Any help or tips would be super appreciated. Unfortunately, I don't have an oscilloscope.

Code: Untitled.c Select all

#include <stdio.h>
#include <string.h>
#include "driver/uart.h"
#include "driver/gpio.h"
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"

#define SIM7080_TXD (GPIO_NUM_17)
#define SIM7080_RXD (GPIO_NUM_16)
#define UART_PORT_NUM UART_NUM_1
#define UART_BAUD_RATE 115200
#define BUF_SIZE 1024
#define RESPONSE_TIMEOUT_MS 3000

static const char *TAG = "SIM7080";

static void sim7080_init(void) {
ESP_LOGI(TAG, "Initializing UART for SIM7080...");
ESP_LOGI(TAG, "TXD: %d, RXD: %d, Baud Rate: %d", SIM7080_TXD, SIM7080_RXD, UART_BAUD_RATE);

uart_config_t uart_config = {
.baud_rate = UART_BAUD_RATE,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.source_clk = UART_SCLK_DEFAULT,
};

ESP_ERROR_CHECK(uart_driver_install(UART_PORT_NUM, BUF_SIZE * 2, BUF_SIZE * 2, 0, NULL, 0));
ESP_ERROR_CHECK(uart_param_config(UART_PORT_NUM, &uart_config));
ESP_ERROR_CHECK(uart_set_pin(UART_PORT_NUM, SIM7080_TXD, SIM7080_RXD, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE));

ESP_LOGI(TAG, "UART initialized successfully");
}

static bool send_at_command_with_response(const char* command, uint32_t timeout_ms) {
ESP_LOGI(TAG, "Sending command: %s", command);

// Clear any existing data in RX buffer
uart_flush(UART_PORT_NUM);

// Send command
uart_write_bytes(UART_PORT_NUM, command, strlen(command));
uart_write_bytes(UART_PORT_NUM, "\r\n", 2);

// Read response
uint8_t* data = (uint8_t*) malloc(BUF_SIZE);
memset(data, 0, BUF_SIZE);

int length = 0;
uint32_t start_time = xTaskGetTickCount() * portTICK_PERIOD_MS;

while ((xTaskGetTickCount() * portTICK_PERIOD_MS - start_time) < timeout_ms) {
int bytes_read = uart_read_bytes(UART_PORT_NUM, data + length, BUF_SIZE - length - 1, pdMS_TO_TICKS(100));
if (bytes_read > 0) {
length += bytes_read;
data[length] = 0; // Null terminate

// Check if we have a complete response
if (strstr((char*)data, "OK") || strstr((char*)data, "ERROR")) {
break;
}
}
}

bool success = false;
if (length > 0) {
ESP_LOGI(TAG, "Response (%d bytes): %s", length, (char*)data);
success = (strstr((char*)data, "OK") != NULL);
} else {
ESP_LOGE(TAG, "No response received within %d ms", timeout_ms);
}

free(data);
return success;
}

static void diagnostic_test(void) {
ESP_LOGI(TAG, "Starting SIM7080G comprehensive diagnostic test");
ESP_LOGI(TAG, "-------------------------------------------");

// Basic AT test
ESP_LOGI(TAG, "1. Testing basic AT communication");
if (!send_at_command_with_response("AT", 1000)) {
ESP_LOGE(TAG, "Basic AT test failed");
return;
} else {
ESP_LOGI(TAG, "Basic AT test passed");
}
}

void app_main(void) {
// Initialize UART
sim7080_init();

// Wait for module to stabilize
ESP_LOGI(TAG, "Waiting for module to stabilize (5 seconds)...");
vTaskDelay(pdMS_TO_TICKS(5000));

// Run diagnostic test
diagnostic_test();

ESP_LOGI(TAG, "\nEntering command loop - you can now use the serial monitor to send AT commands");

// Command loop
char cmd[256];
while (1) {
int len = uart_read_bytes(UART_PORT_NUM, (uint8_t*)cmd, sizeof(cmd) - 1, pdMS_TO_TICKS(100));
if (len > 0) {
cmd[len] = 0;
send_at_command_with_response(cmd, RESPONSE_TIMEOUT_MS);
}
vTaskDelay(pdMS_TO_TICKS(100));
}
}
Attachments
IMG_4271.jpeg
IMG_4271.jpeg (1.36 MiB) Viewed 1308 times

ozkaraha
Posts: 2
Joined: Mon Dec 19, 2022 3:08 am

Re: Help with getting UART response from SIM7080G to ESP32-S3

Postby ozkaraha » Thu Mar 19, 2026 11:41 am

Hi, did you find a solution for this problem. I have exactly the same problem. No response to any command.

Who is online

Users browsing this forum: trendictionbot and 2 guests