ESP32 AT Commands With STM32 (ESP32-C3 WiFi)

In this tutorial, we’ll discuss how to use the ESP32 AT commands (ESP-AT) with STM32 microcontrollers, using an ESP32-C3 as a WiFi co-processor. You’ll learn how the ESP-AT firmware works, which ESP-AT version to use, how to flash it on an ESP32-C3, how to wire the ESP32-C3 to an STM32 Blue Pill, and how to configure the STM32 UART with DMA in CubeMX to talk to it.

Then, we’ll build four STM32 ESP32-C3 example projects with our own non-blocking ESP_AT driver: AT commands, connecting to WiFi with automatic reconnection, a TCP client that sends and receives data, and network time (SNTP) with ping. We’ll also compare the ESP32-C3 and the ESP8266 on the bench, and finish with a complete ESP32 AT commands list with the real replies from our module. This is the third part of our STM32 WiFi tutorial series. Without further ado, let’s get right into it!

STM32 WiFi Tutorial Series: Part 3 of 8
1 STM32 WiFi2 STM32 ESP82663 STM32 ESP32-C34 HTTP Client5 Web Server6 MQTT7 OTA Update8 WebSocket

Note: The STM32 code examples in this tutorial are tested with: STM32 Blue Pill (STM32F103C8T6), WeAct ESP32-C3 Core Board with ESP-AT firmware.


STM32 ESP32-C3 WiFi: How It Works

ESP-AT is Espressif’s official AT command firmware for its ESP32 chips. It turns an ESP32 into a WiFi co-processor: the STM32 sends text commands over a UART ( AT+CWJAP="MyWiFi","password" to join a network, AT+CIPSTART to open a TCP connection, AT+CIPSEND to send data), and the ESP32 answers with text replies ( OK, ERROR, +IPD,... for received data). The ESP32 runs the TCP/IP stack, TLS, DNS, and even an HTTP and MQTT client, so the STM32 needs none of them.

ESP-AT supports the ESP32, ESP32-C2, ESP32-C3, ESP32-C5, ESP32-C6, ESP32-C61, and ESP32-S2. The ESP32-C3 is the best fit for an STM32 project: it’s one of the cheapest chips in the family, its AT port is a separate UART from its boot log, and it gets every ESP-AT release. The ESP8266 runs an older AT firmware, which we covered in the ESP8266 AT commands with STM32 tutorial. The commands are almost the same, so the same STM32 driver works with both.

STM32 ESP32-C3 WiFi architecture: the STM32 application and ESP_AT driver talk over UART to the ESP-AT firmware on the ESP32-C3, which runs the TCP/IP stack and the WiFi radio


ESP-AT Firmware: Versions and Download

Espressif publishes ready-made ESP-AT binaries for each chip and module. For the ESP32-C3, the binary for the ESP32-C3-MINI-1 module works on most ESP32-C3 boards with 4MB of flash, including the WeAct ESP32-C3 Core Board and the ESP32-C3 SuperMini. Its AT port is UART1:

FunctionESP32-C3 PinConnects To
AT commands in (UART1 RX)GPIO6STM32 TX
AT replies out (UART1 TX)GPIO7STM32 RX
Flow control (optional)GPIO5 (CTS), GPIO4 (RTS)Not used in this tutorial
Firmware download and boot log (UART0)GPIO20 (RX), GPIO21 (TX), or the USB portYour PC

The pins come from Espressif’s ESP32-C3 AT hardware connection guide. Because the AT port is not the boot-log port, the STM32 never receives the garbage characters that an ESP8266 prints at power-up.

ESP-AT VersionReleasedHow to Get It
v4.1.1.0 (the one we use)July 2025Direct download from Espressif’s AT binary list (ESP32-C3-MINI-1-AT-V4.1.1.0.zip)
v4.2.0.0NewerEspressif asks you to fill in a request form first

Our WeAct ESP32-C3 Core Board answered AT+GMR with:

Note: An ESP32-C3 board is usually sold with a demo program, not with the AT firmware. If AT gets no answer on GPIO6/GPIO7 at 115200 baud, flash the firmware first (next section).


Flashing the ESP-AT Firmware on the ESP32-C3

