hi i've been testing my SIM900 and Arduino mega but when i try to communicate with sim900 via Serial and Serial1 the SIM900 does not respond. Here is the sample code i use for testing
void setup()
{
//Begin serial communication with Arduino and Arduino IDE (Serial Monitor)
Serial.begin(9600);
//Begin serial communication with Arduino and SIM900
Serial1.begin(9600);
Serial.println("Initializing...");
delay(1000);
Serial1.println("AT"); //Handshaking with SIM900
updateSerial();
Serial1.println("AT+CSQ"); //Signal quality test, value range is 0-31 , 31 is the best
updateSerial();
Serial1.println("AT+CCID"); //Read SIM information to confirm whether the SIM is plugged
updateSerial();
Serial1.println("AT+CREG?"); //Check whether it has registered in the network
updateSerial();
}
void loop()
{
updateSerial();
}
void updateSerial()
{
delay(500);
while (Serial.available())
{
Serial1.write(Serial.read());//Forward what Serial received to Software Serial Port
}
while(Serial1.available())
{
Serial.write(Serial1.read());//Forward what Software Serial received to Serial Port
}
}
this should be the output:
but all i got is this:
can you help me?
btw iim using hardware serial of the SIM900 and i also connected both gND pins of arduino Mega and SIm900
can you provide detials of the SIM900 module and how it is connected
e.g. using
the following code works
// 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);
}
}
@horace That is the connection i used when i test the module
@lastchancename the wiring is the same as the one replied by @horace. The delay must be for entering commands only..maybe... i'll try to remove it and see what is the output.
i tried checking my module using a FTDI programmer and it works. Every command i entered on the serial monitor get a response from the module.
@lastchancename@horace is it okay if i use the Tx & Rx pins of the module instead of (D0,D1) and (D7,D8) to connect to the serial1 of the arduino mega?
@horace i used the Tx, Rx and GND pins near the 3.5mm barrel jack to communicate with the arduino mega and it works like a charm....
`// 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);
}
}
also i tried this code that you posted and it returns the desired output