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.

Problem in receiving sms from GSM module

Status
Not open for further replies.

ubuntuman

Newbie level 4
Joined
Nov 15, 2017
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
74
Hey guy i make this piece of code to test the sending and receiving of sms via this gsm module

It is LINKSPIRT a6390 https://linksprite.com/wiki/index.php5?title=ATWIN_Quad-band_GPRS/GSM_Shield_for_Arduino

the code i put is the following to read the received sms


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
//###########################SETTING LCD MODULE###################################################
// LCD module connections
sbit LCD_RS at RB5_bit;
sbit LCD_EN at RB4_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 TRISB5_bit;
sbit LCD_EN_Direction at TRISB4_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
//##############################################################################
//############################################################################################
char initializeGsmModule[] = "AT";
char noEcho[] = "ATE0";
char textMode[] = "AT+CMGF=1";
char charMode[] = "AT+CSCS="GSM"";
char setParametersOfCharMode[] ="AT+CSMP=17,167,0,0";
char sendSMSToThisMobileNumber[]="AT+CMGS="+201124247733"";
char sendAnyReceivedSmsCommand[]="AT+CNMI=2,2,0,0,0";
char deleteAllSmsCommand[]="AT+CMGD=1,4";
char changeGSMBaudRateCommand[]="AT+IPR=9600";
char saveCurrentConfigurationInEEPROMCommand[]="AT&W";
char sendAllReceivedSmsCommand[]="AT+CMGL="ALL"";
char testSMSToSend[]="Congratulations Sir , i am not a real phone . I am ur new product smartX from my creator";
char ctrlPlusZ=0x1A;
char enter=0x0D;
char receivedSmS[50];
char receivedSmSDigitchar[]=".......";
char *receivedDigit;
unsigned int i=0;
unsigned int receivedSmSDigitint=0;
unsigned int toggledDoneFlag=0;
 
//######################################################################################################################################
//##################################### Read Data from GSM Module Using UART Protocol ################################################################################
void ReceiveSmsString(char *stringPointer3)
{
 while(UART1_Data_Ready()==1)
 {
  *stringPointer3=UART1_Read();
  stringPointer3++;
 }
 //Delay_ms(1000);
}
//######################################################################################################################################
//#####################################Send Data to GSM Module Using UART Protocol ################################################################################
void SendStringToModem1(char *stringPointer4)
{
 while(UART1_Tx_Idle()==0){}
 while(*stringPointer4)UART1_Write(*stringPointer4++);
 UART1_Write(enter);
 Delay_ms(100);
}
//######################################################################################################################################
void SendStringToModem2(char *stringPointer5)
{
 while(UART1_Tx_Idle()==0){}
 while(*stringPointer5)UART1_Write(*stringPointer5++);
 UART1_Write(ctrlPlusZ);
 Delay_ms(100);
}
//###############################################################################
//###############################################################################
 
void main()
{
 
 ADCON1=0b00001111;
 CMCON =0b00000111;
//.........................
 TRISA=0;
 TRISD=0;
//.........................
 TRISE.B0=0;
 TRISE.B1=0;
 TRISE.B2=0;
//.........................
 TRISC.B3=1;
 TRISC.B4=1;
//.........................
 LATA=0;
 LATD=0;
 LATE.B0=0;
 LATE.B1=0;
 LATE.B2=0;
//.........................
 UART1_Init(115200);
 Lcd_Init();
 delay_ms(500); 
 SendStringToModem1(initializeGsmModule);
 
 SendStringToModem1(noEcho);
 
 SendStringToModem1(textMode);
 
 SendStringToModem1(charMode);
 
 SendStringToModem1(setParametersOfCharMode);
 
 SendStringToModem1(sendAnyReceivedSmsCommand);
 
 SendStringToModem1(saveCurrentConfigurationInEEPROMCommand);
 
 SendStringToModem1(deleteAllSmsCommand);
 Delay_ms(1000); 
 while(1)
  { 
 
 
    ReceiveSmsString(receivedSmS);
 
    Lcd_Out(1,1,receivedSmS);
 
  }
}



- - - Updated - - -

Just for ur knowledge i test the part of the code who is responsible for sending sms to a phone number and it works and send a valid sms to the give phone number , so where is the wrong stuff in receiving the sms ?
 

i test the part of the code who is responsible for sending sms to a phone number and it works and send a valid sms to the give phone number , so where is the wrong stuff in receiving the sms ?

Taking a glance at your code, it seemed that continuously calling the LCD routine in the data-receiving loop could result in data loss.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top