Download the ESP32-C3-MINI-1 AT zip and unzip it. The factory folder has one image, factory_MINI-1.bin, that holds everything (bootloader, partition table, AT application, and default settings). Connect the ESP32-C3 board to your PC with its USB cable and write the image to address 0x0 with esptool:

Replace COM5 with your board’s port. If you have the Arduino ESP32 core installed, esptool is already on your PC (in the core’s tools/esptool_py folder), or install it with pip install esptool. If the board doesn’t connect, hold its BOOT button (GPIO9) while you press RESET, and try again. Espressif’s Flash Download Tool for Windows does the same with a GUI.


STM32 ESP32-C3 Wiring

Required Parts

QTY.Component NameAmazon.comAliExpress
1STM32 Blue Pill (STM32F103C8T6)AmazonAliExpress
1ST-Link V2 DebuggerAmazonAliExpress
1ESP32-C3 board (ESP32-C3 SuperMini; we use the WeAct ESP32-C3 Core Board)AmazonAliExpress
1USB-TTL (UART) Converter, 3.3VAmazonAliExpress
1BreadBoardAmazonAliExpress
1Jumper Wires PackAmazonAliExpress

STM32 Blue Pill to ESP32-C3 Wiring

Connect the STM32’s USART1 to the ESP32-C3’s AT port (UART1), and USART2’s TX pin to your USB-TTL converter for the log (see the Blue Pill pinout for the pin locations). TX goes to RX, RX goes to TX, and all the grounds are connected. The ESP32-C3 board is powered from its own USB port, so only the ground is shared:

PA9 USART1 TX, goes to the ESP32-C3 GPIO6 (AT RX): the AT commands.

PA10 USART1 RX, goes to the ESP32-C3 GPIO7 (AT TX): the replies, events, and received data.

PA2 USART2 TX, goes to the USB-TTL converter’s RX: the log to your PC at 115200 baud.

GND Goes to the ESP32-C3 GND and the USB-TTL GND: common ground.

STM32 ESP32-C3 wiring diagram: Blue Pill PA9 to ESP32-C3 GPIO6, PA10 to GPIO7, and PA2 to a USB-TTL converter

STM32 Blue Pill wired to a WeAct ESP32-C3 Core Board on a breadboard for the ESP-AT commands

STM32 Blue Pill ESP32-C3 / USB-TTL PA9 (USART1 TX) GPIO6 (AT RX) PA10 (USART1 RX) GPIO7 (AT TX) GND GND PA2 (USART2 TX) USB-TTL RX GND USB-TTL GND

The ST-Link stays on the Blue Pill’s SWD header (SWDIO, SWCLK, GND) as usual and isn’t shown in the diagram.

Note: Power the ESP32-C3 board from its own USB port (or 5V on its 5V pin), and power the Blue Pill from its micro-USB port, not from the ST-Link’s 3.3V pin. The ESP32-C3’s on-board regulator then supplies its WiFi transmit peaks, and the 3.3V supply sag that we measured with the ESP8266 doesn’t happen.


Testing ESP32 AT Commands With a USB-TTL Converter

Before connecting the ESP32-C3 to the STM32, it’s worth a quick test from your PC. Connect the ESP32-C3’s GPIO7 to the converter’s RX, GPIO6 to its TX, and GND to GND, open a serial terminal at 115200 baud with CR+LF line endings, and type AT. The module answers OK. Then try AT+GMR and AT+CWMODE?. If nothing comes back, the AT firmware isn’t on the board yet, or TX and RX are swapped.


STM32 CubeMX Configuration Steps

All four examples use the same CubeMX configuration as the ESP8266 tutorial: USART1 with DMA for the ESP32-C3, USART2 for the log, and the on-board LED on PC13.

#1

Open STM32CubeMX, create a new project, and select the STM32F103C8T6 in the MCU selector

#2

Set SYS > Debug to Serial Wire

STM32CubeMX SYS Debug set to Serial Wire: PA13 SWDIO and PA14 SWCLK on the Blue Pill

#3

Set RCC > High Speed Clock (HSE) to Crystal/Ceramic Resonator, and set HCLK to 72MHz in the Clock Configuration tab

STM32CubeMX RCC High Speed Clock (HSE) set to Crystal/Ceramic Resonator on PD0 and PD1

