ESP32 with SIM900A GSM Module
📡 What is SIM900?
The SIM900 is a GSM/GPRS module from SIMCom. It allows microcontrollers like ESP32 or Arduino to:
✅ Send/receive SMS
✅ Make/receive phone calls
✅ Connect to the Internet (GPRS)
✅ Send data to servers via HTTP, MQTT, TCP/IP
It communicates via UART (TX/RX) and uses AT commands.
📦 Features of SIM900
| Feature | Description |
|---|---|
| Network | 2G GSM (850/900/1800/1900 MHz) |
| Communication | UART (AT commands) |
| Baud Rate | Default 9600 |
| SIM Card | Standard-size SIM (2G supported) |
| Power Supply | 5V–12V, 2A recommended |
| Antenna | Required for GSM signal |
| Optional | Mic & Speaker (for calls) |
🔌 SIM900 to ESP32 Connection
| SIM900 Pin | ESP32 Pin |
|---|---|
| TX | GPIO 16 (ESP32 RX) |
| RX | GPIO 17 (ESP32 TX) |
| GND | GND |
| VCC | ⚠️ External 5V 2A power supply |
⚠️ DO NOT power SIM900 directly from ESP32 or USB. It needs high current, especially during network operations.
🧾 Arduino Code Example – Sending SMS with ESP32 + SIM900
🧰 Libraries Required:
You don’t need extra libraries – just Serial and AT commands.
⚙️ Wiring
- SIM900 TX → ESP32 RX (GPIO 16)
- SIM900 RX → ESP32 TX (GPIO 17)
- SIM900 GND ↔ ESP32 GND
- SIM900 VCC → External 5V 2A📱 Other Useful AT Commands:CommandFunction
ATCheck moduleAT+CSQSignal strengthAT+CCIDSIM card numberAT+CREG?Network registrationATD+91XXXXXXXXXX;Make a callATHHang upAT+CMGR=1Read SMS from slot 1AT+CMGD=1Delete SMS from slot 1⚙️ Using Serial Monitor to TestYou can manually send AT commands via Serial Monitor using this setup:- Use Serial passthrough sketch to forward
SerialtoSIM900.
- SIM900 can draw up to 2A peak. If underpowered, it may restart or fail to send SMS.
- Use external power supply (e.g., 5V 2A adapter or battery pack).
- Keep GND common between ESP32 and SIM900.
- Use Serial passthrough sketch to forward
HOW TO OPERATE
// Define ESP32 hardware serial port for SIM900
#define SIM900_TX 17 // ESP32 TX connected to SIM900 RX
#define SIM900_RX 16 // ESP32 RX connected to SIM900 TX
#define PWRKEY 4 // SIM900 Power Key pin (adjust if needed)
#define GSM_BAUD 9600
// Initialize hardware serial for SIM900
HardwareSerial sim900(2);
void powerOnSIM900() {
pinMode(PWRKEY, OUTPUT);
digitalWrite(PWRKEY, LOW);
delay(1000); // Hold PWRKEY low for 1 second
digitalWrite(PWRKEY, HIGH);
delay(9000); // Wait for the module to initialize
}
void setup() {
Serial.begin(115200); // Serial Monitor
sim900.begin(GSM_BAUD, SERIAL_8N1, SIM900_RX, SIM900_TX); // SIM900 UART
powerOnSIM900();
Serial.println("Testing AT communication...");
// Test AT command
sendATCommand("AT");
// Set SMS text mode
sendATCommand("AT+CMGF=1");
// Send SMS
Serial.println("Sending SMS...");
sim900.println("AT+CMGS=\"+919305706040\""); // Replace with recipient's number
delay(1000);
sim900.print("Hello from ESP32 and SIM900");
sim900.write(26); // CTRL+Z to send
delay(5000);
printResponse();
}
void loop() {
// Add code to handle incoming messages or other functionalities
}
// Function to send an AT command and print response
void sendATCommand(const char *command) {
Serial.print("Sending: ");
Serial.println(command);
sim900.println(command);
delay(1000);
printResponse();
}
// Function to print response from SIM900
void printResponse() {
while (sim900.available()) {
Serial.write(sim900.read());
}
Serial.println("----------------------");
}

Leave a Reply
You must be logged in to post a comment.