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.

[General] GSM SIM800/SIM900A modem for sending temperature to server from Controller

Status
Not open for further replies.

desgin

Full Member level 1
Joined
Apr 7, 2017
Messages
96
Helped
1
Reputation
2
Reaction score
1
Trophy points
8
Activity points
813
Hello All,

I am using PIC16F controller for sending temperature derails to server by GSM Modem
Can anybody help me, how i should start ? I have SIM900 GSM Modem with me.
I know AT commands but i don't know exact procedure.

Thanks in advance !!
 

This is an example of sending GPS data to server. Change gps data with temperature data (string).


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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
sbit NMEA_IntFlag at RC1IF_bit;  // NMEA Library RX Interrupt flag
 
#define baudrate 4800
 
// GSM_GPRS Library RX2 Interrupt flag
sbit GSM_RST at LATD0_bit;
 
unsigned char gsmBuffer[200]; // = "AT+CMGR=156\r\n\r\n+CMGR: "REC READ","p4w4w274",,"2013/01/02 19:16:19+22"\r\nYour Google verification code is 484537;";
unsigned char CopyConst2RamBuff[20];
 
const char response[] = "OK";
const char response2[] = "CONNECT OK";
const char at1[] = "AT\r\n";
const char csq[] = "AT+CSQ\r\n";
const char creg[] = "AT+CREG?\r\n";
const char cgatt[] = "AT+CGATT?\r\n";
const char cstt[] = "AT+CSTT="AIRTELGPRS.COM","",""\r\n";
const char ciicr[] = "AT+CIICR\r\n";
const char cifsr[] = "AT+CIFSR\r\n";
const char cipstart[] = "AT+CIPSTART="TCP","203.197.114.67","6900"\r\n";
const char cipsend[] = "AT+CIPSEND\r\n";
const char cmgf[] = "AT+CMGF=1\r";
const char cmgs[] = "AT+CMGS="";
const char cmgr[] = "AT+CMGR=1\r";
const char cmgd[] = "AT+CMGD=1\r";
const char prompt[] = "> ";
const char err[] = "ERROR";
 
char gpsbuffer[200], nmea[200], tmp[3];
char rcvd = 0, errFlag = 0;
unsigned int i = 0, j = 0;
int szGsmBuff = 200, szGpsBuff = 200;
char CC2RamBuff[30];
char fix[2], noOfSat[3], timeStamp[11], validity[2], currLat[23], NS[2], currLong[23], EW[2], speed[12], trueCourse[6], date[7], dp, temp[23], speedKmph[23];
float deg, minute, sec, fLat, fLong, fSpeedKmph;
unsigned int attemptFlag = 0;
unsigned int buffIndex = 0;
 
 
// Callback function called on reception of NMEA sentence
void NMEA_DataReceived() {
        rcvd = 1;
}
 
//Timer1
//Prescaler 1:8; TMR1 Preload = 3035; Actual Interrupt Time : 100 ms
 
//Place/Copy this part in declaration section
void InitTimer1(){
  T1CON         = 0x31;
  TMR1IF_bit = 0;
  TMR1H        = 0x0B;
  TMR1L        = 0xDB;
  //TMR1IE_bit = 1;
  INTCON = 0xC0;
}
 
 
void Interrupt(){
     if(RC1IF_bit){
          NMEA_IntHandler();
     }
 
     if(RC2IF_bit){
          gsmBuffer[buffIndex++] = UART2_Read();
          gsmBuffer[buffIndex] = '\0';
 
          RC2IF_bit = 0;
     }
 
}
 
void UART2_Write_Special(){
    UART2_Write_Text(";");
}
 
