| 
	
	|  |  |  
	
		| View previous topic :: View next topic |  
		| Author | Message |  
		| Jody 
 
 
 Joined: 08 Sep 2006
 Posts: 182
 
 
 
			      
 
 | 
			
				| GSM M95 Quectel not sending/receiving SMS |  
				|  Posted: Thu May 19, 2022 6:21 am |   |  
				| 
 |  
				| Hello, I have a M95 Quectel module (Clicker board from MikroE).
 This one: https://www.mikroe.com/gsm-2-click
 And a https://www.mikroe.com/clicker-2-pic18fj where the GSM module is mounted to.
 I have used the code from GABRIEL BARRIOS and I have contact with the module.
 And it was working...and suddenly it stopped. Now I have changed the SIM card (result is the same) and I think that there is some register I am missing to initialize but I just cannot find it.
 So my question is: Is there somebody who has a Init for this module?
 To make anything clear I will post my project (or the Init).
 
 But right now I am pulling my hair!!!!!
 
 Best regards,
 Jody
 |  |  
		|  |  
		| hmmpic 
 
 
 Joined: 09 Mar 2010
 Posts: 314
 Location: Denmark
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Thu May 19, 2022 7:24 am |   |  
				| 
 |  
				| Just some hints... You need to start with a terminal connected, check what is working:
 autobaud AT
 simcard with CPIN
 Signal CSQ
 Reg CREG
 Use the datasheet:-)
 
 When you do the code use the STATUS pin to know what state the module is at.
 When entering commands use returned "OK" or what the datasheet say must be the end of the commands.
 Many just use a delay, but it won't work in the real world. Some commands respond in few ms, and others in many second.
 |  |  
		|  |  
		| dyeatman 
 
 
 Joined: 06 Sep 2003
 Posts: 1968
 Location: Norman, OK
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Thu May 19, 2022 9:24 am |   |  
				| 
 |  
				| What version CCS compiler are you using? Please post the first part of your code up to and including the RS232 initialization lines.
 _________________
 Google and Forum Search are some of your best tools!!!!
 |  |  
		|  |  
		| Jody 
 
 
 Joined: 08 Sep 2006
 Posts: 182
 
 
 
			      
 
 | 
			
				|  |  
				|  Posted: Fri May 20, 2022 12:56 am |   |  
				| 
 |  
				| I can communicate with the M95. Read and write to the module is fine. CREG = 1,1 and sometimes 1,2
 
 I start with a GSM_SMS_init_1() include this function with this post.
 Also include the functions called from that init file.
 And sorry for the long post
 
 
 
  	  | Code: |  	  | void GSM_SMS_init_1(void)
 {
 extern int   gsm_init_error;
 
 gsm2_reset();
 gsm2_module_power();
 gsm2_reset();
 gsm2_module_init();
 
 if(!gsm_init_error)
 {
 //**************************************************************************
 // Check if modem is attached
 //**************************************************************************
 if(Check_COM())
 {
 Clear_buffer();
 fprintf(RS232,"COMMS ARE GOOD\n");
 fprintf(RS232,"MOVING ON...\n");
 delay_ms(500);
 }
 else
 {
 fprintf(RS232,"COMMS FAILED\n");
 delay_ms(500);                     // Delay a maximum of X seconds;
 while(!Check_COM())
 {
 fprintf(RS232,"RETRYING - STUCK IN LOOP\n");
 gsm_init_error =1;
 delay_ms(500);
 }
 fprintf(RS232,"COMMS ARE GOOD\n");
 }
 }
 delay_ms(500);
 //SEND_SMS_RUNNING();
 SET_CREG();
 ARE_WE_SET_CREG();
 //SET_MEM();
 if(!gsm_init_error)
 {
 //**************************************************************************
 // Set Modem to TXT mode
 //**************************************************************************
 fprintf(RS232,"\n\n");
 fprintf(RS232,"SET MODEM TO TXT MODE\n");
 delay_ms(1000);                        // Delay a maximum of X seconds;
 if(SET_PDU())
 {
 Clear_buffer();
 fprintf(RS232,"OK! - MOVING ON...\n");
 delay_ms(500);
 }
 else
 {
 fprintf(RS232,"ERROR - SETTING MODEM TO TXT MODE...\n");
 gsm_init_error =1;
 }
 }
 
 
 if(!gsm_init_error)
 {
 //**************************************************************************
 // Set SMS Alert Message
 //**************************************************************************
 fprintf(RS232,"SETTING SMS ALERT\n");
 delay_ms(500);
 if(SET_CNMI())
 {
 CLEAR_BUFFER();
 fprintf(RS232,"OK! - MOVING ON...\n");
 delay_ms(500);
 }
 else
 {
 fprintf(RS232,"ERROR - STUCK IN LOOP...\n");
 gsm_init_error =1;
 }
 }
 if(!gsm_init_error)
 {
 //**************************************************************************
 // WAIT FOR SMS AND READ
 //**************************************************************************
 fprintf(RS232,"MODEM SETUP IS DONE\n");
 fprintf(RS232,"CLEARING BUFFER...\n");
 Clear_buffer();
 fprintf(RS232,"DONE ---> RUN PROGRAM\n");
 DELAY(1);                           // Delay a maximum of X seconds;
 fprintf(RS232,"\n\n");
 }
 }
 | 
 
 most of this code is from GABRIEL BARRIOS.
 
 
  	  | Code: |  	  | //******************************************************************************
 //                      GSM/SMS CONTROL "Driver"
 //******************************************************************************
 // AUTHOR: GABRIEL BARRIOS
 // DATE: 29/04/2013
 // Panama, Rep. Panama.
 //______________________________________________________________________________
 //
 // This "Driver" contains the _basic_ functions required to succesfully control
 // "something" via SMS.
 // The included delay function waits for a character or times out.
 // Ive included a function to recharge credit to a prepaid sim.
 // Also included is a reply to sms function.
 //
 // YOU NEED TO CLEARLY UNDERSTAND HOW TO ADD NEW COMMANDS
 // There are 3 example commands - I use defines as "pointers" to the commands
 //
 // UPDATE: 06/05/2013
 // Forum user EZFLYR noted the "New Message Indicator" was missing.
 // He also noted that most modules Default with this feature OFF.
 // A new Function SET_CNMI() has been added to correct this.
 //______________________________________________________________________________
 //******************************************************************************
 
 
 //******************************************************************************
 // These defines are for code readability purposes. They must match EXACTLY with:
 //          Strings[][] + SIZE_COMMAND + TOTAL_STRINGS + GET_SMS_COMMAND()
 // Makes it a whole lot easier to add new ones.
 // I have arbitrarily set the max command length to 10 chars, including '\0'.
 // This can be changed with the defines below.
 //******************************************************************************
 //                        (See TOTAL_STRINGS BELOW)
 #DEFINE OK            0          // 1 <-- Required
 #DEFINE CMTI         1          // 2 <-- Required
 #DEFINE ERROR         2          // 3 <-- Required
 #DEFINE EXITO         3          // 4 <-- Untested
 
 #DEFINE Temp1         4          // 5 <-- USER DEFINED
 #DEFINE Temp2         5          // 5 <-- USER DEFINED
 #DEFINE Alarm         6          // 6 <-- USER DEFINED
 #DEFINE Power1         7          // 7 <-- USER DEFINED
 #DEFINE Power2         8          // 8 <-- USER DEFINED
 #DEFINE Info         9          // 9 <-- USER DEFINED
 
 #DEFINE TOTAL_STRINGS   10         // Total number of Searchable strings
 #DEFINE SIZE_COMMAND   10        // Sets the Max command Length including '\0'
 #DEFINE SIZE_BUFFER      160        // Serial Buffer Size
 #DEFINE NULL         '\0'         // Easier to type than '\0'
 //______________________________________________________________________________
 
 
 
 //******************************************************************************
 //                      FUNCTION DECLARATIONS
 //******************************************************************************
 
 #INT_RDA
 void SerialInt();      // Serial ISR used
 
 int1 CHECK_COM();      // Checks Modem comms are OK
 int1 SET_PDU();         // Sets modem to TXT MODE
 int1 SET_MEM();         // Sets the Prefered Message Storage
 int1 SET_CNMI();
 int1 DEL_SMS(int);      // Deletes SMS form memory
 int1 READ_SMS(int);      // Loads SMS onto buffer
 int1 RECHARGE_ACCOUNT();// If using Pre_Paid cards *Might* vary depending on country
 int1 STRING_SEARCH(int);// Searchs for strings or commands
 int1 DELAY(int);      // Delay with Limit
 int GET_SMS_COMMAND();   // Similar to string_search but "simpler" and for user level.
 void CMD_LOAD(int);      // Loads commands to a temp buffer from main "Strings" data base
 void SEND_SMS_POWER();   // Sends an SMS when power fails
 void SEND_SMS_TEMP1();   // Sends an SMS when temperature fails
 void SEND_SMS_RUNNING();// Sends an SMS
 void get_temp_number();    //Get number temperature warning
 void get_power_number();    //Get number power warning
 void get_alarm_temp();      //Get temperature setting
 
 // These are helpfull to have around
 void Clear_buffer();      // Clears the serial buffer
 void Print_buffer();      // Just a serial buffer Print
 //______________________________________________________________________________
 
 
 
 //******************************************************************************
 //          MAIN STRINGS or COMMANDS ARRAY and TEMPORARY COMMAND STORAGE
 //******************************************************************************
 // It is _IMPERATIVE_ that these match the define statements at the top
 //
 //                                              (SEE DEFINES AT TOP)
 const char Strings[TOTAL_STRINGS][SIZE_COMMAND]={
 "OK\0",         // index 0
 "+CMTI\0",      // index 1
 "ERROR\0",      // index 2
 "Exitosa\0",   // index 3
 "Temp1\0",      // index 4
 "Temp2\0",      // index 5
 "Alarm\0",      // index 6
 "Power1\0",      // index 7
 "Power2\0",      // index 8
 "Info\0"};      // index 9
 char Command[SIZE_COMMAND];                     // Temp command buffer
 extern char Receive_String[SIZE_BUFFER];         // Serial Buffer
 extern char tel_temp1[14];
 extern char tel_temp2[14];
 extern char tel_power1[14];
 extern char tel_power2[14];
 extern char tel_info[14];
 extern signed int8 alarm_temp;
 int counter_read = 0x00;                     // Serial Buffer Counter
 
 //______________________________________________________________________________
 //******************************************************************************
 //                      M95 INIT MODULE
 //******************************************************************************
 void gsm2_module_init()
 {
 fprintf(RS232,"INIT THE MODEM\n");
 
 fprintf(GSM,"AT\r");      // Send Attention Command
 delay_ms(500);
 fprintf(GSM,"AT\r");      // Send Attention Command
 delay_ms(500);
 fprintf(GSM,"AT\r");      // Send Attention Command
 delay_ms(500);
 fprintf(GSM,"ATE0\r");      // Send Attention Command
 delay_ms(500);
 fprintf(GSM,"AT+IFC=2,2\r");   // Set data flow control 0,0-> no flow control; 2,2-> RTS,CTS
 delay_ms(500);
 fprintf(GSM,"AT+CMGF=1\r" ); // Select SMS message format 0-> PDU mode 1-> Text mode
 delay_ms(500);
 
 }
 //******************************************************************************
 //                      POWER UP THE M95 MODULEHAVE
 //******************************************************************************
 void gsm2_module_power()
 {
 fprintf(RS232,"SET POWER TO MODEM\n");
 output_high(PIN_D0);
 delay_ms(100);
 while(!input(STAT)); //wachten tot STAT hoog wordt
 output_low(PIN_D0);
 delay_ms(3000);
 output_high(PIN_D0);
 delay_ms(6000);
 }
 
 //******************************************************************************
 //                      RESET THE M95 MODULE
 //******************************************************************************
 void gsm2_reset()
 {
 fprintf(RS232,"RESET THE MODEM\n");
 output_high(PIN_D0);
 while(!input(STAT)); //wachten tot STAT hoog wordt
 delay_ms(100);
 output_low(PIN_D0);
 delay_ms(400);
 output_high(PIN_D0);
 delay_ms(8000);
 }
 
 //******************************************************************************
 //                      HAVE *ALL* THE CODES!!!
 //******************************************************************************
 //                      CHECKS COMMS WITH MODEM
 int1 Check_COM()
 {
 counter_read=0;            // Reset buffer counter
 fprintf(GSM,"AT\r");      // Send Attention Command
 //fprintf(RS232,"AT: %s\n", Receive_String);
 PRINT_BUFFER();
 delay_ms(500);
 counter_read=0;            // Reset buffer counter
 return(String_search(OK));   // Check for OK response
 }
 //______________________________________________________________________________
 //
 //                      REGISTER TO NETWORK
 int1 SET_CREG()
 {
 counter_read=0;               // Reset buffer counter
 fprintf(GSM,"AT+CREG=1\r");      // Register to Network
 PRINT_BUFFER();
 //fprintf(RS232,"AT+CREG=1:  %s\n", Receive_String);
 delay_ms(500);
 counter_read=0;               // Reset buffer counter
 return(STRING_SEARCH(OK));      // Check for OK response
 }
 //______________________________________________________________________________
 //
 //                      Are WE REGISTER TO NETWORK
 int1 ARE_WE_SET_CREG()
 {
 counter_read=0;               // Reset buffer counter
 fprintf(GSM,"AT+CREG?\r");      // Register to Network
 //fprintf(RS232,"AT+CREG?: %s\n", Receive_String);
 PRINT_BUFFER();
 delay_ms(500);
 counter_read=0;               // Reset buffer counter
 return(STRING_SEARCH(OK));      // Check for OK response
 }
 
 //______________________________________________________________________________
 //
 //                      SET MODEM TO TXT MODE
 int1 SET_PDU()
 {
 counter_read=0;               // Reset buffer counter
 fprintf(GSM,"AT+CMGF=1\r");      // Set modem to TXT mode
 //fprintf(RS232,"AT+CMGFG?: %s\n", Receive_String);
 PRINT_BUFFER();
 delay_ms(500);
 counter_read=0;               // Reset buffer counter
 return(STRING_SEARCH(OK));      // Check for OK response
 }
 //______________________________________________________________________________
 //
 //                     SET MESSAGE STORAGE
 int1 SET_MEM()
 {
 counter_read=0;                           // Reset buffer counter
 fprintf(GSM,"AT+CPMS=\"SM\",\"SM\",\"SM\"\r");   // Store in SIM Card
 //fprintf(RS232,"AT+CPMS?: %s\n", Receive_String);
 PRINT_BUFFER();
 delay_ms(500);
 counter_read=0;                           // Reset buffer counter
 return(STRING_SEARCH(OK));                  // Check for OK response
 }
 //______________________________________________________________________________
 //
 //                     SET NEW SMS ALERT MSG
 int1 SET_CNMI()
 {
 counter_read=0;                  // Reset buffer counter
 fprintf(GSM,"AT+CNMI=2,1,2,0,0\r");   //text part of the command.
 //fprintf(RS232,"AT+CNMI?: %s\n", Receive_String);
 PRINT_BUFFER();
 delay_ms(500);
 counter_read=0;                  // Reset buffer counter
 return(STRING_SEARCH(OK));         // Check for OK response
 }
 //______________________________________________________________________________
 
 //______________________________________________________________________________
 //
 //                     LOADS SMS INTO BUFFER
 int1 READ_SMS(int index)            // index' is the memory address/location
 {
 counter_read=0;                  // Reset buffer counter
 fprintf(GSM,"AT+CMGR=%d\r",index);   // Send Read SMS command
 //fprintf(RS232,"AT+CMGR?: %s\n", Receive_String);
 PRINT_BUFFER();
 delay_ms(500);
 counter_read=0;                  // Reset buffer counter
 if(STRING_SEARCH(OK))            // Check for OK response
 return(1);                  //           OR
 if(STRING_SEARCH(ERROR))            // Check for ERROR response
 return(0);
 }
 //______________________________________________________________________________
 //
 //                     DELETES SMS FROM MODEM
 int1 DEL_SMS(int index)               // index' is the memory address/location
 {
 fprintf(GSM,"AT+QMGDA=6\r");   // Send Delete ALL SMS command
 
 counter_read=0;                  // Reset buffer counter
 fprintf(GSM,"AT+CMGD=%d\r",index);   // Send Delete SMS command
 //fprintf(RS232,"AT+CMGD?: %s\n", Receive_String);
 
 delay_ms(500);
 counter_read=0;                  // Reset buffer counter
 if(STRING_SEARCH(OK))            // Check for OK response
 return(1);                  //           OR
 if(STRING_SEARCH(ERROR))            // Check for ERROR response
 return(0);
 }
 //______________________________________________________________________________
 //
 //                           SEND SMS POWER1
 void SEND_SMS_POWER1()
 {
 counter_read=0;
 fprintf(GSM,"AT+CMGS= \"%s\"\r",tel_power1);   // send command and cel #
 delay_ms(500);                           // Delay long enough for modem response
 fprintf(GSM,"Vriezer POWER failed!!\n\r");      // Text to reply
 putchar(0x1A);                           // send Ctrl-z
 delay_ms(500);
 }
 //______________________________________________________________________________
 //
 //                           SEND SMS POWER2
 void SEND_SMS_POWER2()
 {
 counter_read=0;
 fprintf(GSM,"AT+CMGS= \"%s\"\r",tel_power2);   // send command and cel #
 delay_ms(500);                           // Delay long enough for modem response
 fprintf(GSM,"Vriezer POWER failed!!\n\r");      // Text to reply
 putchar(0x1A);                           // send Ctrl-z
 delay_ms(500);
 }
 //______________________________________________________________________________
 //
 //                           SEND SMS TEMP1
 void SEND_SMS_TEMP1()
 {
 counter_read=0;
 fprintf(GSM,"AT+CMGS= \"%s\"\r",tel_temp1);      // send command and cel #
 delay_ms(500);                           // Delay long enough for modem response
 fprintf(GSM,"Vriezer Temp too high!!!\n\r");   // Text to reply
 putchar(0x1A);                           // send Ctrl-z
 delay_ms(500);
 }
 //______________________________________________________________________________
 //
 //                           SEND SMS TEMP2
 void SEND_SMS_TEMP2()
 {
 counter_read=0;
 fprintf(GSM,"AT+CMGS= \"%s\"\r",tel_temp2);      // send command and cel #
 delay_ms(500);                           // Delay long enough for modem response
 fprintf(GSM,"Vriezer Temp too high!!!\n\r");   // Text to reply
 putchar(0x1A);                           // send Ctrl-z
 delay_ms(500);
 }
 //______________________________________________________________________________
 //
 //                           SEND SMS INFO
 void SEND_SMS_INFO()
 {
 counter_read=0;
 fprintf(GSM,"AT+CMGS= \"%s\"\r",tel_info);      // send command and cel #
 delay_ms(500);                           // Delay long enough for modem response
 fprintf(GSM,"Vriezer Temp too high!!!\n\r");   // Text to reply
 putchar(0x1A);                           // send Ctrl-z
 delay_ms(500);
 }
 //______________________________________________________________________________
 //
 //               SEARCHES FOR A SPECIFIC STRING IN BUFFER
 int1 STRING_SEARCH(int index)                  // index' is Strings[index][SIZE_COMMAND]
 {                                       // See defines at top.
 CMD_LOAD(index);                        // Loads into temp array the string to be found
 if(STRSTR(Receive_String,Command)!=NULL)   // Find String or Command in main Buffer
 return(1);                           // Return 1 if found
 else
 return(0);                           // Return 0 if not found.
 }
 //______________________________________________________________________________
 //
 //               LOADS TO TEMP ARRAY THE SEARCHABLE STRING
 void CMD_LOAD(int index)
 {
 int var=0;                                       // temp index for array
 memset(Command,NULL,SIZE_COMMAND);                     // Reset data array index
 while((Strings[index][var]!=NULL)&&(var<SIZE_COMMAND))   // Copy data from main "Strings" to commparing array.
 {
 Command[var]=Strings[index][var];                     // Copy into temp array the strings from Main Database
 var++;                                       // Up index
 }
 }
 //______________________________________________________________________________
 //
 //               SEARCHES TRHOUGH ALL POSSIBLE COMMANDS
 int GET_SMS_COMMAND()
 {
 if(STRING_SEARCH(TEMP1)==1)return(TEMP1);   // Using string_search() goes through
 else                                 // all user defined commands.
 
 if(STRING_SEARCH(TEMP2)==1)return(TEMP2);   // Using string_search() goes through
 else                                 // all user defined commands.
 
 if(STRING_SEARCH(ALARM)==1)return(ALARM);
 else
 
 if(STRING_SEARCH(POWER1)==1)return(POWER1);
 else
 
 if(STRING_SEARCH(POWER2)==1)return(POWER2);
 else
 
 if(STRING_SEARCH(INFO)==1)return(INFO);
 else
 
 return(0);                           // returns zero if nothing found
 }
 //______________________________________________________________________________
 //
 //                     PRINT SERIAL BUFFER
 void PRINT_BUFFER()
 {
 int var=0;                                 // Temp data array index
 while(var<SIZE_BUFFER)                        // print all data array
 {
 fprintf(RS232,"%c-%u, ",Receive_String[var],var);   // print in ASCII content and index
 var++;                                 // Up index
 }
 fprintf(RS232,"\r\n");                        // Send return & new line
 }
 //______________________________________________________________________________
 //
 //                     CLEAR SERIAL BUFFER
 void CLEAR_BUFFER()
 {
 memset(Receive_String,NULL,SIZE_BUFFER);   // Set all elements to NULL
 counter_read=0;                     // Reset index
 }
 //______________________________________________________________________________
 //
 //                         LIMITED DELAY
 int1 DELAY(int Delay_ctr)
 {
 counter_read=0;                     // Reset buffer counter
 while((counter_read==0)&&(Delay_ctr>0))   // stay here until modem responds (X Seconds is arbitrary)
 {
 delay_ms(1000);
 Delay_ctr--;
 }
 if((counter_read==0)&&(Delay_ctr==0))
 return(1);
 if((counter_read==0)&&(Delay_ctr>0))
 return(0);
 }
 //______________________________________________________________________________
 //
 //                  Get the Temperature setting
 //                  and store it in the EEPROM at address: 0x50
 void get_alarm_temp()
 {
 char delimiter[2];
 char *ptr_GSM;
 char param11[14];
 int8 stringlengte;
 int8 stringlengte_max;
 int8 i = 0,p = 0;
 char Receive_Message[20];
 
 stringlengte_max = strlen(Receive_String);// op stringlengte(max) - 16 begint onze string
 stringlengte = stringlengte_max - 10;
 for(i = stringlengte;i < (stringlengte+3);i++)
 {
 Receive_Message[p] = Receive_String[i];
 p++;
 }
 alarm_temp = atol(Receive_Message);
 write_ext_eeprom(0x50,(alarm_temp));// start addres is 0x50
 delay_ms(10);
 }
 
 //______________________________________________________________________________
 //
 //                        Get the phone number to send the Temperature error
 //                  and store it in the EEPROM at address: 0x20...0x29
 void get_temp_number()
 {
 char delimiter[2];
 char *ptr_GSM;
 char param1[14];
 int8 stringlengte;
 int8 stringlengte_max;
 int8 i = 0;
 int teller = 0;
 int eeprom_inhoud;
 char Receive_Message[20];
 
 stringlengte_max = strlen(Receive_String);// op stringlengte(max) - 28 begint onze string
 stringlengte = stringlengte_max - 28;
 for(stringlengte;stringlengte < stringlengte_max;stringlengte++)
 {
 Receive_Message[i] = Receive_String[stringlengte];
 i++;
 }
 
 strcpy(delimiter," ");
 ptr_GSM = strtok(Receive_Message, delimiter);
 ptr_GSM = strtok(0,delimiter);
 strcpy(param1,ptr_GSM);///hier is telefoonnummer bekent
 fprintf(RS232,"\Param1: %s\n",param1);   //Hier het telefoonnummer eruit hengelen
 strcpy(tel_temp1,param1);
 fprintf(RS232,"\Tel_temp: %s\n",tel_temp1);   //Hier het telefoonnummer eruit hengelen
 tel_temp1[0] ='0';
 tel_temp1[10] ='\0';
 
 for(teller = 0;teller <0x0A; teller++)
 {
 write_ext_eeprom((0x20+teller),(tel_temp1[teller]-48));// start addres is 0x20 ascii to hex is -48
 }
 
 for(teller = 0; teller < 0x0A;teller++)//naar RS232 het ontvangen tel nummer
 {
 eeprom_inhoud = read_ext_eeprom((0x20+teller));
 fprintf(RS232,"EEPROM inhoud %d = %d\n",teller,eeprom_inhoud);
 delay_ms(500);
 }
 }
 
 //______________________________________________________________________________
 //
 //                        Get the phone number to send the Temperature error
 //                  and store it in the EEPROM at address: 0x40...0x49
 void get_temp2_number()
 {
 char delimiter[2];
 char *ptr_GSM;
 char param1[14];
 int8 stringlengte;
 int8 stringlengte_max;
 int8 i = 0;
 int teller = 0;
 int eeprom_inhoud;
 char Receive_Message[20];
 
 stringlengte_max = strlen(Receive_String);// op stringlengte(max) - 28 begint onze string
 stringlengte = stringlengte_max - 28;
 for(stringlengte;stringlengte < stringlengte_max;stringlengte++)
 {
 Receive_Message[i] = Receive_String[stringlengte];
 i++;
 }
 
 strcpy(delimiter," ");
 ptr_GSM = strtok(Receive_Message, delimiter);
 ptr_GSM = strtok(0,delimiter);
 strcpy(param1,ptr_GSM);///hier is telefoonnummer bekent
 fprintf(RS232,"\Param1: %s\n",param1);   //Hier het telefoonnummer eruit hengelen
 strcpy(tel_temp2,param1);
 fprintf(RS232,"\Tel_temp: %s\n",tel_temp2);   //Hier het telefoonnummer eruit hengelen
 tel_temp2[0] ='0';
 tel_temp2[10] ='\0';
 
 for(teller = 0;teller <0x0A; teller++)
 {
 write_ext_eeprom((0x40+teller),(tel_temp2[teller]-48));// start addres is 0x40 ascii to hex is -48
 }
 
 for(teller = 0; teller < 0x0A;teller++)//naar RS232 het ontvangen tel nummer
 {
 eeprom_inhoud = read_ext_eeprom((0x40+teller));
 fprintf(RS232,"EEPROM inhoud %d = %d\n",teller,eeprom_inhoud);
 delay_ms(500);
 }
 }
 //______________________________________________________________________________
 //
 //                  Get the phone number to send the Power fail error
 //                  and store it in the EEPROM at address: 0x30...0x39
 void get_power_number()
 {
 char delimiter[2];
 char *ptr_GSM;
 char param12[14];
 int8 stringlengte;
 int8 stringlengte_max;
 int8 i = 0;
 int teller = 0;
 int eeprom_inhoud;
 char Receive_Message[20];
 char position_string;
 
 strcpy(delimiter," ");
 
 position_string = strstr(Receive_String,Command);
 fprintf(RS232,"Positie in string: %s",position_string);
 ptr_GSM = strtok(position_string, delimiter);
 ptr_GSM = strtok(0,delimiter);
 strcpy(tel_power1,ptr_GSM);                  ///hier is telefoonnummer bekent
 fprintf(RS232,"\Tel_power: %s\n",tel_power1);   //Hier het telefoonnummer eruit hengelen
 strcpy(param12,tel_power1);
 tel_power1[0]='0';
 tel_power1[10] ='\0';
 
 for(teller = 0;teller <0x0A; teller++)
 {
 write_ext_eeprom((0x30+teller),(tel_power1[teller]-48));// start addres is 0x30 ascii to hex is -48
 }
 
 for(teller = 0; teller < 0x0A;teller++)//naar RS232 het ontvangen tel nummer
 {
 eeprom_inhoud = read_ext_eeprom((0x30+teller));
 fprintf(RS232,"EEPROM inhoud %d = %d\n",teller,eeprom_inhoud);
 delay_ms(500);
 }
 
 }
 //______________________________________________________________________________
 //
 //                  Get the phone number to send the Power fail error
 //                  and store it in the EEPROM at address: 0x60...0x69
 void get_power2_number()
 {
 char delimiter[2];
 char *ptr_GSM;
 char param12[14];
 int8 stringlengte;
 int8 stringlengte_max;
 int8 i = 0;
 int teller = 0;
 int eeprom_inhoud;
 char Receive_Message[20];
 char position_string;
 
 strcpy(delimiter," ");
 
 position_string = strstr(Receive_String,Command);
 fprintf(RS232,"Positie in string: %s",position_string);
 ptr_GSM = strtok(position_string, delimiter);
 ptr_GSM = strtok(0,delimiter);
 strcpy(tel_power2,ptr_GSM);                  ///hier is telefoonnummer bekent
 fprintf(RS232,"\Tel_power: %s\n",tel_power2);   //Hier het telefoonnummer eruit hengelen
 strcpy(param12,tel_power2);
 tel_power2[0]='0';
 tel_power2[10] ='\0';
 
 for(teller = 0;teller <0x0A; teller++)
 {
 write_ext_eeprom((0x60+teller),(tel_power2[teller]-48));// start addres is 0x60 ascii to hex is -48
 }
 
 for(teller = 0; teller < 0x0A;teller++)//naar RS232 het ontvangen tel nummer
 {
 eeprom_inhoud = read_ext_eeprom((0x30+teller));
 fprintf(RS232,"EEPROM inhoud %d = %d\n",teller,eeprom_inhoud);
 delay_ms(500);
 }
 
 }
 //______________________________________________________________________________________
 //
 //   Reply to the phone number who send the info string and send the info to that number
 //   Info is :   Temp1 number
 //            Temp2 number
 //            Power1 number
 //            Power2 number
 //            Alarm Temp
 //
 void send_info_to_sender()
 {
 char delimiter[4];
 char *ptr_GSM;
 char param12[14];
 int8 stringlengte;
 int8 stringlengte_max;
 int8 i = 0;
 int teller = 0;
 int eeprom_inhoud;
 char Receive_Message[20];
 char position_string[];
 
 strcpy(delimiter,"+31");
 
 position_string = strstr(Receive_String,delimiter);
 //ptr_GSM = strtok(position_string, delimiter);
 ptr_GSM = strtok(0,delimiter);
 strcpy(tel_info,ptr_GSM);                  ///hier is telefoonnummer bekent
 fprintf(RS232,"\Tel_info: %s\n",tel_info);   //Hier het telefoonnummer eruit hengelen
 strcpy(param12,tel_info);
 tel_info[0]='0';
 tel_info[10] ='\0';
 }
 //______________________________________________________________________________
 //
 //                           SEND SMS
 void SEND_SMS_RUNNING()
 {
 char mobie[] = "06xxxxxxxx";
 
 counter_read=0;
 fprintf(GSM,"AT+CMGS= \"%s\"\r",mobie);         // send command and cel #
 delay_ms(1000);                           // Delay long enough for modem response
 fprintf(GSM,"Vriezer monitor RUNNING!!!\n\r");   // Text to reply
 putchar(0x1A);                           // send Ctrl-z
 DELAY(20);                              // Delay a maximum of X seconds
 }
 
 | 
 |  |  
		|  |  
		| hmmpic 
 
 
 Joined: 09 Mar 2010
 Posts: 314
 Location: Denmark
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Fri May 20, 2022 5:30 am |   |  
				| 
 |  
				| My suggestion... 
 Maybe for testing it can work, but not in any production.
 All the code is based on delay() and no change to know what is going on.
 The code doesn't handle CREG right, 1 means reg local net, 5 is ok too, it is reg for roaming. Ex. simcom can be confused and return a 5 where it is a 1. Or you can plug a simcard there must be roaming, 2 is searching....The code is not handling that.
 When sending an SMS it can take up to 90 seconds, most is done <6sec, and the module is not ready for new AT commands. In best case it ignores them, worst case they all be processed after it returns from the sending. Therefore code with delay() is no go. From my view you must make a more stable way to deal with all this.
 Do a receive buffer and do all your lookup from that.
 It is also important to pay attention to the STATUS pin.
 ....
 |  |  
		|  |  
		| Jody 
 
 
 Joined: 08 Sep 2006
 Posts: 182
 
 
 
			      
 
 | 
			
				| GSM M95 Quectel not sending/receiving SMS |  
				|  Posted: Tue May 24, 2022 3:02 am |   |  
				| 
 |  
				| Oke have did some testing: 
 Just connect a USB-? SERIAL to the module.
 And can communicate with the module and here is the communication I have done with the module. It seems to be working but it doesn't want to connect to the network.
 
  	  | Code: |  	  | AT
 OK
 AT
 OK
 AT
 OK
 ATE0
 OK
 AT+IFC=2,2
 OK
 AT+CMGF=1
 OK
 AT+CREG=1
 OK
 AT+CREG?
 +CREG: 1,2
 OK
 AT+CPIN?
 +CPIN: READY
 OK
 AT+CSQ
 +CSQ: 28,0
 OK
 AT+CREG?
 +CREG: 1,2
 OK
 
 | 
 |  |  
		|  |  
		| hmmpic 
 
 
 Joined: 09 Mar 2010
 Posts: 314
 Location: Denmark
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Tue May 24, 2022 9:30 am |   |  
				| 
 |  
				| Module have ok signal, and searching for net (creg 1,2). When searching for net, it is your provider there have the control, you can ask them why your simcard is not getting connected. If using 2G the module will draw about 2,5Amp for the registering to take place. If power drop module typically reset itself...
 |  |  
		|  |  
		|  |  
  
	| 
 
 | You cannot post new topics in this forum You cannot reply to topics in this forum
 You cannot edit your posts in this forum
 You cannot delete your posts in this forum
 You cannot vote in polls in this forum
 
 |  
 Powered by phpBB © 2001, 2005 phpBB Group
 
 |