ARCH GPRS V2 Send SMS Test

With the arrival of my amaysim, I managed to get the Arch GPRS V2 to send an SMS message.

For the full example, you can check out my mbed repository.

My starting point was, again, an example of interfacing to the SIM900 from the on board micro. This example successfully powers the SIM900 and then polls it using the Serial class.

Powering on the SIM900 is a two step process. First, VBAT is powered with the VBAT_900 line, then PWRKEY is driven low for 1 second before being released, as explained in the reference design guide.

VBAT is powered by driving P1_2 low. From the schematic, we can see that this will connect VBAT_900 with either VCC_BUCK or VCC_BAT, depending on whether or not we are connected to (and, being powered by) USB.

Power switch; use P1_2 to connect VBAT_900 with either VCC_BUCK or VCC_BAT
Power switch; use P1_2 to connect VBAT_900 with either VCC_BUCK or VCC_BAT

As an aside, I believe this part of the schematic is labelled EG10 because the EG-10 GPRS module was used in version 1 of the Arch GPRS and someone forgot to update the document. Also, D16 is an ESD protection diode, which is protecting VBAT_900 and P1_7 and does not affect the functionality we are discussing here.

PWKREY is cycled using P1_7, as seen on the schematic.

PWRKEY is controlled using P1_7
PWRKEY is controlled using P1_7. VBAT_900 line is connected to VBAT.

The firmware looks like this:

// PINPWR to low on Q10 drives 3V3 to Q7, which drives Q5 to ground, which powers VBAT_900, with either VCC_BUCK or VCC_BAT
#define PINPWR                  P1_2

// PINONOFF controls PWRKEY on the SIM900, see manual for more info
#define PINONOFF                P1_7

DigitalOut m_sim900_pwr(PINPWR);      
DigitalOut m_sim900_on (PINONOFF);

...

void main()
{
...
    // power on sequence borrowed from http://gronlier.fr/blog/2014/11/seeeduino-arch-gprs-v2/
    // order of events specified by the SIM900 manual
    m_sim900_pwr.write(1);     // turn power supply off
    m_sim900_on.write(1);
    wait(0.5);                 // wait to settle
    
    m_sim900_pwr.write(0);     // turn power supply on
    m_sim900_on.write(0);      // from the ref: "drive the PWRKEY to a low level for 1 second then release."
    wait(1);                   // wait for one second
    
    m_sim900_on.write(1);      // release power key
    wait(20 /*0.5*/);          // wait to settle

...
}

I wait for 20 seconds to settle to make absolutely certain that it has powered up and connected to the cellular network. The status LEDs will flash a certain way once it has connected, as explained in this tutorial using the SIM900 with an Arduino.

The bright “STATUS” LED will come on, and then the “NETLIGHT” LED will blink once every 800 milliseconds- until the GSM module has found the network, at which point it will blink once every three seconds.

I got the correct AT commands for sending an SMS from the same tutorial. Of particular interest was the sendSMS() function:

void sendSMS()
{
  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("Hello, world. This is a text message from an Arduino Uno.");        // 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
}

Something I was stuck on for a little while was that println() appends a carriage return and line feed to any string that it parses. When porting this over to the mbed project, I had to add these in manually to get it to work:

// the following sequence and messages are borrowed from http://tronixstuff.com/2014/01/08/tutorial-arduino-and-sim900-gsm-modules/
// Set SMS mode with AT command
m_sim900_serial.printf("AT+CMGF=1\r\n");
myled1 = 1;
wait(0.1);
    
// Send phone number in international format
m_sim900_serial.printf("AT + CMGS = \"+61123456789\"\r\n");
myled2 = 1;
wait(0.1);
        
// Send text   
m_sim900_serial.printf("Hello, world. This is a text message from an Arch GPRS V2.\r\n");
myled3 = 1;
wait(0.1);    
    
// End message with AT command ^Z, ASCII code 26
m_sim900_serial.putc((char)26);
m_sim900_serial.printf("\r\n");          
myled4 = 1;
wait(0.1);

Piece of cake!

Spamming myself
Spamming myself

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s