ESP32 AT command를 이용한 간단한 Socket 통신 시험

개발팁|2026. 1. 30. 14:55

  준비물

1) ESP32 모듈 

 

2) AT command 펌웨어

https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Binary_Lists/index.html

 

3) PC용 TCP서버 프로그램 (시험용)

ttps://www.sollae.co.kr/ko/download/ezterm

 

4) PC용 시리얼 터미널 프로그램 (일반적인 프로그램도 사용가능)

https://esp8266.ru/esplorer/

https://aithinker-static.oss-cn-shenzhen.aliyuncs.com/docs/_media_old/aithinker_serial_tool_v1.2.3.7z

 

  순서

1) ESP32-AT: Wi-Fi Station 모드로 AP 접속 

2) PC: 같은 AP에 접속 후 IP에  8080 TCP 서버 실행 (PC의 IP번호는 CMD -> ipconfig /all로 확인)

3) ESP32-AT: AT+CIPSTART로 PC 서버에 TCP 연결

4) AT+CIPSEND로 DATA 전송

 

  시험 방법

 

1. ESP32는 WiFi STATION - TCP Client로 동작.
1) AT+CWMODE=1
2) AT+CWJAP="TEST1234","1234123411"
3) AT+CIPSTA?

2. PC에서 TCP 서버 실행
1) ESP32와 동일 AP접속
2) IP 확인 (도스창) (예, PC IP주소 192.168.3.102) : cmd - ipconfig /all
3) TCP 서버 프로그램 실행 (8080포트로 서버 실행)

3. ESP32 TCP 연결
1) PC TCP 서버로 접속 (ESP32-AT → PC)
2) AT+CIPSTART="TCP","192.168.3.102",8080
(* PC IP주소가 192.168.3.102이고, 서버 포트가 8080일 경우)

4. 데이터 전송 보낼 바이트 수 지정 (예: 4바이트 test)
AT+CIPSEND=4
OK >
프롬프트 >가 나오면 실제 데이터 입력:
PC의 TCP 서버 프로그램에서 test 문자열이 수신되는지 확인합니다.


실제 사용된 AT 명령어 

AT+CWMODE=1

AT+CWJAP="SSID","Password"

AT+CIPSTA?

AT+CIPSTART="TCP","서버IP주소",서버포트번호

AT+CIPSEND

 

각 AT 명령어 메뉴얼

https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Set/#

 

AT Command Set - ESP32 - — ESP-AT User Guide latest documentation

+ERRNO: Error code when command execution fails. When TCP connection, UDP transmission, or SSL server fails, the error code is returned in priority order: first, the socket’s SO_ERROR; if SO_ERROR is 0, then LwIP’s errno; if errno is 0, then the error

docs.espressif.com

 


 

'개발팁' 카테고리의 다른 글

ESP32-C3/C6/H2 MINI 모듈 기본 하드웨어 설계  (0) 2026.01.28