STM32CubeMX clock configuration for the Blue Pill: 8MHz HSE, PLL x9, HCLK 72MHz, APB1 /2

#4

Enable USART1 in Asynchronous mode (115200 baud, 8N1)

STM32CubeMX USART1 in Asynchronous mode at 115200 baud on PA9 (TX) and PA10 (RX) for the ESP32-C3 AT link

#5

In USART1’s DMA Settings tab, add USART1_RX with Mode set to Circular, and add USART1_TX (Mode Normal)

STM32CubeMX USART1 DMA Settings: USART1_RX in Circular mode and USART1_TX in Normal mode for the ESP_AT driver

#6

In USART1’s NVIC Settings tab, enable the USART1 global interrupt (the two DMA channel interrupts are enabled by CubeMX)

STM32CubeMX USART1 NVIC Settings: USART1 global interrupt and the DMA1 channel 4 and 5 interrupts enabled

#7

Enable USART2 in Asynchronous mode (115200 baud, 8N1) for the log

STM32CubeMX USART2 in Asynchronous mode on PA2 (TX) and PA3 (RX) for the debug log

#8

Set PC13 as GPIO_Output with the user label LED (the Blue Pill’s on-board LED)

STM32CubeMX GPIO configuration of PC13 as Output Push Pull with the user label LED

Here’s the finished pin configuration:

STM32CubeMX pinout for the STM32 ESP32-C3 examples: USART1 on PA9/PA10, USART2 on PA2/PA3, and PC13 as the LED output on the Blue Pill

#9

In Project Manager, name the project, set the Toolchain/IDE to STM32CubeIDE, and click Generate Code

STM32CubeMX Project Manager with the project name and Toolchain/IDE set to STM32CubeIDE


STM32 ESP-AT Commands Driver (ESP_AT)

All the examples use our ESP_AT driver from the ESP8266 tutorial: plain C, HAL called directly, two files ( ESP_AT.c and ESP_AT.h), no dynamic memory, about 9.1KB of flash and 3.9KB of RAM. The STM32 receives every byte from the ESP32-C3 with DMA in circular mode, and a line parser turns the stream into replies, events, and received data, so nothing is lost while the main loop is busy:

How the STM32 ESP_AT driver receives ESP32-C3 replies: UART DMA in circular mode fills a ring buffer, and the parser turns it into replies, events, and +IPD data

The driver reads AT+GMR and picks the right command form for each firmware. On ESP-AT, it uses AT+CWJAP and AT+CIPSTA? (the ESP8266 NonOS firmware uses AT+CWJAP_CUR and AT+CIPSTA_CUR?), and it parses +PING:<ms> replies. Your application code doesn’t change between the two modules.

Testing on the ESP32-C3 also showed why the driver’s ESP_AT_Begin() syncs with the module first. When the STM32 resets, the ESP32-C3 keeps running: an unfinished AT+CIPSEND left late replies in the line, and a TCP link left open made AT+CIPMUX answer ERROR. So Begin now waits for a clean AT / OK exchange, closes any open link, and only then sets the connection mode.

FunctionWhat It Does
ESP_AT_Init(&esp, &cfg)Checks the UART and DMA setup and starts the reception
ESP_AT_Process(&esp)Runs the parser, the jobs, and the timers. Call it in the main loop as often as possible
ESP_AT_Begin(&esp)Auto-baud, sync, ATE0, AT+GMR (firmware detection), closes old links, optional baud switch
ESP_AT_Command(&esp, cmd, timeout)Sends any AT command and collects its reply
ESP_AT_WiFiJoin(&esp, ssid, pwd)Station mode, joins the network, and reads the IP address
ESP_AT_Connect(&esp, link, type, host, port)Opens a TCP, UDP, or SSL connection
ESP_AT_Send(&esp, link, data, len)Sends data with AT+CIPSEND
ESP_AT_Ping(&esp, host)Pings a host, the round trip goes to esp.pingMs
ESP_AT_..._Blocking()The same jobs, waiting until they finish (for simple programs)

STM32 ESP32-C3 WiFi Example 1: AT Commands

In the first example project, the STM32 finds the ESP32-C3, reads its firmware version, and sends ten common AT commands, printing each reply and how long it took.

