#include <SoftwareSerial.h>
//Create software serial object to communicate with SIM900A
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
}
}
sim900A has network but not communicating with arduino mega.
tried with the voltage divider also.
but not responding means AT command not working at all.
I'm powering the module with usb cable from my laptop
Show your connections in a diagram, including power supply, and a photo to verify... are you using 5v (5VR/5VT) or 3v3 (3VR/3VT) - and not the RS232 TX/RX connector.
some modems use 3.3V logic so you have to use a potential divider on the Mega Tx signal to the modem Rx
the program I used
// SIM900 GSM modem test for Arduino Mega - working 15 May 2022
// serial monitor line ending should be Carriage Return Carriage Return or CR & NL
/* when you power the SIM900 the PWR LED should light
if you press the PWRKEY on the SIM900
1. the STATUS LED should lingth
2. the Netlight should blink
and the following appear on the terminal
RDY
+CPIN: NOT INSERTED
+CFUN: 1
*/
// UART connections
// j17/j18 set D7/D8
// connect SIM900 TXD (pin D8) to Mega pin 19 RXD (pin D7) to pin 18
// j17/j18 set D1/D0
// connect SIM900 TX (pin D0) to Mega RX1 (pin 19) SIM900 RX (pin D1) toMega TX1 (pin 18)
// see https://create.arduino.cc/projecthub/mitov/send-and-receive-text-messages-sms-with-gsm-sim900-shield-6d53c6
// AT+CGMI returns the manufacturer's name
// AT+CGMM returns the MODEM model number
// AT+CGMR returns details of the software and model revision level
// AT+CGSN returns the MODEM's serial number
#define mySerial Serial1
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(115200);
while (!Serial) { }
Serial.println("Mega SIM800 test!");
// set the data rate for the Serial port
mySerial.begin(9600);//115200);//115200);
}
void loop() { // run over and over
if (mySerial.available()) {
Serial.write(mySerial.read());
}
while (Serial.available()) {
char ch;
mySerial.write(ch=toupper(Serial.read()));
Serial.write(ch);
}
}
can you give a closeup photo of the SIM900A or a link to where you purchased it?
Mega2560 has more than one Hardware Serial port... Serial1 uses Tx = pin 18, Rx = pin 19) so you would not need SoftwareSerial.h. Your sketch was written for Uno/Nano with only one Hardware Serial port (pins 0/1)
what program are you using?
how have you connected the Mega to the SIM900A? ?
as the Mega uses 5V logic you should connect to 5RX and 5TX
e.g. if using the program of post 6
SIM900A 5RX to Mega pin 18 TX1
SIM900A 5TX to Mega pin 19 RX1
if using the program from the link in post 7
SoftwareSerial SIM900A(10,11); // RX | TX
// Connect the SIM900A TX to Arduino pin 10 RX.
// Connect the SIM900A RX to Arduino pin 11 TX.
change the baudrate to the external device
best to have serial monitor at higher baudrate than external device otherwise you may loose data as the serial monitor buffer overruns, e.g.
Serial.begin(115200);
// set the data rate for the Serial port
mySerial.begin(9600); // << try 19200, 38400, etc