This project demonstrates how to send SMS messages using an ESP32 microcontroller and a SIM7670 GSM module. The Arduino sketch initializes the GSM module, configures it for SMS in text mode, and sends a predefined SMS message to a specified phone number.
- ESP32 Development Board
- SIM7670 GSM Module
Below is the wiring diagram for connecting the ESP32 to the SIM7670 module:
| ESP32 Pin | SIM7670 Pin | Description |
|---|---|---|
| 3V3 | VCC | Power Supply |
| GND | GND | Ground |
| GPIO 16 | TXD | ESP32 RX (GSM TX) |
| GPIO 17 | RXD | ESP32 TX (GSM RX) |
Note: Double-check your module's pinout, as labeling can vary by board version.
- Arduino IDE installed
- ESP32 board package added to Arduino IDE
- SIM card with SMS capability (inserted into the SIM7670)
- Required libraries: none extra (uses built-in
HardwareSerial)
Upload the provided GSM_ESP32.ino sketch to your ESP32.
#include <HardwareSerial.h>
#define MODEM_RX 16 // ESP32 RX pin (connect to SIM7670 TX)
#define MODEM_TX 17 // ESP32 TX pin (connect to SIM7670 RX)
HardwareSerial GSM(2);
const char* PHONE_NUMBER = "+1234567890"; // <-- PUT RECIPIENT'S PHONE NUMBER HERE
void sendCommand(const char* cmd, unsigned long waitMs = 500, bool showOutput = true) {
GSM.println(cmd);
delay(waitMs);
if (showOutput) {
while (GSM.available()) {
Serial.write(GSM.read());
}
}
}
void setup() {
Serial.begin(115200);
GSM.begin(115200, SERIAL_8N1, MODEM_RX, MODEM_TX);
sendCommand("AT");
sendCommand("ATE0");
sendCommand("AT+CMGF=1");
sendCommand("AT+CPIN?");
sendCommand("AT+CSQ");
sendCommand("AT+CREG?");
GSM.print("AT+CMGS=\"");
GSM.print(PHONE_NUMBER);
GSM.println("\"");
delay(1000);
GSM.print("hi, how are you ?");
GSM.write(26);
delay(5000);
while (GSM.available()) {
Serial.write(GSM.read());
}
}
void loop() { }- Wire the ESP32 and SIM7670 as shown in the diagram above.
- Insert a SIM card with SMS capability into the SIM7670.
- Open the Arduino IDE, load
GSM_ESP32.ino, and updatePHONE_NUMBERwith your recipient's phone number (including country code). - Upload the sketch to your ESP32.
- Open the Serial Monitor (115200 baud) to view debug output.
- The ESP32 will initialize the SIM7670 and send an SMS to the specified number.
- Ensure SIM card is active and unlocked (no PIN required or set PIN in code).
- Check wiring, especially TX/RX crossover.
- Use external power for SIM7670 if you observe instability.
This project is open source and free to use for educational and hobbyist purposes.
Author: [Your Name]
Repository: aeoank/Resources