Wiring: PA9 to ESP32-C3 GPIO6, PA10 to GPIO7, PA2 to the USB-TTL RX, and GND to both.

Here is The Application Code For This Example Project (main.c). Only the USER CODE sections are shown; the rest of the file is generated by CubeMX:

STM32 ESP32-C3 Example 1 Code Explanation

OnTrace() prints every line the driver sends ( >>) and receives ( <<) on USART2, so you see the whole AT exchange. ESP_AT_Begin_Blocking() finds the module’s baud rate, syncs with it, turns the echo off, and reads AT+GMR. Then the loop sends each command in demoCommands[] with ESP_AT_Command_Blocking() and prints the result and its time.

STM32 ESP32-C3 Example 1 Testing

This is the real hardware testing result for this example project on my Blue Pill and ESP32-C3 (network names and access point MAC addresses are hidden):

Most commands answered in 3 to 27ms. The WiFi scan ( AT+CWLAP) took 2.1 seconds and found 18 networks, and AT+SYSRAM? shows about 134KB of free RAM inside the ESP32-C3, more than twice the ESP8266’s 51KB.


STM32 ESP32-C3 Example 2: Connect to WiFi and Get IP Address

In this example project, the STM32 joins your WiFi network, prints the IP address, gateway, and netmask, and then runs a non-blocking loop that keeps the connection alive:

  • The on-board LED is on while the ESP32-C3 is connected, and blinks fast while it isn’t.
  • When the module reports WIFI DISCONNECT, the driver joins the network again by itself.
  • To show this without touching the router, the example drops the WiFi once with AT+CWQAP 30 seconds after the start.

Write your WiFi name and password in Core/Inc/wifi_secrets.h:

Here is The Application Code For This Example Project (main.c). Only the USER CODE sections are shown; the rest of the file is generated by CubeMX:

STM32 ESP32-C3 Example 2 Code Explanation

Setting cfg.autoReconnect = 1 keeps the connection: the driver remembers the network and joins it again after every WIFI DISCONNECT. OnEvent() receives the WiFi events and the end of each job, and the main loop only calls ESP_AT_Process() and updates the LED.

Note: On ESP-AT, AT+CWJAP also saves the network in the ESP32-C3’s flash ( AT+SYSSTORE is 1 by default), and the module joins it again by itself after a reset. Use AT+SYSSTORE=0 first if you don’t want it saved.

STM32 ESP32-C3 Example 2 Testing

This is the real hardware testing result for this example project:

The ESP32-C3 joined the network in 1.2 seconds, with WIFI GOT IP (the router’s DHCP answer) 1.0 second after WIFI CONNECTED. After the simulated drop at 30 seconds, it was back with an IP address 3.1 seconds later. The ESP8266 needed 5 to 6 seconds for the same join on the same router.


STM32 ESP32-C3 WiFi Example 3: TCP Client (Send and Receive Data)

In this example project, the STM32 connects to a TCP server on your PC through the ESP32-C3 and exchanges data with it in both directions:

  • The STM32 sends a text line every 2 seconds.
  • The PC server sends each line back ( echo: ...), and the STM32 measures how long the echo takes.
  • Every 6 seconds, the server sends LED TOGGLE, and the STM32 toggles its on-board LED.
  • If the server stops, the STM32 tries to reconnect every 3 seconds.

Data goes out with AT+CIPSEND=<length>: the STM32 waits for the > prompt, sends exactly that many bytes, and the module answers Recv <n> bytes and SEND OK. Data comes in at any time as +IPD,<length>: followed by the data, and the driver reads it by its length. The ESP8266 tutorial shows this exchange step by step.

The PC TCP Server

Run this Python script on your PC (Python 3, no extra packages), and set SERVER_IP in wifi_secrets.h to your PC’s IP address. Allow Python through the Windows firewall when it asks.

Here is The Application Code For This Example Project (main.c). Only the USER CODE sections are shown; the rest of the file is generated by CubeMX:

STM32 ESP32-C3 Example 3 Code Explanation

The application is a non-blocking state machine: begin, join, and then online, where it opens link 0 with ESP_AT_Connect() and sends a line every 2 seconds with ESP_AT_Send(). Received data comes as ESP_AT_EVT_DATA events in chunks of up to 256 bytes, which the example collects into lines and checks for the LED commands.

