The core idea is to use the Arduino as a controller that sends AT commands (Attention commands) to the SIM900 module. These commands instruct the GSM module to perform actions like connecting to the cellular network, sending an SMS, or reading a received SMS. The communication between the Arduino and the SIM900 module happens via Serial (UART).
Components RequiredAccording to the article, you will need:
Arduino Uno (or any other Arduino board)
- Arduino Uno (or any other Arduino board)
SIM900A GSM Module (must support the frequencies used in your country)
- SIM900A GSM Module (must support the frequencies used in your country)
SIM Card (A working, activated SIM card from a local carrier)
- SIM Card (A working, activated SIM card from a local carrier)
12V, 2A DC Power Adapter (Crucial! The SIM900 requires more current than the Arduino 5V pin can provide)
- 12V, 2A DC Power Adapter (Crucial! The SIM900 requires more current than the Arduino 5V pin can provide)
Breadboard
- Breadboard
Jumper Wires
- Jumper Wires
- Circuit Diagram & Connection
The connections are straightforward but require careful attention to power.
SIM900 Module ←→ Arduino:
SIM900 RX → Arduino TX (Digital Pin 1)
- SIM900 RX → Arduino TX (Digital Pin 1)
SIM900 TX → Arduino RX (Digital Pin 0)
- SIM900 TX → Arduino RX (Digital Pin 0)
- SIM900 Module ←→ Arduino:SIM900 RX → Arduino TX (Digital Pin 1)SIM900 TX → Arduino RX (Digital Pin 0)
Power Connections (Very Important!):
SIM900 VCC → External 12V, 2A Adapter's Positive (+)
- SIM900 VCC → External 12V, 2A Adapter's Positive (+)
SIM900 GND → External 12V, 2A Adapter's Negative (-)
- SIM900 GND → External 12V, 2A Adapter's Negative (-)
Also connect SIM900 GND → Arduino GND (This creates a common ground)
- Also connect SIM900 GND → Arduino GND (This creates a common ground)
- Power Connections (Very Important!):SIM900 VCC → External 12V, 2A Adapter's Positive (+)SIM900 GND → External 12V, 2A Adapter's Negative (-)Also connect SIM900 GND → Arduino GND (This creates a common ground)
⚠️ Critical Warning from the Article:
DO NOT power the SIM900 from the Arduino's 5V pin. The module requires up to 2A of current during transmission, which can damage the Arduino.
- DO NOT power the SIM900 from the Arduino's 5V pin. The module requires up to 2A of current during transmission, which can damage the Arduino.
Use the external 12V, 2A power adapter for the SIM900 alone.
- Use the external 12V, 2A power adapter for the SIM900 alone.
The code works by establishing a serial communication link with the SIM900 module and sending a series of AT commands.
SoftwareSerial Library: The code often uses the SoftwareSerial library to communicate with the GSM module on digital pins other than 0 and 1. This is better than using the hardware serial pins (0, 1) because it avoids interference with the serial monitor. The article's code uses hardware serial, but a more robust version would use SoftwareSerial (e.g., SIM900 RX → Arduino Pin 10, SIM900 TX → Arduino Pin 11).
- SoftwareSerial Library: The code often uses the
SoftwareSeriallibrary to communicate with the GSM module on digital pins other than 0 and 1. This is better than using the hardware serial pins (0, 1) because it avoids interference with the serial monitor. The article's code uses hardware serial, but a more robust version would use SoftwareSerial (e.g., SIM900 RX → Arduino Pin 10, SIM900 TX → Arduino Pin 11).
setup() Function:
Initializes serial communication with the PC (for debugging) and with the SIM900 module.
- Initializes serial communication with the PC (for debugging) and with the SIM900 module.
Sends a basic AT command to check if the module is responding.
- Sends a basic
ATcommand to check if the module is responding.
Configures the module for SMS text mode with AT+CMGF=1.
- Configures the module for SMS text mode with
AT+CMGF=1. setup()Function:Initializes serial communication with the PC (for debugging) and with the SIM900 module.Sends a basicATcommand to check if the module is responding.Configures the module for SMS text mode withAT+CMGF=1.
Sending an SMS (sendSMS function):
Uses the command AT+CMGS="+91XXXXXXXXXX" (replace with the actual recipient number, including country code).
- Uses the command
AT+CMGS="+91XXXXXXXXXX"(replace with the actual recipient number, including country code).
The module then expects the message content.
- The module then expects the message content.
The Arduino sends the message text.
- The Arduino sends the message text.
The message is finalized by sending a Ctrl+Z character (ASCII 26).
- The message is finalized by sending a Ctrl+Z character (ASCII 26).
- Sending an SMS (
sendSMSfunction):Uses the commandAT+CMGS="+91XXXXXXXXXX"(replace with the actual recipient number, including country code).The module then expects the message content.The Arduino sends the message text.The message is finalized by sending a Ctrl+Z character (ASCII 26).
Receiving an SMS (Reading):
The code waits for the module to notify it of a new message.
- The code waits for the module to notify it of a new message.
When a new message arrives, the module sends a string like +CMTI: "SM", <index> where <index> is the message's position in memory.
- When a new message arrives, the module sends a string like
+CMTI: "SM", <index>where<index>is the message's position in memory.
The code then sends AT+CMGR=<index> to read the message at that specific index.
- The code then sends
AT+CMGR=<index>to read the message at that specific index.
It parses the response, which contains the sender's number and the message text, and prints it to the serial monitor.
- It parses the response, which contains the sender's number and the message text, and prints it to the serial monitor.
- Receiving an SMS (Reading):The code waits for the module to notify it of a new message.When a new message arrives, the module sends a string like
+CMTI: "SM", <index>where<index>is the message's position in memory.The code then sendsAT+CMGR=<index>to read the message at that specific index.It parses the response, which contains the sender's number and the message text, and prints it to the serial monitor.
Here is a simplified version of the code logic for sending an SMS.
cpp
// Using Hardware Serial for simplicity (as in the article)
void setup() {
Serial.begin(9600); // Communication with PC/Serial Monitor
Serial1.begin(9600); // Communication with SIM900 (on boards that have multiple hardware serial)
delay(2000); // Wait for module to initialize
Serial.println("Setting up GSM Module...");
Serial1.println("AT"); // Handshake command
delay(1000);
Serial1.println("AT+CMGF=1"); // Set SMS to text mode
delay(1000);
}
void loop() {
sendSMS("+1234567890", "Hello from Arduino!"); // Send an SMS
delay(30000); // Wait 30 seconds before next action
// Code for receiving SMS would be here, checking Serial1 for incoming data
}
void sendSMS(String number, String text) {
Serial1.print("AT+CMGS=\"");
Serial1.print(number);
Serial1.println("\"");
delay(1000);
Serial1.print(text); // The SMS body
delay(1000);
Serial1.write(26); // Send Ctrl+Z to finalize and send
delay(5000); // Wait for the message to be sent
}Advantages and LimitationsAdvantages
Limitations / Challenges
Adds Remote Communication: Allows projects to send alerts and receive commands from anywhere with cellular network coverage.
High Power Consumption: Requires a robust external power supply, not suitable for battery-only projects.
Uses Ubiquitous SMS: Works on any mobile network without needing internet.
Network Dependency: Requires a good GSM signal and a valid, activated SIM card.
Relatively Low Cost: SIM900 modules are inexpensive.
Large Size: The SIM900 module is relatively bulky.
Foundation for IoT: Can be extended for GPRS data communication, making HTTP requests, etc.
Complex Parsing: Reliably reading and parsing received SMSs in code can be tricky.
Common Issues and TroubleshootingModule Not Responding / No Lights:
Check Power: Ensure you are using the 12V, 2A adapter. The network LED on the SIM900 should blink every ~1-3 seconds.
- Check Power: Ensure you are using the 12V, 2A adapter. The network LED on the SIM900 should blink every ~1-3 seconds.
Check SIM Card: Is it inserted correctly? Is it active and has balance?
- Check SIM Card: Is it inserted correctly? Is it active and has balance?
- Module Not Responding / No Lights:Check Power: Ensure you are using the 12V, 2A adapter. The network LED on the SIM900 should blink every ~1-3 seconds.Check SIM Card: Is it inserted correctly? Is it active and has balance?
"ERROR" Responses to AT Commands:
Baud Rate: Ensure the baud rate in your code (e.g., 9600) matches the module's baud rate.
- Baud Rate: Ensure the baud rate in your code (e.g.,
9600) matches the module's baud rate.
Wiring: Double-check the TX/RX connections. Arduino TX should go to SIM900 RX, and Arduino RX to SIM900 TX.
- Wiring: Double-check the TX/RX connections. Arduino TX should go to SIM900 RX, and Arduino RX to SIM900 TX.
Common Ground: This is essential! Connect the GND of the Arduino to the GND of the SIM900's power supply.
- Common Ground: This is essential! Connect the GND of the Arduino to the GND of the SIM900's power supply.
- "ERROR" Responses to AT Commands:Baud Rate: Ensure the baud rate in your code (e.g.,
9600) matches the module's baud rate.Wiring: Double-check the TX/RX connections. Arduino TX should go to SIM900 RX, and Arduino RX to SIM900 TX.Common Ground: This is essential! Connect the GND of the Arduino to the GND of the SIM900's power supply.
SMS Sending Fails:
Formatting: Ensure the phone number is in international format (e.g., +1 for US, +91 for India).
- Formatting: Ensure the phone number is in international format (e.g.,
+1for US,+91for India).
Final Character: Don't forget to send the Ctrl+Z (ASCII 26) character to end the message.
- Final Character: Don't forget to send the
Ctrl+Z(ASCII 26) character to end the message. - SMS Sending Fails:Formatting: Ensure the phone number is in international format (e.g.,
+1for US,+91for India).Final Character: Don't forget to send theCtrl+Z(ASCII 26) character to end the message.
The Send and Receive SMS using SIM900 project is a fundamental and powerful IoT tutorial. It teaches how to interface a microcontroller with a cellular module using AT commands over serial communication. Successfully completing this project opens the door to a wide range of applications, from remote sensors and security alarms to agricultural monitors and industrial control systems. Paying close attention to the power requirements is the key to making it work reliably.


_ztBMuBhMHo.jpg?auto=compress%2Cformat&w=48&h=48&fit=fill&bg=ffffff)





Comments