Need Help with GSM SIM900a, it will not work with power dc only usb power

Please help here, i'm working on a small project with Network Shield, Arduino Uno and GSM SIM900a modules.

My goal is very simple, I have an address parameter sent with phone number and type message. Once received, it filters the parameter and send sms.

The code is working IF ONLY CONNECTED via USB, if I want to connect with DC (5v 2A) it wont work and doesn't send any message (sms). I already tried connecting the power directly to the GSM not from Arduino but still the same.

Any help really appreciated. Thanks.

#include <SoftwareSerial.h>
#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xED};

const char mobileno[13] = "";
const char txtmessage[30] = "";

EthernetServer server(80);
SoftwareSerial SIM900A(7,8);

String readString = String(30);
char phone[13] = "";
char txt[30] = "";
String mobile_ = "";
String msg_ = "";

String mobile_msg;
String data;
int start;
int ind1; // - locations
int ind2;

String currentLine = "";
String tweet = "";   
String current_tweet = "";
boolean readingTweet = false;

void setup()
{ 
  delay(1000);
  // GSM
  SIM900A.begin(9600);   
  Serial.begin(9600);    
  delay(100);
  //SIM900A.begin(38400);   
  Serial.println ("SIM900A Ready");
  delay(100);
  Serial.println ("Type s to send message or r to receive message");

  // ETHERNET
  delay(1000);
  Ethernet.begin(mac);
  delay(500);
  server.begin();
  delay(500);
  Serial.println("Server is at");
  Serial.println(Ethernet.localIP());
  
}

void loop()
{ 
  
  if (Serial.available()>0){
    switch(Serial.read())
    {
      case 's':
        SendMessage("09277324510", "Message here...");
        break;
      case 'r':
        RecieveMessage();
        break;
    }
  }
  
  if (SIM900A.available()>0){
    Serial.write(SIM900A.read());
  }

  // Create a client connection
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();

        //read char by char HTTP request
        if (readString.length() < 100) {

          //store characters to string
          readString += c;
          //Serial.print(c);
        }

        //if HTTP request has ended
        if (c == '\n') {

          ///////////////
          Serial.println(readString); //print to serial monitor for debuging

          //now output HTML data header
             if(readString.indexOf('?') >=0) { //don't send new page
               client.println("HTTP/1.1 204 Zoomkat");
               client.println();
               client.println(); 
             }
             else {
          client.println("HTTP/1.1 200 OK"); //send new page
          client.println("Content-Type: text/html");
          client.println();
          client.println("<HTML>");
          client.println("<HEAD>");
          client.println("<TITLE>HOVER - GSM Server</TITLE>");
          client.println("</HEAD>");
          client.println("<BODY>");
          client.println("<H1>GSM</H1>");
          client.println("</BODY>");
          client.println("</HTML>");
             }

          delay(1);
          //stopping client
          client.stop();

          ///////////////////// control arduino pin
          Serial.println("client disconnected.");
          Serial.println("Data from server captured in readString:");
          Serial.println();
          Serial.print(readString); //prints readString to serial monitor
          Serial.println(); 
         
          //parse readString for data
          start = readString.indexOf("?phone");  //finds a unique start location
          ind1 = readString.indexOf('=', start+2);  //finds location of first -
          ind2 = readString.indexOf("&d", ind1+1 );   //finds location of second -
          data = readString.substring(ind1+1, ind2);   //captures data String
          Serial.print("my data is: ");
          Serial.println(data);
          mobile_msg = data;
          Serial.println();
          int n = data.toInt();  //convert data into a number
          Serial.print("my number is: ");
          Serial.println(n);
           
          Serial.println();
          Serial.println("End of readString");
          Serial.println("==================");
          Serial.println();
          readString=""; //clear readString variable
          data=""; //clear data variable
          readString="";

          // SENDING SMS
          mobile_ = mobile_msg.substring(0,11);
          mobile_.toCharArray(phone,13);
          msg_ = mobile_msg.substring(16,18);
          msg_.toCharArray(txt,30);
          Serial.println( "------------------" );
          Serial.println( "READING TXT: " );
          Serial.println( txt );
          Serial.println( "------------------" );
          //if(txt == "01"){
             // SendMessage( phone , "You have a Visitor!" );
            //}else{
                SendMessage( phone , "Message here..." );
              //}

        }
      }
    }
  }

}

 void SendMessage(char mobile_number[13], char txt_message[100])
{
    Serial.println ("Sending Message...");
    SIM900A.println("AT+CMGF=1");    //Sets the GSM Module in Text Mode
    delay(2000);
    Serial.println ("Set SMS Number");
    SIM900A.println(String("AT+CMGS=\"") + mobile_number + String("\"\r")); 
    delay(2000);
    Serial.println ("Set SMS Content");
    SIM900A.println( txt_message );// Messsage content
    delay(2000);
    Serial.println ("Finish");
    SIM900A.println((char)26);// ASCII code of CTRL+Z
    delay(500);
    Serial.println ("Message has been sent!");
}

 void RecieveMessage()
{
  Serial.println ("SIM900A Membaca SMS");
  //delay (2000);
  SIM900A.println("AT+CNMI=2,2,0,0,0"); // AT Command to receive a live SMS
  delay(1000);
  Serial.write ("Unread Message done!");
 }

Please post photos of you boards and connections.

Sorry for the late reply. I don't know if I'm attaching the right photo. It's an actual pic with what I'm working now.

I also tried putting them separate power source both Arduino Uno and SIM900a but still the same. I didn't work perfectly unlike Arduino Uno powered via usb and the SIM900a gets from pins 5v and GND.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.