STM32 ESP32-C3 Example 3 Testing

This is the real hardware testing result for this example project (the first lines):

All 18 lines came back, with an echo round trip of 39 to 49ms, and all 5 LED TOGGLE commands toggled the LED.


STM32 ESP32-C3 Example 4: Network Time (SNTP) and Ping

ESP-AT has an SNTP client built in, so the STM32 can get the date and time from the internet with two commands, with no RTC setup and no NTP code. In this example project, the STM32 joins WiFi, sets the time zone and the NTP server, pings the router and www.google.com, and prints the local time every 10 seconds.

Here is The Application Code For This Example Project (main.c). Only the USER CODE sections are shown; the rest of the file is generated by CubeMX:

STM32 ESP32-C3 Example 4 Code Explanation

AT+CIPSNTPCFG=1,2,"pool.ntp.org" turns SNTP on with a time zone of UTC+2 (set TIME_ZONE to yours) and the pool.ntp.org servers. The module prints +TIME_UPDATED by itself when it has the time, and AT+CIPSNTPTIME? then returns the local date and time as text. ESP_AT_Ping() sends AT+PING and the driver reads the round trip from the +PING: reply.

STM32 ESP32-C3 Example 4 Testing

This is the real hardware testing result for this example project:

The router answered in 3ms and www.google.com in 45ms. Note that AT+PING itself took about 1 second to return each time, even though the reported round trip was a few milliseconds. ESP-AT waits out a fixed window before it answers, so don’t use AT+PING to time anything.


Measured: ESP32-C3 vs ESP8266 With STM32

We ran the same driver and the same tests on the ESP32-C3 (ESP-AT v4.1.1.0) and on the ESP8266 from the previous tutorial (NonOS AT v1.7.6), both driven by the same Blue Pill and joining the same router:

TestESP32-C3 (ESP-AT v4.1.1.0)ESP8266 (NonOS AT v1.7.6)
WiFi join time1.2 to 1.9s5.0 to 6.1s
IP back after a WiFi drop3.1s5.8s
TCP echo round trip (STM32 to PC and back)39 to 49ms32 to 89ms
TCP upload at 115200 baudabout 10KB/s7.2KB/s
TCP upload at 921600 baud35 to 37KB/s31.8KB/s
TCP upload at 2,000,000 baud56.2KB/sNot tested
Reply delay after a short command (scope)1.95ms0.38ms
AT+RST to ready1.2s0.26s
Free RAM inside the moduleabout 134KBabout 51KB
Boot log on the AT portNo (separate UART0)Yes, at 74880 baud
Built-in HTTP client, MQTT, SNTP event, BLEYesSNTP only

The ESP32-C3 joins the network 3 to 4 times faster and moves data faster at every baud rate. At 2,000,000 baud, the 64KB upload ran at 56.2KB/s, and all 71,719 bytes echoed back by the PC arrived with no byte lost. The ESP8266 answers short commands faster (0.38ms vs 1.95ms), and it restarts faster, but for a WiFi application the join time and the throughput matter much more.

ESP32 AT Commands on The Oscilloscope

Here’s what an AT command and its reply look like on my oscilloscope captures. CH1 (yellow) is PA9, the STM32’s TX line to the ESP32-C3’s GPIO6, and CH3 (blue) is PA10, the ESP32-C3’s GPIO7 back to the STM32.

The first command of Example 2 is AT plus CR LF: 4 bytes in 0.34ms at 115200 baud. The cursors show that the ESP32-C3’s OK starts 2.29ms after the command starts, so the module answered 1.95ms after it received the last byte. That’s 5 times slower than the ESP8266, but still far below any timeout:

Oscilloscope capture of the STM32 sending AT to the ESP32-C3 on PA9 and the OK reply on PA10, 2.29ms later at 115200 baud
Oscilloscope capture of the STM32 sending AT to the ESP32-C3 on PA9 and the OK reply on PA10, 2.29ms later at 115200 baud

The WiFi join: the cursors run from the AT+CWJAP command (X1) to the module’s WIFI GOT IP line (X2), 1.93 seconds in this run. WIFI CONNECTED came 0.42 seconds after the start. Unlike the ESP8266 capture, there are no supply dips on the lines, because the ESP32-C3 board has its own regulator fed from USB:

Oscilloscope capture of the ESP32-C3 WiFi join: AT+CWJAP sent by the STM32, then WIFI CONNECTED at 0.42s and WIFI GOT IP at 2.13s on the ESP32-C3 TX line
Oscilloscope capture of the ESP32-C3 WiFi join: AT+CWJAP sent by the STM32, then WIFI CONNECTED at 0.42s and WIFI GOT IP at 2.13s on the ESP32-C3 TX line


ESP32 AT Commands List (With Real Replies)

These are the ESP32 AT commands (ESP-AT) you’ll use most with an STM32, grouped by function, with the real replies from our ESP32-C3 running ESP-AT v4.1.1.0. Every command ends with \r\n. The full reference is Espressif’s ESP-AT command set.

Note: The NonOS-only _CUR and _DEF forms of the ESP8266 ( AT+CWJAP_CUR, AT+CIPSTA_CUR?…) return ERROR on ESP-AT. Use the plain forms, and AT+SYSSTORE to choose whether settings are saved.

ESP32 AT Commands List: Basic, WiFi, and TCP/IP (click to expand)

Basic and System AT Commands

CommandWhat It DoesReply From Our ESP32-C3Time (ms)
ATTests that the module is aliveOK4
ATE0 / ATE1Turns the command echo off / onOK3
AT+GMRAT, SDK, and bin versionsAT version:4.1.1.0(ba4dd0e - ESP32C3 - Jul 31 2025 08:38:07)
SDK version:v5.4.1-643-g8ad0d3d8f2-dirty
compile time(7c092f9a):Aug 1 2025 05:35:19
Bin version:v4.1.1.0(MINI-1)
OK
26
AT+RSTRestarts the moduleOK, then the boot log on UART0, then ready1225 to ready
AT+UART_CUR?Current UART settings: baud, data bits, stop bits, parity, flow control+UART_CUR:115211,8,1,0,110
AT+UART_DEF?UART settings saved in flash+UART_DEF:115200,8,1,0,111
AT+SYSSTORE?Whether settings are saved in flash (1 = yes)+SYSSTORE:17
AT+SYSRAM?Free RAM and the minimum ever free, in bytes+SYSRAM:134144,1281408
AT+SYSFLASH?The user flash partitions+SYSFLASH:"mfg_nvs",1,2,0x1f000,0x1f000
+SYSFLASH:"fatfs",1,129,0x47000,0x19000
16
AT+SLEEP?Sleep mode (0 off, 1 modem sleep DTIM, 2 light, 3 modem sleep interval)+SLEEP:17
AT+RFPOWER=82Maximum TX powerOK7
AT+BLEINIT?Bluetooth LE role (0 = off)+BLEINIT:07

WiFi AT Commands

CommandWhat It DoesReply From Our ESP32-C3Time (ms)
AT+CWMODE?WiFi mode: 1 station, 2 SoftAP, 3 both+CWMODE:17
AT+CWJAP="ssid","pwd"Joins a network (saved in flash when AT+SYSSTORE=1)WIFI CONNECTED
WIFI GOT IP
OK
1182
AT+CWJAP?The current network: SSID, BSSID, channel, RSSI, and more+CWJAP:"MyWiFi","xx:xx:xx:xx:xx:xx",9,-66,0,1,3,0,116
AT+CWSTATE?WiFi state (2 = connected with an IPv4 address) and SSID+CWSTATE:2,"MyWiFi"10
AT+CWLAPScans for WiFi networks+CWLAP:(3,"MyWiFi",-55,"xx:xx:xx:xx:xx:xx",9,-1,-1,4,4,7,1)
... one line per network
OK
2117
AT+CWQAPDisconnects from the networkWIFI DISCONNECT
OK
17
AT+CWAUTOCONN?Joins the saved network after power-up (1 = on)+CWAUTOCONN:17
AT+CWDHCP?DHCP state (bit 0 station, bit 1 SoftAP)+CWDHCP:36
AT+CWHOSTNAME?The module’s host name on your network+CWHOSTNAME:espressif9
AT+CIPSTAMAC?Station MAC address+CIPSTAMAC:"60:55:f9:af:ae:90"10
AT+CIPSTA?IP address, gateway, and netmask+CIPSTA:ip:"192.168.1.201"
+CIPSTA:gateway:"192.168.1.1"
+CIPSTA:netmask:"255.255.255.0"
16
AT+CIFSRIP and MAC address+CIFSR:STAIP,"192.168.1.201"
+CIFSR:STAMAC,"60:55:f9:af:ae:90"
13

