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.

[PIC] gsm quectel m95 with pic 16f877A

Status
Not open for further replies.

Downuri

Newbie level 4
Joined
Feb 26, 2016
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
40
Hello,
i have a problem with the gsm and the pic , i want to send a sms with gsm + pic but it's doesn't work i have this code :
Code:
#include <16F877A.h>
#fuses HS,NOWDT,NOPROTECT,PUT,NOBROWNOUT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)
#include <LCDPICDEM2006.c>

 

void main()
{
SET_TRIS_A(0x0d);
printf("AT\r"); 
delay_ms(1000);
printf("AT+CSCS=\"GSM\"");
delay_ms(1000);
printf("AT+CMGF=1\r"); //texte mode 
delay_ms(1000);
printf("AT+CMGS=+33665343539\r"); 
delay_ms(1000);
printf("teste");
delay_ms(1000);
putchar(0x1A);
while(TRUE);
}
but it doesn't work , i have conected like this : **broken link removed**
i do the connection :
M95 towards pic16f877A
TX ==> RC7
RX ==> RC6
5V ==>5V
GND==>GND
Stat==>RB4
PWK==>RB5
I'm actually blocked but i don't know why , the program is correct ?
GND ==> GND
 

hello,


what answer do you get for each AT commande
the 1rst step is to send AT , and get OK response ..
so you have the good UART speed to dialogue with GSM..

before sending an SMS , you must do an init of GSM
this is what i get with mine.
20:01:37.500> Arme RX IT UART2 ..
20:01:37.500> Negoce baud rate
20:01:38.500>
20:01:38.500> OK
20:01:39.000> Negoce reussi
20:01:39.062> Set PIN code(AT+CPIN=1234)
20:01:41.562>
20:01:41.562> +CPIN: READY
20:01:41.562>
20:01:41.562> OK
20:01:41.562>
20:01:41.562> Call Ready
20:01:41.562> Last Step: 1
20:01:41.625> Send Msg type as text mode (AT+CMGF=1)
20:01:44.125>
20:01:44.125> OK
20:01:44.125> Last Step: 2
20:01:44.125> Test si enregistré sur le reseau (AT+CREG?1)
20:01:46.625>
20:01:46.687> +CREG: 0,5
20:01:46.687>
20:01:46.687> OK
20:01:46.687> Last Step: 3
20:01:46.687> Lecture de date et heure (AT+CCLK?)
20:01:49.187>
20:01:49.187> +CCLK: "04/01/01,00:00:16+04"
20:01:49.187>
20:01:49.250> OK
20:01:49.250> Last Step: 4
20:01:49.250> Never go in SLEEP mode(AT+QSCLK=0)
20:01:51.750>
20:01:51.750> OK
20:01:51.750> Last Step: 5
20:01:51.812> Save profile (AT&W)
20:01:54.312>
20:01:54.312> OK
20:01:54.312> Last Step: 6
20:01:54.312> List all msg from inbox (AT+CMGL=ALL)
20:01:56.812>
20:01:56.812> OK
20:01:56.812> Last Step: 7
20:01:56.875> Phase d'init en 7 pas / 7
20:01:56.875> .. OK
 

Hello ,

in first one thanks for your answer but i have others questions.
How we can see the answer ? with a terminal? if yes wich one? because i think i don't have :(
and can we send a sms with date and hour with a command or something like that
 

How we can see the answer ? with a terminal? if yes wich one? because i think i don't have :(

Yes, you have only one hardware UART < ---- > GSM device !

but you can add a software UART on any available output PIN for TX usage ..
add a MAX232, or a 2TR interface if you have a com port on your PC
or a Prolific Cable PLH2303 converter TTL/USB Virtual COM PORT
or a blue tooth device HC05 or RN41 .. terminal bluetooth on your phone or tablette

or**broken link removed**interface, if you have a Pickit2
(Pickit2 connected to PORTB ICSP pin = Terminal )

In your code :
All you receive by Hardware UART RX interrupt , must be copied to the TX Softawre UART
All you send to the GSM by TX Hardware ,must be copied ti the TX Software UART
so you can follow the dialogue in both way .

and can we send a sms with date and hour with a command or something like that

Date & time comming from what device ?
Real Time Clock RTC DS1307 I2C or DS1302 SPI or other ?


a command ?
What kind of command ?
An external Event like status change on an input ?
or a threshod on an nalog measure ?



Use of GSM is not so easy as your code let suppose..
 
