General

Battery gps/gprs/gsm

userHead baterista41 2014-07-20 19:13:52 4019 Views3 Replies
hi

I'm trying to send a message to another cell, but I can not, I think the problem is the power of the battery, as I show them my module is connected with my arduino.


[img]http://sia1.subirimagenes.net/img/2014/ ... 569635.jpg[/img]

[img]http://sia1.subirimagenes.net/img/2014/ ... 881957.jpg[/img]


[img]http://sia1.subirimagenes.net/img/2014/ ... 516400.jpg[/img]


I have connected a bluetooth hc-05, when shipping number 3 led lights and send a message but does not send any message


I have taken this code from the wiki


Code: Select all

byte gsmDriverPin[3] = {
  3,4,5};




void  setup ()
{    

  for( int  i = 0; i <3; i++) {
    pinMode (gsmDriverPin [i], OUTPUT);
  }
  pinMode(13,OUTPUT);
  Serial1.begin(9600);
  
  digitalWrite(5,HIGH);//Output GSM Timing 
  delay(1500);
  digitalWrite(5,LOW);  
  digitalWrite(3,LOW);//Enable the GSM mode
  digitalWrite(4,HIGH);//Disable the GPS mode
  delay(2000);
  Serial.begin(9600); //set the baud rate
  delay(5000);//call ready
  delay(5000);
  delay(5000);
  
  
}
 
void  loop ()
{  
  
  
  if(Serial1.available())
  {
    int a=Serial1.read();
    
    if(a=='3'){
      
      digitalWrite(13,HIGH);
      delay(1000);
      digitalWrite(13,LOW);      
      
        Serial.println("AT"); //Send AT command  
        delay(2000);
        Serial1.println("AT");   
        delay(2000);
        //Send message
        Serial1.println("AT+CMGF=1");
        delay(1000);
        Serial1.println("AT+CMGS=\"9511212886\"");//Change the receiver phone number
        delay(1000);
        Serial1.print("HELLO");//the message you want to send
        delay(1000);
        Serial1.write(26);
        while(1);
      
     
      
      
    }
  }
  
  /*

  */
}


2014-07-22 19:15:44 The serial monitor? How do you connect your Bluetooth to your PC? with a Bluetooth dongle?
I think it is not what your GSM module received, it is what your bluetooth received.
After the first "AT", you have changed "Serial" to "Serial1"
Code: Select all
Serial.println("AT"); //Send AT command  
        delay(2000);
        Serial1.println("AT");   
        delay(2000);
        //Send message
        Serial1.println("AT+CMGF=1");
......
And from your connection, what Serial1 connected is Bluetooth, not GSM module.

Hey, you could try this code:
Code: Select all
byte gsmDriverPin[3] = {
  3,4,5};


void  setup ()
{    
  for( int  i = 0; i <3; i++) 
  {
    pinMode (gsmDriverPin [i], OUTPUT);
  }
  pinMode(13,OUTPUT);
  Serial1.begin(9600);
  Serial.begin(9600); //set the baud rate
  digitalWrite(5,HIGH);//Output GSM Timing 
  delay(1500);
  digitalWrite(5,LOW);  
  digitalWrite(3,LOW);//Enable the GSM mode
  digitalWrite(4,HIGH);//Disable the GPS mode
  delay(2000);
  delay(5000);//call ready
  delay(5000);
}

void  loop ()
{
  if(Serial1.available())
  {
    int a=Serial1.read();
    if(a=='3')
    {     
      digitalWrite(13,HIGH);
      delay(1000);
      digitalWrite(13,LOW);      
      Serial.println("AT");   
      delay(50);
      //Send message
      Serial.println("AT+CMGF=1");
      delay(50);
      Serial.println("AT+CMGS=\"9511212886\"");//Change the receiver phone number
      delay(50);
      Serial.print("HELLO");//the message you want to send
      delay(50);
      Serial.write(26);
    }
  }
}



"While(1);" will make your loop die. so I delete it. and it is no need to use such a long time delay.
After upload the sketch,  turn the switch S1 to Comm side; S2 to Arduino side; Uart Select to the middle.
userHeadPic Grey.CC
2014-07-21 19:59:38 the code works,the serial monitor shows the following lines according to the code,



AT
AT
AT+CMGF=1
"AT+CMGS=\"9511212886\""
"HELLO"



but it does not receive any message the other cellphone, why is the correct form to aliment (batery) the GPS module and the arduino? or is it well connected?
userHeadPic baterista41
2014-07-21 18:25:44 Welcome baterista41.

If I am right, you have connected Bluetooth to Serial1 port, and GSM module to Serial port.
But your code is sending AT command to Serial1 port , it is Bluetooth module, not GSM one. So I guess it doesn't work.

From you picture, I saw that you turned the UART switch to the GSM side, It is better to turn it to the middle, if you want to control it with your code.
userHeadPic Grey.CC