TCP/IP AT Commands

CommandWhat It DoesReply From Our ESP32-C3Time (ms)
AT+CIPSTATUSConnection status (2 = got IP)STATUS:26
AT+CIPMUX?Single (0) or multiple (1) connections+CIPMUX:06
AT+CIPMODE?0 normal mode, 1 transparent (passthrough) mode+CIPMODE:06
AT+CIPRECVTYPE?Receive mode per link (0 = active, data pushed as +IPD)+CIPRECVTYPE:0,09
AT+CIPSTO?TCP server timeout, in seconds+CIPSTO:06
AT+CIPDOMAIN="www.google.com"DNS lookup+CIPDOMAIN:"142.251.156.119"264
AT+PING="192.168.1.1"Pings a host, the reply is the time in ms+PING:41010
AT+CIPSNTPCFG=1,0,"pool.ntp.org"Enables SNTP time (time zone 0 = UTC)OK, then +TIME_UPDATED13
AT+CIPSNTPTIME?Date and time from the SNTP server+CIPSNTPTIME:Thu Nov 26 07:56:45 202613
AT+CIPSTART="TCP","192.168.1.101",5000Opens a TCP connection (“UDP” and “SSL” also work)CONNECT
OK
29
AT+CIPSEND=5Sends 5 bytes: wait for the > prompt, then send the dataOK
>
Recv 5 bytes
SEND OK
19 to SEND OK
(received data)Data from the server, sent by the module at any time+IPD,28:Hello STM32, this is the PC–
AT+CIPCLOSECloses the connectionCLOSED
OK
15
AT+HTTPCLIENT=2,0,"http://httpbin.org/get",,,1HTTP GET (built-in HTTP client)+HTTPCLIENT:246,{ "args": {}, ... }
OK
551

STM32 ESP32-C3 Troubleshooting

The ESP32-C3 doesn’t answer AT commands

Check that the AT firmware is flashed (a new board usually runs a demo program), that you are on the AT port (GPIO6 and GPIO7, not the USB port or GPIO20/GPIO21), that TX and RX are crossed, and that the grounds are connected. Test the module alone with a USB-TTL converter as shown above.

Replies look shifted by one, or AT+CIPMUX returns ERROR after an STM32 reset

The ESP32-C3 kept running while the STM32 restarted, so an old reply or an open TCP link is still pending. Send AT until you get a clean OK, then AT+CIPCLOSE before AT+CIPMUX. Our driver’s Begin does this.

AT+CWJAP_CUR or AT+CIPSTA_CUR? returns ERROR

Those are ESP8266 NonOS commands. On ESP-AT, use AT+CWJAP and AT+CIPSTA?.

AT+CWJAP returns FAIL or ERROR

The reply +CWJAP:<code> tells you why: 1 = timeout, 2 = wrong password, 3 = network not found, 4 = connection failed. The ESP32-C3 is 2.4GHz only. Commas, double quotes, and backslashes in the SSID or password must be escaped with a backslash (our driver does it).

The module joins WiFi by itself after a reset

ESP-AT saves the network when you join ( AT+SYSSTORE=1 by default) and reconnects after power-up. Send AT+CWAUTOCONN=0 or AT+SYSSTORE=0 if you don’t want that.

The reply is busy p…

It’s short for (busy processing…): the module is still working on the previous command. Wait for its OK or ERROR before sending the next command. Our driver resends the command after 200ms.


STM32 ESP32-C3 FAQ

Which ESP32 boards can run the ESP-AT firmware?

Boards with an ESP32, ESP32-C2, ESP32-C3, ESP32-C5, ESP32-C6, ESP32-C61, or ESP32-S2. For the ESP32-C3, the ESP32-C3-MINI-1 binary works on most boards with 4MB of flash, like the WeAct ESP32-C3 Core Board and the ESP32-C3 SuperMini. The ESP32-S3 isn’t on Espressif’s ESP-AT list.