Last edited:

printf("AT+CMGS=+33665343539\r");
is the problem

correct format : AT+CMGS="XXXXXXXXXXX"\r

Dont use "+" and use double quotes before and after the number

Nandhu
 

Replace

Code:
printf("AT+CMGS=+33665343539\r");

with

Code:
printf("AT+CMGS=\"+33665343539\"\r");
 

Okay thank you guys for this answers, it will be verry usefull!! , i go try this :)
For the command of hours i though a command who send the sms and in the sms it's write 10 am for example if you understand what i want to mean and if it possible
thanks
 

Hello ,
i have test with this program : aenvoyer.JPG
but i didn't receive any message
i have a problem with the program?
or i need to initialise my gsm before send a sms ? if yes what are the commands for do this?
when i use the program on the screen i can see on the gsm a red led and a yellow led so it's okay normally no?
 

hello,

The 1rst step is to negociate Baud rate by sending AT command...
then
you must initialise your GSM module at least once .. minimum ..
After parameters can be stored into the module..
i add a LCD2x16 + UART output to follow each step .command and answer .
it is a good way for debuging if init fails.
init must be ok, before to continue ...







this is my init .. 1rst long init in 15 steps ..
. then short init in 5 step..

Code:
void Negocie_Baud_Rate()
{ int i1;
   i1=0;
  test=0;
  UART1_Write_CText(" Negoce baud rate \r\n");
  do
  {
    RAZ_UART2();
    UART2_Write_CText("AT\r");
    Delay_ms(1000);
    if(UART2_DataReady==1)
    {
    if (strstr(buffer2,"OK")>0)
     {
        i1=21;
        test=1;
        UART1_Write_Text(buffer2);
        #ifdef  With_LCD2119
        LCD_Write_CText(2,1,"Negoce baud rate");
        #endif
       }
     }
   Delay_ms(500);
   i1++;
  } while((i1<20) && (test==0));
 }
 


void Send_Cde_display_response(const char* Cde, char B)
{
   RAZ_UART2();
   UART2_Write_CText(Cde); 
 //  RAZ_UART2();
   Delay_ms(3500);
   UART1_Write_Text(buffer2);
  if (B)
  {
   UART1_Write(TAB);
   if(strstr(buffer2,"OK")>0) Step++;
   WordToStr(Step,txt);
    // visu sur LCD
    #ifdef With_LCD2119
    #ifdef Full_Init
   LCD_Write_CText(2,1,"Step : ...../15 ");
   LCD_Write_Text(2,7,txt);
    #else
   LCD_Write_CText(2,1,"Step : ...../ 5 ");
   LCD_Write_Text(2,7,txt);
   #endif
   #endif
   UART1_Write_CText(" Step:");
   UART1_Write_Text(txt);
   UART1_Write(TAB);
  }
   CRLF1();
   //RAZ_UART2();
 }




