Hi everyone, I was using an Arduino Uno for my project with SIM900A Mini module. At first it was ok but I soon realized that I needed more memory so I switched to an Arduino Mega. During this I realised that I can send data to the SIM900A module, but can't recieve using AT commands. I used two codes for testing. The first code I can't send and recieve, but the second code I can only send but not recieve. I don't quite understand what's happening but it's making me restless for hours trying to find the problem. I tried using Arduino Uno again to test the code and it works perfectly, it's only when I use Arduino Mega that this problem occurs. Below is the codes that I used:
First Code:
#include <SoftwareSerial.h>
//Create software serial object to communicate with SIM800L
SoftwareSerial mySerial(3, 2); //GSM Module Rx & Tx is connected to Arduino #2 & #3
void setup()
{
//Begin serial communication with Arduino and Arduino IDE (Serial Monitor)
Serial.begin(9600);
//Begin serial communication with Arduino and SIM900A
mySerial.begin(9600);
}
void loop()
{
while (Serial.available())
mySerial.write(Serial.read());//Forward what Serial received to Software Serial Port
while(mySerial.available())
Serial.write(mySerial.read());//Forward what Software Serial received to Serial Port
}
Second Code:
#include <SoftwareSerial.h>
// Define RX and TX pins for SoftwareSerial
SoftwareSerial SIM900A(3, 2); // RX = Pin 10, TX = Pin 11
void setup() {
// Initialize serial communication
Serial.begin(9600); // For communication with the PC
SIM900A.begin(9600); // For communication with the SIM 900A module
Serial.println("Initializing GSM SIM 900A...");
delay(1000);
// Send AT command to check module response
SIM900A.println("AT");
delay(1000);
if (SIM900A.available()) {
Serial.println("Module is ready!");
} else {
Serial.println("No response from module. Check connections.");
}
// Send SMS
sendSMS("+xxxxxxxxx", "Hello from GSM SIM 900A!");//phone number censored obviously
}
void loop() {
// Nothing to do in the loop
}
void sendSMS(String phoneNumber, String message) {
SIM900A.println("AT+CMGF=1"); // Set SMS mode to text
delay(1000);
SIM900A.print("AT+CMGS=""); // Start SMS command
SIM900A.print(phoneNumber); // Add recipient phone number
SIM900A.println(""");
delay(1000);
SIM900A.print(message); // Add SMS content
delay(1000);
SIM900A.write(26); // Send Ctrl+Z to send the SMS
delay(5000);
Serial.println("SMS sent successfully!");
}
below is the connection I made to Arduino Mega as well as UNO
Thank you very much, any help is appreceated.