void main() {
 
     ANSELA = 0x00;
     ANSELB = 0x00;
     ANSELC = 0x00;
     ANSELD = 0x00;
     ANSELE = 0x00;
 
     TRISA = 0xFF;
     PORTA = 0x00;
     LATA = 0x00;
     TRISB = 0x00;
     PORTB = 0x00;
     LATB = 0x00;
     TRISC = 0xC0;
     PORTC = 0x00;
     LATC = 0x00;
     TRISD = 0xC0;
     PORTD = 0x00;
     LATD = 0x00;
     TRISE = 0x80;
     PORTE = 0x80;
     LATE = 0x00;
 
     UART1_Init(baudrate);
     Delay_ms(500);
 
     UART2_Init(9600);
     RC2IE_bit = 1;
     Delay_ms(500);
 
     NMEA_Init(&UART1_Read, gsmBuffer, sizeof(gsmBuffer));
     RC1IE_bit = 0;
     INTCON = 0xC0;
 
     GSM_Send_AT_Cmd1(&UART2_Write_Text, gsmBuffer, szGsmBuff, response, &at1, err, CopyConst2RamBuff, 20, 2, &buffIndex, &attemptFlag, &memset, &strstr, &CopyConst2Ram);
 
     /*
     while((strstr(gsmBuffer, "25") == 0) && (strstr(gsmBuffer, "26") == 0) && (strstr(gsmBuffer, "27") == 0)
                      && (strstr(gsmBuffer, "28") == 0) && (strstr(gsmBuffer, "29") == 0) && (strstr(gsmBuffer, "30") == 0)){
               UART2_Write_ConstTxt(&UART2_Write_Text, &CopyConst2Ram, CopyConst2RamBuff, &csq);
               Delay_ms(5000);
               i = 0;
     }
 
     clrbuff(&memset, &gsmBuffer, '\0', 200);
     */
     
     GSM_Send_AT_Cmd1(&UART2_Write_Text, gsmBuffer, szGsmBuff, response, creg, err, CopyConst2RamBuff, 20, 2, &buffIndex, &attemptFlag, &memset, &strstr, &CopyConst2Ram);
     GSM_Send_AT_Cmd1(&UART2_Write_Text, gsmBuffer, szGsmBuff, response, cgatt, err, CopyConst2RamBuff, 20, 2, &buffIndex, &attemptFlag, &memset, &strstr, &CopyConst2Ram);
     GSM_Send_AT_Cmd1(&UART2_Write_Text, gsmBuffer, szGsmBuff, response, cstt, err, CopyConst2RamBuff, 20, 4, &buffIndex, &attemptFlag, &memset, &strstr, &CopyConst2Ram);
     GSM_Send_AT_Cmd1(&UART2_Write_Text, gsmBuffer, szGsmBuff, response, ciicr, err, CopyConst2RamBuff, 20, 5, &buffIndex, &attemptFlag, &memset, &strstr, &CopyConst2Ram);
 
     //while(strstr(gsmBuffer, CopyConst2Ram(CopyConst2RamBuff, response)) == 0){
               UART2_Write_ConstTxt(&UART2_Write_Text, &CopyConst2Ram, CopyConst2RamBuff, &cifsr);
               Delay_ms(5000);
               i = 0;
     //}
     
     clrbuff(&memset, gsmBuffer, '\0', 200);
     clrbuff(&memset, CopyConst2RamBuff, '\0', 20);
     
     while(1){
 
            RC2IE_bit = 0;
            RC1IE_bit = 1;
 
            // wait until valid position is acquired
            while(1){
               if(rcvd) {
                  strcpy(nmea, gsmBuffer);
                  if((NMEA_IsValid(nmea)) && (strstr(nmea, "$GPGGA"))){
                         NMEA_Split(fix, nmea, ',', 6);   // 0 = not fixed, 1 or 2 = fixed
                         if(fix[0] == '1' || fix[0] == '2'){
                            break;                        // position locked, exit here from while(1)
                         }
 
                  }
                  rcvd = 0;
               }
            }
 
            RC1IE_bit = 0;
            rcvd = 0;
 
            NMEA_Split(noOfSat, nmea, ',', 7);
 
            RC1IE_bit = 1;
 
            while(1){
               if(rcvd) {
                  strcpy(nmea, gsmBuffer);
                  if((NMEA_IsValid(nmea)) && (strstr(nmea, "$GPRMC"))){
                         NMEA_Split(validity, nmea, ',', 2);   // 0 = not fixed, 1 or 2 = fixed
                         if(validity[0] == 'A'){
                                break;                        // position locked, exit here from while(1)
                         }
 
                  }
                  rcvd = 0;
               }
            }
 
            RC1IE_bit = 0;
            rcvd = 0;
            RC2IE_bit = 1;
 
            NMEA_Split(timeStamp, nmea, ',', 1);
            NMEA_Split(currLat, nmea, ',', 3);
            NMEA_Split(NS, nmea, ',', 4);
            NMEA_Split(currLong, nmea, ',', 5);
            NMEA_Split(EW, nmea, ',', 6);
            NMEA_Split(speed, nmea, ',', 7);
            NMEA_Split(trueCourse, nmea, ',', 8);
            NMEA_Split(date, nmea, ',', 9);
 
            clrbuff(&memset, nmea, '\0', 200);
            
            i = 0;
            while(currLat[i]){
                    if((currLat[i] >= '0') && (currLat[i] <= '9'))
                    currLat[i] = currLat[i] - 0x30;
                    i++;
            }
 
            i = 0;
            while(currLong[i]){
                    if((currLong[i] >= '0') && (currLong[i] <= '9'))
                    currLong[i] = currLong[i] - 0x30;
                    i++;
            }
 
            deg = currLat[0] * 10.0 + currLat[1];
 
            i = 2;
            while(currLat[i]){
                  if((currLat[i] != '.') && (dp == 0))minute = minute * 10.0 + currLat[i];
                  else  {dp = 1; j = 10;}
 
                  if(dp){
                      minute = minute + (currLat[i] / j);
                      j*10;
                  }
 
                  i++;
            }
            fLat = deg + (minute / 60.0);
            dp = 0;
 
            deg = currLong[0] * 100.0 + currLat[1] * 10.0 + currLong[2];
            i = 3;
            while(currLong[i]){
                  if((currLong[i] != '.') && (dp == 0))minute = minute * 10.0 + currLong[i];
                  else  {dp = 1; j = 10;}
 
                  if(dp){
                      minute = minute + (currLong[i] / j);
                      j*10;
                  }
 
                  i++;
            }
            fLong = (deg + minute / 60.0);
 
            i = 0;
            while(speed[i]){
                  if((speed[i] != '.') && (dp == 0))fSpeedKmph = fSpeedKmph * 10.0 + speed[i];
                  else  {dp = 1; j = 10;}
 
                  if(dp){
                      fSpeedKmph = fSpeedKmph + (speed[i] / j);
                      j*10;
                  }
 
                  i++;
            }
            fSpeedKmph = fSpeedKmph * 1.85;
 
            FloatToStr(fspeedKmph, speedKmph);
            FloatToStr(fLat, currLat);
            FloatToStr(fLong, currLong);
            //2235.0478,N,08824.8603,E
            i = 0;
            
            GSM_Send_AT_Cmd1(&UART2_Write_Text, gsmBuffer, szGsmBuff, response2, cipstart, err, CopyConst2RamBuff, 20, 8, &buffIndex, &attemptFlag, &memset, &strstr, &CopyConst2Ram);
            GSM_Send_AT_Cmd1(&UART2_Write_Text, gsmBuffer, szGsmBuff, prompt, cipsend, err, CopyConst2RamBuff, 20, 2, &buffIndex, &attemptFlag, &memset, &strstr, &CopyConst2Ram);
 
            UART2_Write_Txt(&UART2_Write_Text, fix);
            UART2_Write_Txt(&UART2_Write_Text, noOfSat);
            UART2_Write_Txt(&UART2_Write_Text, validity);
            UART2_Write_Txt(&UART2_Write_Text, timeStamp);
            UART2_Write_Txt(&UART2_Write_Text, currLat);
            UART2_Write_Txt(&UART2_Write_Text, NS);
            UART2_Write_Txt(&UART2_Write_Text, currLong);
            UART2_Write_Txt(&UART2_Write_Text, EW);
            UART2_Write_Txt(&UART2_Write_Text, speedKmph);
            UART2_Write_Txt(&UART2_Write_Text, trueCourse);
            UART2_Write_Txt(&UART2_Write_Text, date);
            UART2_Write(0x1A);
            
 
            i = 0;
            while(strstr(gsmBuffer, "CLOSED") == 0);
            
            clrbuff(&memset, gsmBuffer, '\0', 200);
            clrbuff(&memset, fix, '\0', 2);
            clrbuff(&memset, noOfSat, '\0', 3);
            clrbuff(&memset, validity, '\0', 2);
            clrbuff(&memset, timestamp, '\0', 11);
            clrbuff(&memset, currLat, '\0', 23);
            clrbuff(&memset, currLong, '\0', 23);
            clrbuff(&memset, NS, '\0', 2);
            clrbuff(&memset, EW, '\0', 2);
            clrbuff(&memset, speedKmpH, '\0', 23);
            clrbuff(&memset, trueCourse, '\0', 6);
            clrbuff(&memset, date, '\0', 7);
     }
}

 
  • Like