unsigned int Initialisation_Cdes_GSM2(void)
 {
     //                   1234567890123456
   #ifdef  With_LCD2119
  LCD_Write_CText(1,1,"Init GSM2-Click ");
  #endif
   LD2=1;
   Step=0;
   Drapeaux.Visible=1;

   UART1_Write_CText(" Set PIN code(AT+CPIN=1234) \r\n");  // p 61-62
   Send_Cde_display_response("AT+CPIN=1234\r", Drapeaux.Visible);
   //1
    #ifdef Full_Init
   UART1_Write_CText(" Send Msg type as text mode (AT+CMGF=1)\r\n");
   Send_Cde_display_response("AT+CMGF=1\r", Drapeaux.Visible);   // TXT lmode for messages
   //2
   UART1_Write_CText(" Software Version (AT+CGMR) \r\n");
   Send_Cde_display_response("AT+CGMR\r\n", Drapeaux.Visible);
   //3
   UART1_Write_CText(" IMEI Serial number (AT+CGSN) \r\n");
   Send_Cde_display_response("AT+CGSN\r", Drapeaux.Visible);
   //4
   UART1_Write_CText(" Format de Reponse via libellé (ATV1) \r\n");
   Send_Cde_display_response("ATV1\r", Drapeaux.Visible);
   //5
   UART1_Write_CText(" Select SM (AT+CPMS=\"SM\",\"SM\",\"SM\"  \r\n");
   Send_Cde_display_response("AT+CPMS=\"SM\",\"SM\",\"SM\"\r", Drapeaux.Visible);
   //6
   UART1_Write_CText(" Renvoi SMS sur terminal (AT+CNMI=2,1) \r\n");
   Send_Cde_display_response("AT+CNMI=2,1\r", Drapeaux.Visible);
   //7
   UART1_Write_CText(" Enregistre Numero tel Paul ,en position en SIM 1 (AT+CPBW=1,..)\r\n");
   Send_Cde_display_response("AT+CPBW=1,\"+33689795432\",145,\"Paul\",12,12\r", Drapeaux.Visible);
   //8
   UART1_Write_CText(" Enregistre Numero tel Joelle ,en position en SIM 2 (AT+CPBW=2,..)\r\n");
  Send_Cde_display_response("AT+CPBW=2,\"+33612345678\",145,\"Joelle\",12,12\r", Drapeaux.Visible);
   //9
   UART1_Write_CText(" Query service center.(AT+CSCA?)\r\n");
   Send_Cde_display_response("AT+CSCA?\r", Drapeaux.Visible);
   //10
   UART1_Write_CText(" Never go in SLEEP mode(AT+QSCLK=0) \r\n");
   Send_Cde_display_response("AT+QSCLK=0\r", Drapeaux.Visible);
   //11
   UART1_Write_CText(" Save profile (AT&W)\r\n");
   Send_Cde_display_response("AT&W\r", Drapeaux.Visible);
   //12
   #endif
   
   UART1_Write_CText(" Test si enregistré sur le reseau (AT+CREG?1)\r\n");
   Send_Cde_display_response("AT+CREG?\r", Drapeaux.Visible);
   //13 ou 2
  
  // format : AA//MM/DD,HH:MM:SS+xx     xx= decalage horaire *4   (soit +-48)
  // UART1_Write_CText(" MAJ date et Heure par defaut (AT+CCLK=\"15/10/01,19:05:00+04\")\r\n");
  // Send_Cde_display_response("AT+CCLK=\"15/09/29,16:45:00+04\"\r");

   UART1_Write_CText(" Lecture de date et heure (AT+CCLK?)\r\n");
   Send_Cde_display_response("AT+CCLK?\r", Drapeaux.Visible);
    //14  ou 3
   UART1_Write_CText(" Never go in SLEEP mode(AT+QSCLK=0) \r\n");
   Send_Cde_display_response("AT+QSCLK=0\r", Drapeaux.Visible);
    //15   ou 4
   UART1_Write_CText(" List all UNREAD msg from inbox (AT+CMGL=REC UNREAD)\r\n");
   Send_Cde_display_response("AT+CMGL=\"REC UNREAD\"\r", Drapeaux.Visible);
   //16  ou 5
   Delay_ms(1500);
   UART1_Write_CText(" Phase d'init en ");
    #ifdef  With_LCD2119
   LCD_CLS();
   LCD_Write_CText(1,1,"Phase d'init en ");
   #endif
   WordToStr(Step,txt);
   UART1_Write_Text(txt);
   #ifdef  With_LCD2119
   LCD_RAZ_Ligne(2);
   #endif
   #ifdef Full_Init
   UART1_Write_CText(" pas/16");
   #ifdef  With_LCD2119
   LCD_Write_Text(2,1,txt);
   LCD_Write_CText(2,8," pas /16");
   #endif
   #else
    UART1_Write_CText(" pas/5");     // was 6
    #ifdef  With_LCD2119
    LCD_Write_CText(2,1,"      pas / 5   ");
    LCD_Write_Chr(2,3,Step+48);
    #endif
   #endif
   //CRLF1();
   return(Step);
}
 
Last edited:

Okay, i can see you are french no? you can explain me step by step in message private and explain your program because i don't really understand :x
i understand just you init the baud rate ( speed ) and after you init the gsm with command but it's UART it's not rs 232 no?
 

but it's UART it's not rs 232 no?

if you can't understand what is the UART, and what is RS232 .. you better have to learn mora about that.
before trying to use a GSM..

I don't help someone, wihtout seeing some personal progress.
I gave you some piste to follow without feeback.

UART is the Hardware to serialize the data , and encapsulate it with additional bits : a start bit, optional a parity bit , and a stop bit.
RS232 is a standard protocole with many additional functions and levels.
With MCU we use the minima of the protocole .. the format of transmission. and Define the speed in baud rate..
The UART output level could be 3,3V or 5V .. so need a level translator like MAX232 or 322 to obtain -12V +12V for PC COM..
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top