Problem sending AT+CWJAP from PIC32 to ESP8266 (UART communication issue)

Eestika
Posts: 1
Joined: Thu Aug 28, 2025 7:00 pm

Problem sending AT+CWJAP from PIC32 to ESP8266 (UART communication issue)

Postby Eestika » Thu Aug 28, 2025 7:05 pm

Hello everyone,

I am working on a learning project where I need to establish a simple 3-node communication:

PIC32 (Master)

Raspberry Pi 4 (listener in Python, TCP server)

PIC32 (Slave)

At this stage I am focusing only on the Wi-Fi part with ESP8266 modules using AT commands.

⚡ Setup:

IDE: MPLAB X with MCC generated drivers

MCU: PIC32MX795F512L (on Microchip board)

UART4 connected to ESP8266 (AT firmware)

I can monitor traffic using a USB-RS485 adapter + Tera Term

AT commands tested manually with Tera Term work fine (AT, ATE0, AT+CWMODE=1, AT+CWJAP, AT+CIPSTART …).

⚡ Issue:
From the PIC32 code, I can successfully send:

AT → OK

ATE0 → OK

AT+CWMODE=1 → OK

But when I send AT+CWJAP="SSID","PASS" the command does not appear on the ESP side (I don’t even see it in Tera Term), so the ESP never replies.
It looks like the UART stops transmitting correctly at that point.

⚡ Code structure:
I wrote low-level UART functions (U4_SendLine, U4_WaitOK, etc.) and a WiFi_AT_Initialize() sequence.
Here is the simplified part of the code:

// Example snippet
U4_SendLine("AT");
if (!U4_WaitOK(4000)) { error(); }

U4_SendLine("AT+CWMODE=1");
if (!U4_WaitOK(4000)) { error(); }

char cmd[160];
snprintf(cmd, sizeof(cmd), "AT+CWJAP=\"%s\",\"%s\"", WIFI_SSID, WIFI_PASS);
U4_SendLine(cmd);
if (!U4_WaitOK(30000)) { error(); }


⚡ Question:

Why does the AT+CWJAP command not even reach the ESP when sent from the PIC32?

Could it be related to CRLF handling, buffer size, or timing issues with long strings?

Do I need to handle \r\n differently when sending AT commands from PIC32?

Any advice or suggestions would be greatly appreciated 🙏

Thanks in advance!

Daniele

Who is online

Users browsing this forum: Perplexity-User and 4 guests