Reactions: desgin

    desgin

    Points: 2
    Helpful Answer Positive Rating
This is an example of sending GPS data to server. Change gps data with temperature data (string).


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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
sbit NMEA_IntFlag at RC1IF_bit;  // NMEA Library RX Interrupt flag
 
#define baudrate 4800
 
// GSM_GPRS Library RX2 Interrupt flag
sbit GSM_RST at LATD0_bit;
 
unsigned char gsmBuffer[200]; // = "AT+CMGR=156\r\n\r\n+CMGR: "REC READ","p4w4w274",,"2013/01/02 19:16:19+22"\r\nYour Google verification code is 484537;";
unsigned char CopyConst2RamBuff[20];
 
const char response[] = "OK";
const char response2[] = "CONNECT OK";
const char at1[] = "AT\r\n";
const char csq[] = "AT+CSQ\r\n";
const char creg[] = "AT+CREG?\r\n";
const char cgatt[] = "AT+CGATT?\r\n";
const char cstt[] = "AT+CSTT="AIRTELGPRS.COM","",""\r\n";
const char ciicr[] = "AT+CIICR\r\n";
const char cifsr[] = "AT+CIFSR\r\n";
const char cipstart[] = "AT+CIPSTART="TCP","203.197.114.67","6900"\r\n";
const char cipsend[] = "AT+CIPSEND\r\n";
const char cmgf[] = "AT+CMGF=1\r";
const char cmgs[] = "AT+CMGS="";
const char cmgr[] = "AT+CMGR=1\r";
const char cmgd[] = "AT+CMGD=1\r";
const char prompt[] = "> ";
const char err[] = "ERROR";
 
