Hassan Gazal
Junior Member level 3
- Joined
- Apr 6, 2013
- Messages
- 25
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 1,283
- Activity points
- 1,450
can you please check this one and tell me if it's suitable to interface it with 8051 and send AT commands .
**broken link removed**
can you please check also this one it's cheap than the other one , if it is also suitable for me
https://www.sainsmart.com/siemens-tc35-sms-gsm-module-voice-adapter.html
sorry , these modules can send sms for long distance , i mean our mobiles using GSM and you can send a sms to your friend in another city or another country , so these ,modules can do it ???
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 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 An Arduino Leonardo a GSM card Siemens TC 35 A transformer block 5v DC Connections: It is necessary to connect the ground (GND) of the TC35 card to the mass of the Arduino (yellow wire). Then connect the TX port of the TC35 (green wire) to a digital port of the Arduino (here the port 9) card and connect the RX port of the TC35 (blue wire) to the digital port (here 10) map Arduino. ATTENTION: the Leonardo card for RX harbor only pins 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI) can be used. The power of the TC35 should be 5v DC, positive focus. It is necessary to turn on the TC35 card by pressing the left button of the RS232 port, the red LED will flash slowly if everything is ok (valid SIM card) SMS sending Test: Note: The flow rate should be between 9600 Arduino and TC35, AT commands typed without space. The following program allows you to enter a message in the serial monitor then sends. #include <SoftwareSerial.h> #define rxPin 10 #define txPin 9 // set up a new serial port for Leonardo SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin); char recu[150]; // Array for entering message String message=""; //string we're sending int i; void setup() {//--For Leonardo Serial.begin(9600); while (!Serial){ } // set the data rate for the SoftwareSerial port mySerial.begin(9600); delay(5000); Serial.println("Hello, tapez votre SMS en terminant par un point"); } void loop() { i = 0 ; while ( Serial.available()>0 ) {recu[i] = Serial.read(); message += recu[i]; i++; //-- 46 is the Ascii code for "." if (recu[i-1]==46) { Serial.println("Envoi du SMS..."); SendTextMessage(); ShowSerialData(); delay(1000); Serial.println("\r"); //-- Carriage return Serial.println("SMS parti !"); message=""; i=0; } } } ///SendTextMessage() ///this function is to send a sms message void SendTextMessage() { mySerial.print("AT+CMGF=1\r"); //Because we want to send the SMS in text mode delay(1000); mySerial.print("AT+CMGS=\"+336xxxxxxxx\"\r"); delay(1000); mySerial.println(message); mySerial.print("\r"); delay(1000); mySerial.println((char)26);//the ASCII code of the ctrl+z is 26 mySerial.println(); } void ShowSerialData() { while(mySerial.available()!=0) Serial.write(mySerial.read()); } Be careful to read the information from the card, it is necessary to change the size of the receive buffer in file SoftwareSerial.h line # define _SS_MAX_RX_BUFF 1024 / / RX buffer size (here we increased the buffer to 1k). Example of sending commands to the card and read the result. #include <SoftwareSerial.h> SoftwareSerial mySerial(10, 9); char recu[150]; // Array for entering message int i; String message=""; void setup() {//--For Leonardo Serial.begin(9600); while (!Serial){ } mySerial.begin(9600); delay(5000); Serial.println("Started!"); Serial.println("Hello, tapez votre commande en terminant par un point"); //-- Choose SIM memory and show the SMS in MEMORY //-> AT+CPMS="SM". //mySerial.println( "AT+CPMS=\"SM\"" ); //-- Ask for all the SMS //-> AT+CMGL="ALL".// mySerial.println( "AT+CMGL=\"ALL\"" ); //-> AT+CMGR=2. // Read the 2nd message //-> AT+CMGD=2. // Delete the 2nd message //-> AT+CNMI=?. //-- Test received message } void loop() { i = 0 ; while ( Serial.available()>0 ) {recu[i] = Serial.read(); if ((recu[i]!=46)&&(recu[i]!=13)&&(recu[i]!=10)) message += char(recu[i]); i++; if (recu[i-1]==46) { Serial.println("Envoi de la commande ["+message+"]"); SendCmdMessage(); ShowSerialData(); Serial.println("Commande finie,tapez votre commande en terminant par un point"); message=""; i=0; } } } void ShowSerialData() { while(mySerial.available()!=0) { Serial.print(char(mySerial.read())); } } void SendCmdMessage() { mySerial.println(message); delay(1000); } Lighting a LED upon receiving an SMS and erase the SMS: #include <SoftwareSerial.h> SoftwareSerial mySerial(10, 9); char recu[150]; // Array for entering message int i; int dp=0; char c; String message=""; String cmd=""; String cReturn=""; int nReturn=0; int nPremier=0; //--Pin of the LED to turn ON and OFF int ledPin = 5; void setup() {//--For Leonardo Serial.begin(9600); while (!Serial){ } mySerial.begin(9600); delay(5000); Serial.println("Started!"); Serial.println("Hello, Pour commencer taper Envoyer"); message="AT+CPMS=\"SM\""; Serial.println("Envoi de la commande ["+message+"]"); SendCmdMessage(); ShowSerialData(); Serial.println(nReturn); nPremier=nReturn; pinMode( ledPin, OUTPUT ); digitalWrite( ledPin, LOW); //-- Choose SIM memory and show the SMS in MEMORY //-> AT+CPMS="SM". //mySerial.println( "AT+CPMS=\"SM\"" ); //-- Ask for all the SMS //-> AT+CMGL="ALL".// mySerial.println( "AT+CMGL=\"ALL\"" ); //-> AT+CMGR=2. // Read the 2nd message //-> AT+CMGD=2. // Delete the 2nd message //-> AT+CNMI=?. //-- Test received message } void loop() { while ( Serial.available()>0 ) { message="AT+CPMS=\"SM\""; SendCmdMessage(); ShowSerialData(); Serial.print("Nombre de SMS : "); Serial.println(char(nReturn+48)); if (nReturn>nPremier) {Serial.println("Nouveau SMS !"); //nPremier=nReturn-1; Serial.print(nReturn); Serial.print(" "); Serial.println(nPremier); digitalWrite( ledPin, HIGH); delay(1000); //--Read the nReturn message message=""; message=nReturn+message; message="AT+CMGR="+message; Serial.println("Envoi de la commande ["+message+"]"); SendCmdMessage(); ShowSmsData(); delay(1000); //--Delete the nReturn message message=""; message=nReturn+message; message="AT+CMGD="+message; Serial.println("Envoi de la commande ["+message+"]"); SendCmdMessage(); ShowSmsData(); message=""; delay(1000); digitalWrite( ledPin, LOW); } } } void ShowSerialData() { cReturn=""; while(mySerial.available()!=0) { //Serial.print(char(mySerial.read())); c=char(mySerial.read()); switch(dp){ case 1 : if (c==44)///-- Acii code for Comma dp=2; else cmd+=c; break; case 2 : if (cmd!="") { cmd.trim(); //Serial.println("Mem SMS ["+cmd+"]"); cReturn=cmd; if (cReturn.length()==1) {c=cReturn.charAt(0); nReturn=c-0; nReturn=nReturn-48;} else nReturn=0; } dp=0; cmd=""; break; default : if (c==58) //-- Acii code for : dp=1; break; } } } void ShowSmsData() { while(mySerial.available()!=0) { //Serial.print(char(mySerial.read())); c=char(mySerial.read()); switch(dp){ case 1 : if (c==13)///-- Acii code for Return dp=2; else cmd+=c; break; case 2 : if (cmd!="") Serial.println("Mem SMS ["+cmd+"]"); dp=0; cmd=""; break; default : if (c==58) //-- Acii code for : dp=1; break; } } } void SendCmdMessage() { mySerial.println(message); delay(1000); }
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 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 ////////////////////////////////////////////////////// // Delete all SMS in SIM Memory then : // Wait for SMS, if SMS=OK Light PIN 5 // if SMS=OFF light off PIN 5 // if SMS=? give a status (ON or OFF) of PIN 5 // Otherwise return to the SMS sender a message // If the AT command as an error light PIN 3 // If the AT command is ok light PIN 4 /////////////////////////////////////////////////////// #include <SoftwareSerial.h> SoftwareSerial mySerial(10, 9); int dp=0; int i=0; int dpLed=0; char c; String message=""; String Res=""; String TxtSms=""; String NumSms=""; String cReturn=""; int nReturn=0; int nPremier=0; //--Pin of the LEDs int ledPinRel = 5; //-- Led Action Or Relay int ledPinOk = 4; //-- Led OK int ledPinErr = 3; //-- Led Error void setup() { mySerial.begin(9600); delay(5000); //-- SMS in text mode message="AT+CMGF=1"; SendCmdMessage(); ShowSerialData(); //-- Print storage status message="AT+CPMS=\"SM\""; SendCmdMessage(); ExtractSmsNumber(); //--Delete all the SMS for (i=nReturn; i>0; i--) { message=""; message=i+message; message="AT+CMGD="+message; SendCmdMessage(); ShowSerialData(); } //-- Print storage status message="AT+CPMS=\"SM\""; SendCmdMessage(); ExtractSmsNumber(); nPremier=nReturn; //-- Initialize LED PIN pinMode( ledPinRel, OUTPUT ); digitalWrite( ledPinRel, LOW); pinMode( ledPinErr, OUTPUT ); digitalWrite( ledPinErr, LOW); pinMode( ledPinOk, OUTPUT ); digitalWrite( ledPinOk, HIGH); } void loop() { message="AT+CPMS=\"SM\""; SendCmdMessage(); ExtractSmsNumber(); dp=0; if (nReturn>nPremier) {//--Read the nReturn message message=""; message=nReturn+message; message="AT+CMGR="+message; SendCmdMessage(); ShowSmsData(); if (TxtSms=="ON") dp=1; if (TxtSms=="OFF") dp=2; if (TxtSms=="?") dp=3; switch (dp) { case 1 : {digitalWrite( ledPinRel, HIGH); dpLed=1; break;} case 2 : {digitalWrite( ledPinRel, LOW); dpLed=0; break;} case 3 : {if (dpLed==1) message="La LED est ON"; else message="La LED est OFF"; SendSms(); message="AT+CMGD=1"; SendCmdMessage(); ShowSerialData(); break; } default : {message="Erreur, tapez ON, OFF ou ?, merci !"; SendSms(); message="AT+CMGD=1"; SendCmdMessage(); ShowSerialData(); break;} } //--Delete the nReturn message message=""; message=nReturn+message; message="AT+CMGD="+message; SendCmdMessage(); ShowSerialData(); delay(1000); } } void ExtractSmsNumber() {cReturn=""; Res=""; nReturn=1; dp=0; while(mySerial.available()!=0) { c=char(mySerial.read()); //if ((c!=13) && (c!=10)) // Res+=c; switch(dp){ case 1 : if (c==44)///-- Acii code for Comma dp=2; else Res+=c; break; case 2 : if (Res!="") { Res.trim(); cReturn=Res; if (cReturn.length()==1) {c=cReturn.charAt(0); nReturn=c-0; nReturn=nReturn-48;} else nReturn=0; } dp=0; Res=""; break; default : if (c==58) //-- Acii code for : dp=1; break; } } Res.toUpperCase(); if (Res.indexOf("OK")>0) {digitalWrite( ledPinOk, HIGH); digitalWrite( ledPinErr, LOW); } if (Res.indexOf("ERROR")>0) {digitalWrite( ledPinOk, LOW); digitalWrite( ledPinErr, HIGH); } } void ShowSmsData() //-- Read the sender number (NumSms) and the text message (TxtSms) //-- The return code format is : [+CMGR: "REC READ","+336xxxxxxxx",,"13/06/10,22:18:35+08"<CR><LF>Message<CR>] {dp=0; TxtSms=""; NumSms=""; Res=""; while(mySerial.available()!=0) { c=char(mySerial.read()); if ((c!=13) && (c!=10)) Res+=c; if ((c==44) && (dp==0))///-- 44 Ascii code for ',' {//-- Entering Phone Number c=char(mySerial.read()); //-- Reading '"' c=char(mySerial.read()); dp=1;} if ((c==34) && (dp==1))///-- 34 Ascii code for '"' {//-- Leaving Phone Number dp=2;} if ((c==13) && (dp==2))///-- 13 Ascii code for <CR> {//-- Entering Message zone c=char(mySerial.read()); //-- Reading <LF> dp=3;} if ((c==13) && (dp==3))///-- 13 Ascii code for <CR> {//-- Leaving Message zone dp=4;} switch(dp){ case 1 : NumSms+=c; break; case 3 : TxtSms+=c; break; } } TxtSms.toUpperCase(); TxtSms.trim(); Res.toUpperCase(); if (Res.indexOf("OK")>0) {digitalWrite( ledPinOk, HIGH); digitalWrite( ledPinErr, LOW); } if (Res.indexOf("ERROR")>0) {digitalWrite( ledPinOk, LOW); digitalWrite( ledPinErr, HIGH); } } void SendSms() { mySerial.println("AT+CMGS="+NumSms); delay(1000); mySerial.println(message); delay(1000); mySerial.println((char)26);//the ASCII code of the ctrl+z is 26 delay(1000); ShowSerialData(); delay(1000); } void SendCmdMessage() { mySerial.println(message); delay(1000); } void ShowSerialData() {Res=""; while(mySerial.available()!=0) {c=char(mySerial.read()); if ((c!=13) && (c!=10)) Res+=c; } Res.toUpperCase(); if (Res.indexOf("OK")>0) {digitalWrite( ledPinOk, HIGH); digitalWrite( ledPinErr, LOW); } if (Res.indexOf("ERROR")>0) {digitalWrite( ledPinOk, LOW); digitalWrite( ledPinErr, HIGH); } }
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?