UART communication EC200U-CN

Recently i have purchased quectel EC200U-CN EVM board ,using qcom tool i have tesetd all the AT commands and its working fine. Now i want to send the AT commands to EC200 from extranal MCU through UART , kindly help me how to do this UART communication between extranal MCU to EC200U-CN EVM board.

Reference below:


Pay attention to level matching.
NOTE:

The TXD/RXD of the module should be cross-connected with the TXD/RXD of the external MCU.

The RTS/CTS of the module should be directly connected with the RTS/CTS of the external MCU.

@fiona.fang

Is it mandatory to connect rts/cts signal as only tx ,rx won’t work in my case I have connect my MCU and quectel module ec200u and there is a translator in b/w that but still I am not able to communicate with the quectel module over ttl

Could you give me more information such as picture or your schematic.

hello there i might have the same case here i just follow your schematic and i try to connect with ec200ucn with LTE-OPEN-EVB at the evaluation board i connected Main_TXD to STM32 USART_RX and Main_TXD to STM32 USART_RX via TXS0108E module. Because i use only 2 channel at first i keep the unused channel of TXS0108E to the ground with 56k resistor (2 chnnael with 10k because i out of 56k resistor). the result is my stm32 and cant connected, it’s even dont response AT command STM32 that programmed. Before this i also remove the resistor and keep the unused channel not connected after i heard TXS0108 has internal pull-up and the result it still the same. Also before i used ESP32 that also has 3.3v RX TX level logic and try to use software serial library. It response my AT command but the result want “Ok” but only unreadable response. I also use another command like "AT+CPIN?’ that response longer unreadable response. Idk which thing i must try. also the schmeatic of how i connected the pin is same as u guys i just only used 2 channel.
this is also my stm32 lastest code

code:
/* USER CODE BEGIN Header /
/
*


  • @file : main.c
  • @brief : STM32F446RE + EC200U-CN (Firebase HTTP PUT)

/
/
USER CODE END Header */

#include “main.h”
#include <string.h>
#include <stdio.h>

/* ================= CONFIG ================= */
#define RX_BUF_SIZE 1024
#define EC_TIMEOUT_SHORT 2000
#define EC_TIMEOUT_LONG 8000

UART_HandleTypeDef huart2; // EC200U
UART_HandleTypeDef huart3; // DEBUG (Serial Monitor)

/* ================= GLOBALS ================= */
uint8_t ec_rxBuf[RX_BUF_SIZE];
uint16_t ec_rxIndex;

/* ================= PROTOTYPES ================= */
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_USART2_UART_Init(void);
static void MX_USART3_UART_Init(void);

void DEBUG_Print(const char *msg);
void EC200U_SendRaw(const char *data);
void EC200U_SendCmd(const char *cmd);
void EC200U_Read(uint32_t timeout);
uint8_t EC200U_WaitFor(const char *str, uint32_t timeout);

/* ================= FUNCTIONS ================= */

void DEBUG_Print(const char msg)
{
HAL_UART_Transmit(&huart3, (uint8_t
)msg, strlen(msg), HAL_MAX_DELAY);
}

void EC200U_SendRaw(const char data)
{
HAL_UART_Transmit(&huart2, (uint8_t
)data, strlen(data), HAL_MAX_DELAY);
}

void EC200U_SendCmd(const char *cmd)
{
DEBUG_Print(“\r\n[EC200U TX] “);
DEBUG_Print(cmd);
DEBUG_Print(”\r\n”);

EC200U_SendRaw(cmd);
EC200U_SendRaw("\r\n");

}

void EC200U_Read(uint32_t timeout)
{
uint8_t ch;
uint32_t start = HAL_GetTick();

ec_rxIndex = 0;
memset(ec_rxBuf, 0, RX_BUF_SIZE);

while ((HAL_GetTick() - start) < timeout)
{
    if (HAL_UART_Receive(&huart2, &ch, 1, 10) == HAL_OK)
    {
        if (ec_rxIndex < RX_BUF_SIZE - 1)
        {
            ec_rxBuf[ec_rxIndex++] = ch;
        }
        HAL_UART_Transmit(&huart3, &ch, 1, HAL_MAX_DELAY); // live echo
    }
}

}