char gpsbuffer[200], nmea[200], tmp[3];
char rcvd = 0, errFlag = 0;
unsigned int i = 0, j = 0;
int szGsmBuff = 200, szGpsBuff = 200;
char CC2RamBuff[30];
char fix[2], noOfSat[3], timeStamp[11], validity[2], currLat[23], NS[2], currLong[23], EW[2], speed[12], trueCourse[6], date[7], dp, temp[23], speedKmph[23];
float deg, minute, sec, fLat, fLong, fSpeedKmph;
unsigned int attemptFlag = 0;
unsigned int buffIndex = 0;
 
 
// Callback function called on reception of NMEA sentence
void NMEA_DataReceived() {
        rcvd = 1;
}
 
//Timer1
//Prescaler 1:8; TMR1 Preload = 3035; Actual Interrupt Time : 100 ms
 
//Place/Copy this part in declaration section
void InitTimer1(){
  T1CON         = 0x31;
  TMR1IF_bit = 0;
  TMR1H        = 0x0B;
  TMR1L        = 0xDB;
  //TMR1IE_bit = 1;
  INTCON = 0xC0;
}
 
 
void Interrupt(){
     if(RC1IF_bit){
          NMEA_IntHandler();
     }
 
     if(RC2IF_bit){
          gsmBuffer[buffIndex++] = UART2_Read();
          gsmBuffer[buffIndex] = '\0';
 
          RC2IF_bit = 0;
     }
 
}
 
void UART2_Write_Special(){
    UART2_Write_Text(";");
}
 