Can I use an ESP32 DevKit instead of an ESP32-C3?

Yes. Flash the ESP32 (WROOM-32) AT binary; its AT port is UART1 on GPIO16 (RX) and GPIO17 (TX). The STM32 code doesn’t change.

Do I need a level shifter between the STM32 and the ESP32-C3?

No. Both run at 3.3V, so their UART pins connect directly.

How fast can the UART between the STM32 and the ESP32-C3 run?

We ran it at 2,000,000 baud with AT+UART_CUR and got 56.2KB/s of TCP upload with no byte lost. Start at 115200 and switch up once the link works.

Can the ESP32-C3 do HTTPS and MQTT for the STM32?

Yes. ESP-AT has SSL connections, an HTTP client ( AT+HTTPCLIENT), and an MQTT client built in, so TLS runs on the ESP32-C3 and not on the STM32. We use the HTTP client in the STM32 HTTP client over WiFi tutorial, and MQTT in a later part of this series.

ESP32-C3 or ESP8266 for a new STM32 design?

The ESP32-C3: it costs about the same, joins WiFi 3 to 4 times faster in our tests, has a separate AT port with no boot garbage, and gets the current ESP-AT releases.


STM32 WiFi Tutorial Series

This tutorial is the third part of our STM32 WiFi tutorial series. Each part builds complete, tested projects with an STM32 Blue Pill and an ESP WiFi module, using our ESP_AT driver:

PartTutorialWhat You’ll Build
1STM32 WiFiChoosing a WiFi module, quick start, ESP32-C3 vs ESP8266 measured
2ESP8266 AT Commands With STM32ESP8266 AT firmware, commands, and our ESP_AT driver
3ESP32 AT Commands (ESP-AT) With STM32 (this tutorial)ESP-AT firmware, commands, SNTP time, and our ESP_AT driver
4STM32 HTTP Client Over WiFiGET, POST, HTTPS, and JSON parsing
5STM32 Web ServerControl GPIOs and read sensors from a browser
6STM32 MQTTPublish and subscribe, Home Assistant
7STM32 OTA Firmware UpdateUpdate the STM32’s firmware over WiFi
8STM32 WebSocketReal-time data with an ESP32 smart bridge

Download STM32 ESP32-C3 (ESP-AT) Example Projects + ESP_AT Driver

Download all attachment files for this Article/Tutorial (project files, schematics, code, etc.) using the link below. Everything is tested and verified to work on real hardware, as you’ve seen in the demo videos & screenshots. Please consider supporting my work if it helped you.

Wrap Up

To conclude this tutorial, we’ve used the ESP32 AT commands (ESP-AT) with an STM32 Blue Pill and an ESP32-C3 to connect the STM32 to WiFi. We flashed the ESP-AT firmware, configured the STM32 UART with circular DMA, and built four example projects with our ESP_AT driver: AT commands, joining WiFi with automatic reconnection, a TCP client, and network time with ping. The measurements showed that the ESP32-C3 joins WiFi 3 to 4 times faster than the ESP8266 and reaches 56.2KB/s at 2,000,000 baud.

In the next part of this series, we’ll use the ESP32-C3’s built-in HTTP client to send GET and POST requests and parse JSON from the STM32. If you’re new to the STM32 UART, the STM32 UART tutorial and the STM32 UART IDLE line detection tutorial are a good place to start.

Share This Page With Your Network!
Join Our +25,000 Newsletter Subscribers!

Stay Updated With All New Content Releases. You Also Get Occasional FREE Coupon Codes For Courses & Other Stuff!

Photo of author
Author
Embedded systems engineer with several years of experience in embedded software and hardware design. I work as an embedded SW engineer in the Automotive & e-Mobility industry. However, I still do Hardware design and SW development for DSP, Control Systems, Robotics, AI/ML, and other fields I'm passionate about.
I love reading, writing, creating projects, and teaching. A reader by day and a writer by night, it's my lifestyle. I believe that the combination of brilliant minds, bold ideas, and a complete disregard for what is possible, can and will change the world! I will be there when it happens, will you?

Leave a Comment