Im trying to send an sms from a sim900 SIMCom module using a sim I know works because when I put it in the phone I can make calls and send sms to the same mobile im trying to in code. Here is my code:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(9,10);
void setup(){
mySerial.begin(9600); // Setting the baud rate of GSM Module
Serial.begin(9600); // Setting the baud rate of Serial Monitor (Arduino)
delay(100);
}
void loop(){
if (Serial.available()>0)
switch(Serial.read())
{
case 's':
SendMessage();
break;
case 'r':
RecieveMessage();
break;
}
if (mySerial.available()>0)
Serial.write(mySerial.read());
}
void SendMessage()
{
mySerial.println("AT+CMGF=1\r"); //Sets the GSM Module in Text Mode
delay(1000); // Delay of 1000 milli seconds or 1 second
mySerial.println("AT+CMGS=\"+mymobile\"\r"); // Replace x with mobile number
delay(1000);
mySerial.println("I am SMS from GSM Module");// The SMS text you want to send
delay(100);
mySerial.println((char)26);// ASCII code of CTRL+Z
delay(1000);
}
void RecieveMessage()
{
mySerial.println("AT+CNMI=2,2,0,0,0"); // AT Command to receive a live SMS
delay(1000);
}
and my wiring is:
Nano pin 10 - Rxd on SIM900
Nano pin 9 - Txd on SIM900
5V - 5V
GND - GND
I get this in the SM:
⸮⸮⸮⸮⸮
RDY
+CFUN: 1
+CPIN: READY
AT+CMGF=1
OK
AT+CMGS="+50494505578"
> I am SMS from GS⸮⸮⸮⸮
RDY
+CFUN: 1
+CPIN: READY
What else can I try?
OK wait, I just realized the module isnt connecting to the network...