void main() {
 
     ANSELA = 0x00;
     ANSELB = 0x00;
     ANSELC = 0x00;
     ANSELD = 0x00;
     ANSELE = 0x00;
 
     TRISA = 0xFF;
     PORTA = 0x00;
     LATA = 0x00;
     TRISB = 0x00;
     PORTB = 0x00;
     LATB = 0x00;
     TRISC = 0xC0;
     PORTC = 0x00;
     LATC = 0x00;
     TRISD = 0xC0;
     PORTD = 0x00;
     LATD = 0x00;
     TRISE = 0x80;
     PORTE = 0x80;
     LATE = 0x00;
 
     UART1_Init(baudrate);
     Delay_ms(500);
 
     UART2_Init(9600);
     RC2IE_bit = 1;
     Delay_ms(500);
 
     NMEA_Init(&UART1_Read, gsmBuffer, sizeof(gsmBuffer));
     RC1IE_bit = 0;
     INTCON = 0xC0;
 
     GSM_Send_AT_Cmd1(&UART2_Write_Text, gsmBuffer, szGsmBuff, response, &at1, err, CopyConst2RamBuff, 20, 2, &buffIndex, &attemptFlag, &memset, &strstr, &CopyConst2Ram);
 
     /*
     while((strstr(gsmBuffer, "25") == 0) && (strstr(gsmBuffer, "26") == 0) && (strstr(gsmBuffer, "27") == 0)
                      && (strstr(gsmBuffer, "28") == 0) && (strstr(gsmBuffer, "29") == 0) && (strstr(gsmBuffer, "30") == 0)){
               UART2_Write_ConstTxt(&UART2_Write_Text, &CopyConst2Ram, CopyConst2RamBuff, &csq);
               Delay_ms(5000);
               i = 0;
     }
 
     clrbuff(&memset, &gsmBuffer, '\0', 200);
     */
     
     GSM_Send_AT_Cmd1(&UART2_Write_Text, gsmBuffer, szGsmBuff, response, creg, err, CopyConst2RamBuff, 20, 2, &buffIndex, &attemptFlag, &memset, &strstr, &CopyConst2Ram);
     GSM_Send_AT_Cmd1(&UART2_Write_Text, gsmBuffer, szGsmBuff, response, cgatt, err, CopyConst2RamBuff, 20, 2, &buffIndex, &attemptFlag, &memset, &strstr, &CopyConst2Ram);
     GSM_Send_AT_Cmd1(&UART2_Write_Text, gsmBuffer, szGsmBuff, response, cstt, err, CopyConst2RamBuff, 20, 4, &buffIndex, &attemptFlag, &memset, &strstr, &CopyConst2Ram);
     GSM_Send_AT_Cmd1(&UART2_Write_Text, gsmBuffer, szGsmBuff, response, ciicr, err, CopyConst2RamBuff, 20, 5, &buffIndex, &attemptFlag, &memset, &strstr, &CopyConst2Ram);
 
     //while(strstr(gsmBuffer, CopyConst2Ram(CopyConst2RamBuff, response)) == 0){
               UART2_Write_ConstTxt(&UART2_Write_Text, &CopyConst2Ram, CopyConst2RamBuff, &cifsr);
               Delay_ms(5000);
               i = 0;
     //}
     
     clrbuff(&memset, gsmBuffer, '\0', 200);
     clrbuff(&memset, CopyConst2RamBuff, '\0', 20);
     
     while(1){
 
            RC2IE_bit = 0;
            RC1IE_bit = 1;
 
            // wait until valid position is acquired
            while(1){
               if(rcvd) {
                  strcpy(nmea, gsmBuffer);
                  if((NMEA_IsValid(nmea)) && (strstr(nmea, "$GPGGA"))){
                         NMEA_Split(fix, nmea, ',', 6);   // 0 = not fixed, 1 or 2 = fixed
                         if(fix[0] == '1' || fix[0] == '2'){
                            break;                        // position locked, exit here from while(1)
                         }
 
                  }
                  rcvd = 0;
               }
            }
 
            RC1IE_bit = 0;
            rcvd = 0;
 
            NMEA_Split(noOfSat, nmea, ',', 7);
 
            RC1IE_bit = 1;
 
            while(1){
               if(rcvd) {
                  strcpy(nmea, gsmBuffer);
                  if((NMEA_IsValid(nmea)) && (strstr(nmea, "$GPRMC"))){
                         NMEA_Split(validity, nmea, ',', 2);   // 0 = not fixed, 1 or 2 = fixed
                         if(validity[0] == 'A'){
                                break;                        // position locked, exit here from while(1)
                         }
 
                  }
                  rcvd = 0;
               }
            }
 
            RC1IE_bit = 0;
            rcvd = 0;
            RC2IE_bit = 1;
 
            NMEA_Split(timeStamp, nmea, ',', 1);
            NMEA_Split(currLat, nmea, ',', 3);
            NMEA_Split(NS, nmea, ',', 4);
            NMEA_Split(currLong, nmea, ',', 5);
            NMEA_Split(EW, nmea, ',', 6);
            NMEA_Split(speed, nmea, ',', 7);
            NMEA_Split(trueCourse, nmea, ',', 8);
            NMEA_Split(date, nmea, ',', 9);
 
            clrbuff(&memset, nmea, '\0', 200);
            
            i = 0;
            while(currLat[i]){
                    if((currLat[i] >= '0') && (currLat[i] <= '9'))
                    currLat[i] = currLat[i] - 0x30;
                    i++;
            }
 
            i = 0;
            while(currLong[i]){
                    if((currLong[i] >= '0') && (currLong[i] <= '9'))
                    currLong[i] = currLong[i] - 0x30;
                    i++;
            }
 
            deg = currLat[0] * 10.0 + currLat[1];
 
            i = 2;
            while(currLat[i]){
                  if((currLat[i] != '.') && (dp == 0))minute = minute * 10.0 + currLat[i];
                  else  {dp = 1; j = 10;}
 
                  if(dp){
                      minute = minute + (currLat[i] / j);
                      j*10;
                  }
 
                  i++;
            }
            fLat = deg + (minute / 60.0);
            dp = 0;
 
            deg = currLong[0] * 100.0 + currLat[1] * 10.0 + currLong[2];
            i = 3;
            while(currLong[i]){
                  if((currLong[i] != '.') && (dp == 0))minute = minute * 10.0 + currLong[i];
                  else  {dp = 1; j = 10;}
 
                  if(dp){
                      minute = minute + (currLong[i] / j);
                      j*10;
                  }
 
                  i++;
            }
            fLong = (deg + minute / 60.0);
 
            i = 0;
            while(speed[i]){
                  if((speed[i] != '.') && (dp == 0))fSpeedKmph = fSpeedKmph * 10.0 + speed[i];
                  else  {dp = 1; j = 10;}
 
                  if(dp){
                      fSpeedKmph = fSpeedKmph + (speed[i] / j);
                      j*10;
                  }
 
                  i++;
            }
            fSpeedKmph = fSpeedKmph * 1.85;
 
            FloatToStr(fspeedKmph, speedKmph);
            FloatToStr(fLat, currLat);
            FloatToStr(fLong, currLong);
            //2235.0478,N,08824.8603,E
            i = 0;
            
            GSM_Send_AT_Cmd1(&UART2_Write_Text, gsmBuffer, szGsmBuff, response2, cipstart, err, CopyConst2RamBuff, 20, 8, &buffIndex, &attemptFlag, &memset, &strstr, &CopyConst2Ram);
            GSM_Send_AT_Cmd1(&UART2_Write_Text, gsmBuffer, szGsmBuff, prompt, cipsend, err, CopyConst2RamBuff, 20, 2, &buffIndex, &attemptFlag, &memset, &strstr, &CopyConst2Ram);
 
            UART2_Write_Txt(&UART2_Write_Text, fix);
            UART2_Write_Txt(&UART2_Write_Text, noOfSat);
            UART2_Write_Txt(&UART2_Write_Text, validity);
            UART2_Write_Txt(&UART2_Write_Text, timeStamp);
            UART2_Write_Txt(&UART2_Write_Text, currLat);
            UART2_Write_Txt(&UART2_Write_Text, NS);
            UART2_Write_Txt(&UART2_Write_Text, currLong);
            UART2_Write_Txt(&UART2_Write_Text, EW);
            UART2_Write_Txt(&UART2_Write_Text, speedKmph);
            UART2_Write_Txt(&UART2_Write_Text, trueCourse);
            UART2_Write_Txt(&UART2_Write_Text, date);
            UART2_Write(0x1A);
            
 
            i = 0;
            while(strstr(gsmBuffer, "CLOSED") == 0);
            
            clrbuff(&memset, gsmBuffer, '\0', 200);
            clrbuff(&memset, fix, '\0', 2);
            clrbuff(&memset, noOfSat, '\0', 3);
            clrbuff(&memset, validity, '\0', 2);
            clrbuff(&memset, timestamp, '\0', 11);
            clrbuff(&memset, currLat, '\0', 23);
            clrbuff(&memset, currLong, '\0', 23);
            clrbuff(&memset, NS, '\0', 2);
            clrbuff(&memset, EW, '\0', 2);
            clrbuff(&memset, speedKmpH, '\0', 23);
            clrbuff(&memset, trueCourse, '\0', 6);
            clrbuff(&memset, date, '\0', 7);
     }
}


