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.