Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to send AT command to a Modem using a Microcontrollers

Status
Not open for further replies.

Dilma

Newbie level 3
Joined
Aug 18, 2011
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,308
Hi..,
We are given a project to implement remote weather station. In that, all the measurement we are getting should be send via GPRS to the main station. We are going to use PIC 16F877. Can we do that from this PIC? Please explain how can we implement this? I have no knowledge how to use AT command without a hyperterminal..


Thanks in advance.
 

Hi Dilma,

Take a look at Microchip's USART ap note AN774. AT commands are text and you can send them through the PIC's serial port just like you would with a terminal emulator.

Good luck, Chris
 
  • Like
Reactions: Dilma

    Dilma

    Points: 2
    Helpful Answer Positive Rating
We are given a project to implement remote weather station. In that, all the measurement we are getting should be send via GPRS to the main station. We are going to use PIC 16F877. Can we do that from this PIC? Please explain how can we implement this? I have no knowledge how to use AT command without a hyperterminal..

You failed to mention whether you were using Assembly or C language and if C what compiler.

Here is an example using C:

You may need to register to access the source code for the example below.



Another Code Example:

Code:
  /*Header*****************************************************
Microcontroller=16f877
Clock=10 Mhz
Project Title:Air Pollution Control Using GSM/GPRS
Developed By:Sathiesh Kumar.V
Date:31/01/2010*/
void Calculation(unsigned int ) ;
void Gsm_SMS_Init();
void Gsm_SMS_Read();
void Gsm_SMS_Send();
// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
 
unsigned char ch;                    //
char Receive;
unsigned int adc_rd;                 // Declare variables
char *text;                          //
long tlong;                          //
unsigned int i,j;
char return_gsm[2];
char Gsm_Receive[100];
char Gsm_Msg[10];
char uart_rd[]="AT";
char uart_rd1[]="AT+CMGF=1";
char uart_rd2[]="AT+CMGR=1" ;
char uart_rd3[]="AT+CMGS=";
char Mobile_No[]="+919444721638" ;
char Send_Msg[]="@ON";
void main()
{
    INTCON = 0;                      // All interrupts disabled
    ADCON1 = 0x82;                   // A/D voltage reference is VCC
    TRISA = 0xFF;                    // All port A pins are configured as inputs
    TRISC=0x80;
    Delay_ms(2000);                    // Rest of pins are configured as digital
    UART1_Init(9600);              // Initialize UART module at 9600 bps
    Delay_ms(100);                 // Wait for UART module to stabilize
    Lcd_Init();                      // LCD display initialization
    Lcd_Cmd(_LCD_CURSOR_OFF);        // LCD command (cursor off)
    Lcd_Cmd(_LCD_CLEAR);             // LCD command (clear LCD)
 
    text = "Air Pollution ";       // Define the first message
    Lcd_Out(1,1,text);               // Write the first message in the first line
    delay_ms(500);
    text = "Sensor Value";            // Define the second message
    Lcd_Out(2,1,text);               // Define the first message
    delay_ms(500);
    Lcd_Cmd(_LCD_CLEAR);
 
 
    text = "GSM";               // Define the third message
 
   while (1)
   {
       Lcd_Out(1,1,text);               // Define the first message
       delay_ms(500);
       Lcd_Cmd(_LCD_CLEAR);
       Gsm_SMS_Init();
   }
}
 
void Gsm_SMS_Init()
{
if (UART1_Tx_Idle() == 1)
       {
         Lcd_Out(2,1,"AT");               // Define the first message
         delay_ms(500);
         Lcd_Cmd(_LCD_CLEAR);
 
         for(i=0;i<=1;i++)
          {
          UART1_Write(uart_rd[i]);           //AT
          }
        UART1_Write(0x0D);                   //Enter
 
        //delay_ms(5000);
        while(1)
        {
           Lcd_Out(2,1,"In while");               // Define the first message
           delay_ms(500);
           Lcd_Cmd(_LCD_CLEAR);
 
         if (UART1_Data_Ready())
        {                         // If data is received,
      Lcd_Out(2,1,"In IF");               // Define the first message
           delay_ms(500);
           Lcd_Cmd(_LCD_CLEAR);
 
          for(i=0;i<=1;i++)
          {
           return_gsm[i] = UART1_Read();      //   read the received data, Received OK
          }
           Lcd_Out(2,1,"OK");               // Define the first message
           delay_ms(500);
           Lcd_Cmd(_LCD_CLEAR);
 
          /* UART1_Write(return_gsm[0]);
           Lcd_Out(2,1,"OK RESEND");               // Define the first message
           delay_ms(500);
           Lcd_Cmd(_LCD_CLEAR);  */
 
          // UART1_Write(return_gsm[1]);
        }
        }
        /*if(return_gsm[0]==0x4F && return_gsm[1]==0x4B)
          {
            if (UART1_Tx_Idle() == 1)
            {
               for(i=0;i<=8;i++)
                {
                 UART1_Write(uart_rd1[i]);   //AT+CMGF=1
                }
               UART1_Write(0x0D);            //Enter
               Lcd_Out(1,1,"AT+CMGF=1");
               delay_ms(500);
               Lcd_Cmd(_LCD_CLEAR);
            }
            if (UART1_Data_Ready())
            {                             // If data is received,
                for(i=0;i<=1;i++)
                 {
                   return_gsm[i] = UART1_Read();      //   read the received data,OK
                 }
                 Lcd_Out(2,1,"Received OK");
                 delay_ms(500);
                 Lcd_Cmd(_LCD_CLEAR);
            }
                }  */
           }
  }Last edited by bryan1; 1st January

Hope the examples help in your endeavors.

BigDog
 
  • Like
Reactions: Dilma

    Dilma

    Points: 2
    Helpful Answer Positive Rating
Hi Dilma,

Take a look at Microchip's USART ap note AN774. AT commands are text and you can send them through the PIC's serial port just like you would with a terminal emulator.

Good luck, Chris

Thanks tcatkins...

---------- Post added at 23:03 ---------- Previous post was at 22:47 ----------

Thanks everybody...
 

Hi..,
We are given a project to implement remote weather station. In that, all the measurement we are getting should be send via GPRS to the main station. We are going to use PIC 16F877. Can we do that from this PIC? Please explain how can we implement this? I have no knowledge how to use AT command without a hyperterminal..
Is this command you need, example GSM Modem. That is free source code to sending SMS and receive SMS using PIC Hi-Tech.
 

Hi...
Can we use a USB Dongle instead of a GSM modem you have shown?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top