Thank you for your quick reply.
I am new to Embedded and working on pic16f877a.
In my College, First i need to show the FTP File on FTP Server which i made by AT Commands.
Now i want to generate Excel Sheet to server. How it is possible ?
Once check at Hyper terminal i will write code in software tool.
 

If you gave different fields in a string then separate them with commas and save it as .csv file and open it in Excel. It will be tabulated.

I can't help much with PIC16F devices. The older PIC16Fs has very less RAM. I mainly use PIC18F46K22, PIC18F47K40 for the projects. They are cheaper than PIC16Fs and have more RAM and ROM.

If you want to use PIC16F then you can try the newer PIC16F18877.
 
  • Like
Reactions: desgin

    desgin

    Points: 2
    Helpful Answer Positive Rating
If you gave different fields in a string then separate them with commas and save it as .csv file and open it in Excel. It will be tabulated.

I can't help much with PIC16F devices. The older PIC16Fs has very less RAM. I mainly use PIC18F46K22, PIC18F47K40 for the projects. They are cheaper than PIC16Fs and have more RAM and ROM.

If you want to use PIC16F then you can try the newer PIC16F18877.

Ya Thanks a lot, it worked for me in Excel but all datas are filling in rows by comma.
How to fill data in columns ?

And please help me how to make new directory or Folder in FTP Server ?
 

