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Β
SerialΒ toΒSIM900.
- 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.