uint8_t EC200U_WaitFor(const char str, uint32_t timeout)
{
EC200U_Read(timeout);
return (strstr((char
)ec_rxBuf, str) != NULL);
}

/* ================= MAIN ================= */

int main(void)
{
HAL_Init();
SystemClock_Config();

MX_GPIO_Init();
MX_USART2_UART_Init();
MX_USART3_UART_Init();

HAL_Delay(3000);
DEBUG_Print("\r\n===== STM32 BOOT OK =====\r\n");

/* ---------- MODEM CHECK ---------- */
EC200U_SendCmd("AT");
if (!EC200U_WaitFor("OK", EC_TIMEOUT_SHORT))
{
    DEBUG_Print("\r\n[ERROR] EC200U NOT RESPONDING\r\n");
    while (1);
}
DEBUG_Print("\r\n[EC200U] OK\r\n");

/* ---------- SIM CHECK ---------- */
EC200U_SendCmd("AT+CPIN?");
if (!EC200U_WaitFor("READY", EC_TIMEOUT_SHORT))
{
    DEBUG_Print("\r\n[ERROR] SIM NOT READY\r\n");
    while (1);
}
DEBUG_Print("\r\n[SIM] READY\r\n");

/* ---------- NETWORK ---------- */
EC200U_SendCmd("AT+CGATT=1");
EC200U_WaitFor("OK", EC_TIMEOUT_LONG);

/* ---------- HTTP CONFIG ---------- */
EC200U_SendCmd("AT+QHTTPCFG=\"contextid\",1");
EC200U_WaitFor("OK", EC_TIMEOUT_SHORT);

/* ---------- URL ---------- */
DEBUG_Print("\r\n[HTTP] Sending URL...\r\n");
EC200U_SendCmd("AT+QHTTPURL=155,80");

if (!EC200U_WaitFor("CONNECT", EC_TIMEOUT_SHORT))
{
    DEBUG_Print("\r\n[ERROR] URL CONNECT FAILED\r\n");
    while (1);
}

EC200U_SendRaw(
//api key + URL databse
);

EC200U_WaitFor("OK", EC_TIMEOUT_LONG);

/* ---------- HTTP PUT ---------- */
DEBUG_Print("\r\n[HTTP] Sending payload...\r\n");
EC200U_SendCmd("AT+QHTTPPUT=26,80");

if (!EC200U_WaitFor("CONNECT", EC_TIMEOUT_SHORT))
{
    DEBUG_Print("\r\n[ERROR] PUT CONNECT FAILED\r\n");
    while (1);
}

EC200U_SendRaw("\"from stm32 : hello :D\"");

if (EC200U_WaitFor("+QHTTPPUT: 0,200", EC_TIMEOUT_LONG))
    DEBUG_Print("\r\n[FIREBASE] SEND SUCCESS ✅\r\n");
else
    DEBUG_Print("\r\n[FIREBASE] SEND FAILED ❌\r\n");

while (1) {}

}

/* ================= HAL INIT ================= */

void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

__HAL_RCC_PWR_CLK_ENABLE();
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE3);

RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
RCC_OscInitStruct.PLL.PLLM = 16;
RCC_OscInitStruct.PLL.PLLN = 336;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;
RCC_OscInitStruct.PLL.PLLQ = 2;

HAL_RCC_OscConfig(&RCC_OscInitStruct);

RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
                           | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2);

}

static void MX_USART2_UART_Init(void)
{
huart2.Instance = USART2;
huart2.Init.BaudRate = 115200;
huart2.Init.WordLength = UART_WORDLENGTH_8B;
huart2.Init.StopBits = UART_STOPBITS_1;
huart2.Init.Parity = UART_PARITY_NONE;
huart2.Init.Mode = UART_MODE_TX_RX;
HAL_UART_Init(&huart2);
}

static void MX_USART3_UART_Init(void)
{
huart3.Instance = USART3;
huart3.Init.BaudRate = 115200;
huart3.Init.WordLength = UART_WORDLENGTH_8B;
huart3.Init.StopBits = UART_STOPBITS_1;
huart3.Init.Parity = UART_PARITY_NONE;
huart3.Init.Mode = UART_MODE_TX_RX;
HAL_UART_Init(&huart3);
}

static void MX_GPIO_Init(void)
{
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
}

void Error_Handler(void)
{
__disable_irq();
while (1) {}
}