Depending on international settings, default column separator may be "," or ";".
Post a screenshot of your excel sheet and a text view of csv in case you experience any problem.
 
  • Like
Reactions: desgin

    desgin

    Points: 2
    Helpful Answer Positive Rating
Depending on international settings, default column separator may be "," or ";".
Post a screenshot of your excel sheet and a text view of csv in case you experience any problem.

Depending on international settings, default column separator may be "," or ";".
Post a screenshot of your excel sheet and a text view of csv in case you experience any problem.

Thanks for your reply.
Data are displaying in Excel sheet but instead of coming in next line, it's displaying on same line with ;

Time;Temp

Instead of
Time
Temp




Below are my commands which i am using in Docklight Software.


5/9/2017 16:18:34.592 [TX] - AT<CR>

5/9/2017 16:18:34.601 [RX] - AT<CR>
<CR><LF>
OK<CR><LF>

5/9/2017 16:18:47.040 [TX] - AT+SAPBR=3,1,"Contype","GPRS"<CR>

5/9/2017 16:18:47.078 [RX] - AT+SAPBR=3,1,"Contype","GPRS"<CR>
<CR><LF>
OK<CR><LF>
<CR><LF>
Call Ready<CR><LF>

5/9/2017 16:18:48.960 [TX] - AT+SAPBR=3,1,"APN","www"<CR>

5/9/2017 16:18:48.993 [RX] - AT+SAPBR=3,1,"APN","www"<CR>
<CR><LF>
OK<CR><LF>
<CR><LF>
SMS Ready<CR><LF>

