# Hướng dẫn sử dụng module 4G với ESP32 – MQTT
Trong bài viết này mình sẽ hướng dẫn các bạn kết nối ESP với module 4G sử dụng giao thức **[PPPoS](https://linhkienthuduc.com/giao-thuc-ppp-point-to-point-protocol-su-dung-ket-noi-module-sim-4g-gsm-la-gi)**
Với việc sử dụng giao thức PPPoS, module SIM sẽ hoạt động như là 1 driver network giống như Wi-Fi, Ethernet.
**1. Kết nối**
**ESP32**
**Module SIM**
5V
Vin
GND
GND
GPIO 17 (MCU-TX)
RX
GPIO 16 (MCU-RX)
TX
GPIO 15 (MCU-RX)
PEN (Power Enable)
**2. Code mẫu**
**ESP32 ESP-IDF:**
- Sử dụng thư viện ESP-IDF
- Đã test trên các dòng SIM A7670C, A7600C1, SIM7600CE, Quectel EC600S-CN
- Hỗ trợ kết nối MQTT(S)
- Hỗ trợ lưu configuration vào bộ nhớ
- [https://github.com/TDLOGY/esp32\_pppos](https://github.com/TDLOGY/esp32_pppos)
**ESP32 Arduino:**
- Sử dụng thư viện arduino
- Đã test trên các dòng SIM A7670C, A7600C1, SIM7600CE, Quectel EC600S-CN
- Hỗ trợ kết nối MQTT(S)
- Hỗ trợ kết nối SSL
- [https://github.com/TDLOGY/esp32\_pppos\_arrduino](https://github.com/TDLOGY/esp32_pppos_arrduino)
**3. Test**
Mình sử dụng ESP-IDF để test kết nối tới mqtt server test.mosquitto.org:1883
**Hướng dẫn sử dụng:**
**[Phần mềm AT Command Test](https://linhkienthuduc.com/at-command-test-cho-cac-dong-module-sim)**