This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

GSM modem interfacing with MSP430G2553

Other Parts Discussed in Thread: ENERGIA, MSP430G2553, MAX3232

I am using MSP430G2 launchpad and trying to interface it with a SIM900 GSM module. I have crossed the jumpers in Launchpad for serial communication.

I have connected P1.1 (Rx) to Tx pin on GSM and P1.2(Tx) to Rx pin of GSM. The 2 grounds are short. The GSM module gets 12 V external supply, whereas the launchpad is connected to PC via USB port.. The GSM modem is working, I have tested with Hyperterminal.

I have tried both Energia IDE and CCS. but the message is not being sent.

CCS Code:

#include <msp430.h>
#include "msp430g2553.h"

#include "uart.h" // ATTACH THE UART FILE WITH THE MAIN CODE
void gsm();
int main(void)

{

WDTCTL = WDTPW + WDTHOLD;// STOP WATCHDOG TIMER

BCSCTL1 = CALBC1_8MHZ;// MAKE THE FREQUNCY AS PER THE LAUNCHPAD 8MHZ

DCOCTL = CALDCO_8MHZ;

uart_init(); // CALL THE UART INIT FUNCTION WHICH IS AVAILAIBLE IN THE FILE

__enable_interrupt();// ENABLE INTERRUPT

__delay_cycles(100000);
gsm();// CALL THE GSM FUNCTION

}

void gsm()

{
uart_puts((char *)"AT"); // COMMAND FOR INITIALIZING GSM

uart_putc(0x0A);//ENTER

uart_putc(0x0D);//CARRIAGE RETURN

__delay_cycles(10000000);//DELAY...WAIT FOR OK FROM GSM

uart_puts((char *)"AT+CMGF=1");//COMMUNICATION

uart_putc(0x0A);

uart_putc(0x0D);

__delay_cycles(10000000);//WAIT FOR OK

uart_puts((char *)"AT+CMGS=\"9731371397\"");//SEND A MESSAGE TO PARTICULAR NUMBER

uart_putc(0x0A);

uart_putc(0x0D);

uart_puts((char *)"hello");//SEND HELLO

uart_putc(0x1A);//CTRL Z

}

This code compiles with no errors but no message is sent from modem.

Energia Code

const int buttonPin = PUSH2; // the number of the pushbutton pin
const int ledPin = GREEN_LED; // the number of the LED pin

// variables will change:
int buttonState = 0; // variable for reading the pushbutton status

void setup()
{
Serial.begin(9600);
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT_PULLUP);
}

void loop()
{
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);

// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH)
{
// turn LED on:
digitalWrite(ledPin, LOW);
}
else
{
// turn LED off:
digitalWrite(ledPin, HIGH);
sendsms();
delay(1000);
}
}
void sendsms()
{
Serial.println("AT+CMGF=1\r\n");
Serial.println("AT+CMGS=\"9731371397\"\r"); //Enter Mobile Number between double " " codes.
Serial.println("Hello");
Serial.print(char(26));//SMS to ur Mobile Number
delay(5000);
delay(5000);
}

There are no errors while uploading and the commands appear on the serial monitor but no message is sent from modem.

I have gone through both the codes, I cannot understand why it isn't working. 

  • But the GSM module does hopefully not drive out at 12V (and expects input voltages in that range). 12V seems to be quite much, I guess there is some voltage regulator on it, too. But make sure it isn't 5V, either.
  • "But the GSM module does hopefully not drive out at 12V "
    While V.24/RS232 indeed ranges up to +-12V, few devices are really going that far. Most are just outputting +-5V or even +-3V (while of course accepting +-12V). But even with +-3V, it won't work since RS232 '0' level is +3V and '1' level is -3V. Which is incompatible with the MSPs 0V/3V(or rather VCC) signals. A level shifter like the MAX3232 is required.

    However, some modems work with TTL level signals. It may still mean that they emit 5V for '1' then, which is still too much for the MSP (a 4k7 series resistor is the cheapest way to prevent damage).
    It may also be that the modem documentation means 'tx' is the signal that is to be transmitted. So it would have to be connected to the MSPs TX line. Others mean 'tx' is the signal that the modem is sending to the CPU, and it has to be connected to the MSPs RX line.

    One thing I noticed: your main code calls gsm(), and gsm() returns. Then the code falls out of main into the void.

    Without knowing what uart_init() and uart_puts() or uart_putc() _exactly_ do, I can't help you finding a potential bug in the code.

**Attention** This is a public forum