5/9/2017 16:18:52.440 [TX] - AT+SAPBR =1,1<CR>

5/9/2017 16:18:52.461 [RX] - AT+SAPBR =1,1<CR>
<CR><LF>
OK<CR><LF>

5/9/2017 16:20:22.872 [TX] - AT+SAPBR=2,1<CR>

5/9/2017 16:20:22.892 [RX] - AT+SAPBR=2,1<CR>
<CR><LF>
+SAPBR: 1,1,"10.32.154.195"<CR><LF>
<CR><LF>
OK<CR><LF>

5/9/2017 16:20:41.264 [TX] - AT+FTPCID=1<CR>

5/9/2017 16:20:41.283 [RX] - AT+FTPCID=1<CR>
<CR><LF>
OK<CR><LF>

5/9/2017 16:20:43.761 [TX] - AT+FTPSERV="ftp.drivehq.com"<CR>

5/9/2017 16:20:43.798 [RX] - AT+FTPSERV="ftp.drivehq.com"<CR>
<CR><LF>
OK<CR><LF>

5/9/2017 16:20:47.289 [TX] - AT+FTPUN="desgin@puneindia.com"<CR>

5/9/2017 16:20:47.335 [RX] - AT+FTPUN="desgin@puneindia.com"<CR>
<CR><LF>
OK<CR><LF>

5/9/2017 16:20:48.641 [TX] - AT+FTPPW="desgin"<CR>

5/9/2017 16:20:48.669 [RX] - AT+FTPPW="desgin"<CR>
<CR><LF>
OK<CR><LF>

5/9/2017 16:20:51.872 [TX] - AT+FTPPUTNAME="india.csv"<CR>

5/9/2017 16:20:51.907 [RX] - AT+FTPPUTNAME="india.csv"<CR>
<CR><LF>
OK<CR><LF>

5/9/2017 16:20:52.666 [TX] - AT+FTPPUTPATH="/"<CR>

5/9/2017 16:20:52.691 [RX] - AT+FTPPUTPATH="/"<CR>
<CR><LF>
OK<CR><LF>

5/9/2017 16:20:56.336 [TX] - AT+FTPPUT=1<CR>

5/9/2017 16:20:56.355 [RX] - AT+FTPPUT=1<CR>
<CR><LF>
OK<CR><LF>
<CR><LF>
+FTPPUT: 1,1,1360<CR><LF>

5/9/2017 16:21:04.337 [TX] - AT+FTPPUT=2,10<CR>

5/9/2017 16:21:04.359 [RX] - AT+FTPPUT=2,10<CR>
<CR><LF>
+FTPPUT: 2,55<CR><LF>

5/9/2017 16:21:07.369 [TX] - Temp;Time <CR>

5/9/2017 16:21:07.439 [RX] - <CR><LF>
OK<CR><LF>
<CR><LF>
+FTPPUT: 1,1,1360<CR><LF>

5/9/2017 16:21:10.233 [TX] - AT+FTPPUT=2,0<CR>

5/9/2017 16:21:10.254 [RX] - AT+FTPPUT=2,0<CR>
<CR><LF>
OK<CR><LF>
<CR><LF>
+FTPPUT: 1,0<CR><LF>
 

";" or "," shifts to next column.

"\n" changes line/row (line feed).
 
  • Like
Reactions: desgin

    desgin

    Points: 2
    Helpful Answer Positive Rating
";" or "," shifts to next column.

"\n" changes line/row (line feed).

Thanks again for the reply.
Ya, I am getting Data (Text) in Column also.
But, Now problem is, I want to send another data in same Excel File in another line/Column (Just like keep on Update)
How that is Possible ?

As per my Heading of this thread, i want to continuous check Temperature and Time.
Where data has to be store by Controller and send to Severer by using GSM Modem.
And at server side i can Download Excel File with updated data.
Please help me!!

Thanks a lot in Advance !!
Desgin
India
 

Hello Guys..

Still i am confused with, how to send data to server by GSM.
Please help me out.

Desgin
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top