Hello there !
I uploaded the following code from http://tronixstuff.com/2014/01/08/tutorial-arduino-and-sim900-gsm-modules/
and it is not working. There is no reading in Serial Monitor.
#include <SoftwareSerial.h>SoftwareSerial SIM900(7, 8); char incoming_char=0; void setup(){ Serial.begin(19200); // for serial monitor SIM900.begin(19200); // for GSM shield SIM900power(); // turn on shield delay(20000); // give time to log on to network. SIM900.print("AT+CMGF=1\r"); // set SMS mode to text delay(100); SIM900.print("AT+CNMI=2,2,0,0,0\r"); // blurt out contents of new SMS upon receipt to the GSM shield's serial out delay(100);} void SIM900power()// software equivalent of pressing the GSM shield "power" button{ digitalWrite(9, HIGH); delay(1000); digitalWrite(9, LOW); delay(7000);} void loop(){ // Now we simply display any text that the GSM shield sends out on the serial monitor if(SIM900.available() >0) { incoming_char=SIM900.read(); //Get the character from the cellular serial port. Serial.print(incoming_char); //Print the incoming character to the terminal. } }
AND THIS CODE IS WORKING.
#include <SoftwareSerial.h>SoftwareSerial SIM900(7, 8);int x,y;String textForSMS; void setup(){ SIM900.begin(19200); SIM900power(); delay(20000); // give time to log on to network. randomSeed(analogRead(0));} void SIM900power()// software equivalent of pressing the GSM shield "power" button{ digitalWrite(9, HIGH); delay(1000); digitalWrite(9, LOW); delay(7000);} void sendSMS(String message){ SIM900.print("AT+CMGF=1\r"); // AT command to send SMS message delay(100); SIM900.println("AT + CMGS = \"+12128675309\""); // recipient's mobile number, in international format delay(100); SIM900.println(message); // message to send delay(100); SIM900.println((char)26); // End AT command with a ^Z, ASCII code 26 delay(100); SIM900.println(); delay(5000); // give module time to send SMS SIM900power(); // turn off module} void loop(){ x = random(0,255); y = random(0,255); textForSMS = "Your random numbers are "; textForSMS.concat(x); textForSMS = textForSMS + " and "; textForSMS.concat(y); textForSMS = textForSMS + ". Enjoy!"; sendSMS(textForSMS); do {} while (1)}
What could be the problem ?