SMS senden an die Nummer, von der die SMS kam

Moin :slight_smile:

Programm: SMS wird empfangen und ein Status an diese Nr. zurück gesendet ohne, das das Programm die Nummer vorher kennt. Zweck ist eine Vereinfachung, dass ich nicht immer das Programm ändern muss bzw. im Programm 20 Nummern hinterlegen muss.

Grundsätzlich scheitere ich daran, dass in " " stehende Klartextnummer nicht durch ein char ersetzen kann.

Ich arbeite mit der GSMSimSMS Biblithek, weil ich mit den SoftwareSerial AT Befehlen zwar zuverlässig senden kann, aber das Programm keine SMS empfangt(Beispiel). Mit der Bib. funktioniert beides sehr gut und jede SMS wird gesendet & empfangen.

Das SIM800L arbeitet mit einem Mega2560pro zusammen und das SIM Modul hat selbst einen 2200uf und die Spannungsversorgung des SIM einen 6700uf Kondensator bekommen. Übertrieben, aber es läuft so sehr zuverlässig auf 4v. Das AT-Softwareserial-empfangen Problem zieht sich durch mehrere Projekte mit Nano, ESP32 & originalen Mega2560 und mehreren verschiedenen SIM800L.

  Serial.print("Init SMS... ");
  Serial.println(sms.initSMS()); // Its optional but highly recommended. Some function work with this function.
  delay(200);

//  Serial.print("List Unread SMS... ");
//  Serial.println(sms.list(true)); // Its optional but highly recommended. Some function work with this function.
//  delay(200);
  String number1;
  number1 = "+4915251927860";
  Serial.print("number1= ");
  Serial.println(number1);

char string[] = number1;  
  char buffer[4*sizeof(string)]; //sized for the worst case scenario of each being in the hundreds plus a space between each and a null
  char* buffPtr = buffer;
  
  for(byte i = 0; i < sizeof(string) - 1; i++){
    itoa((int)string[i],buffPtr,10); //convert the next character to a string and store it in the buffer
    buffPtr += strlen(buffPtr); //move on to the position of the null character
    *buffPtr = ' '; //replace with a space
    buffPtr++; //move on ready for next
  }
  buffPtr--; //move back a character to where the final space (' ') is
  *buffPtr = '\0'; //replace it with a null to terminate the string
  Serial.println(buffer);

char numberHex;
numberHex = buffer;
Serial.print("numberHex: ");
Serial.println(numberHex);
  
  Serial.print("SMS to any number... ");
  Serial.println(sms.send(numberHex, "heurika!")); // only use ascii chars please

Mit den obrigen Code habe ich versucht, einen String in ein char ascii zuwandeln und das dann als Nummer zu nehmen.

Im "richtigen" Code kommt die Nummer als

Serial.println(sms.getSenderNo(indexno))

indexno mit +49 statt 0. Ich komme hier klar an meine Codinggrenzen und wahrscheinlich liegt die Lösung für euch klar auf der Hand. Habe schon Stunden versucht das irgendwie zu schaffen.
Kurz gesagt: Die indexno muss dahin von numberHex steht. Wenn ich mit AT & Softwareserial empfangen könnte, könnte ich das Problem selbst lösen - daher der Umweg.

Kann mir da jemande helfen? Habe mehrmals von vorne bekommen & fahre mich immer wieder fest.

Beste Grüße Maik

#include <SoftwareSerial.h>
SoftwareSerial sim800l(8, 9); // 8 - RX Arduino (TX SIM800L), 9 - TX Arduino (RX SIM800L)
String number1 = "+4915251927860";

void SendSMS() {
  Serial.println("Sending SMS...");
  sim800l.print("AT+CMGF=1\r");
  delay(100);
  sim800l.print("AT+CMGS=\"");
  sim800l.print(number1);
  sim800l.print("\"\r");
  delay(300);
  sim800l.print("A letter for test purpose");
  delay(300);
  sim800l.print((char)26);
  delay(300);
  sim800l.println();
  Serial.println("Text Sent.");
  delay(500);
}

void setup() {
  sim800l.begin(9600);
  Serial.begin(9600);
  delay(1000);
  Serial.print("number1= ");
  Serial.println(number1);
  SendSMS();
}

void loop() {
  delay(10);
  if (sim800l.available())Serial.write(sim800l.read());
}
String number1 = "+4915251927860";
char num2[12];

void setup() {
  Serial.begin(9600);

  Serial.print("number1= ");
  Serial.println(number1);
  number1.toCharArray(num2, 12);
  Serial.print("num2= ");
  for (int i = 0; i < 12; i++)if (num2[i] > ' ')Serial.print(num2[i]);
}

void loop() {}

Mein Ziel zusammengefasst:

#include <GSMSimSMS.h>

// You can use any Serial interface. I recommended HardwareSerial. Please use the library with highiest baudrate.
// In examples, i used HardwareSerial. You can change it anymore.

#define RESET_PIN 10 // you can use any pin.

static volatile int num = 0;

GSMSimSMS sms(Serial1, RESET_PIN); // GSMSimSMS inherit from GSMSim. You can use GSMSim methods with it.

void setup() {
  Serial1.begin(115200); // If you dont change module baudrate, it comes with auto baudrate.

  while(!Serial1) {
    ; // wait for module for connect.
  }

  Serial.begin(115200); // Serial for debug...

  // Init module...
  sms.init(); // use for init module. Use it if you dont have any valid reason.

  Serial.print("Set Phone Function... ");
  Serial.println(sms.setPhoneFunc(1));
  delay(1000);

  Serial.print("is Module Registered to Network?... ");
  Serial.println(sms.isRegistered());
  delay(1000);

  Serial.print("Signal Quality... ");
  Serial.println(sms.signalQuality());
  delay(1000);

  Serial.print("Operator Name... ");
  Serial.println(sms.operatorNameFromSim());
  delay(1000);



  Serial.print("Init SMS... ");
  Serial.println(sms.initSMS()); // Its optional but highly recommended. Some function work with this function.
  delay(1000);

  Serial.print("List Unread SMS... ");
  Serial.println(sms.list(true)); // Its optional but highly recommended. Some function work with this function.
  delay(1000);

  
  Serial.print("SMS to any number... ");
  Serial.println(sms.send("+4915251927860", "Selam kardesim, naber?")); // only use ascii chars please
  //delay(1000);

  // For other methods please look at readme.txt file.

  Serial.println("Begin to listen incoming messages...");

}

void loop() {
  
  // Use your Serial interface...
  if(Serial1.available()) {
      String buffer = "";
      buffer = Serial1.readString();
      num = num + 1;
      Serial.print(num);
      Serial.print(". ");
      //Serial.println(buffer);

      /**/
      // This example for how you catch incoming calls.
      if(buffer.indexOf("+CMTI:") != -1) {
        
        Serial.print("SMS Index No... ");
        int indexno = sms.indexFromSerial(buffer);
        Serial.println(indexno);

        Serial.print("Who send the message?...");
        Serial.println(sms.getSenderNo(indexno));

        Serial.print("Read the message... ");
        Serial.println(sms.readFromSerial(buffer));

        Serial.print("Init SMS... ");
        Serial.println(sms.initSMS()); // Its optional but highly recommended. Some function work with this function.

        Serial.print("SMS to any number... ");
        Serial.println(sms.send("HIER SOLL INDEXNO HIN", "2Selam kardesim, naber?")); // only use ascii chars please
        
      } else {
        Serial.println(buffer);
      }
      
  }
  
  // put your main code here, to run repeatedly:
}

ab Zeile 109-

SMS kommt rein und Nummer steht bei Zeile 129 als sms.getSenderNo(indexno) zur Verfügung. Die dort hinterlegte Nummer so in Zeile 138 "HIER SOLL INDEXNO HIN" rein.

Beste Grüße Maik

Es gibt keine Zeile 109

Nachtrag:
(direkt im Code editiert - und mit ganz viel Schmerzen da ein int keine Telefonnummer abbilden kann)

#include <GSMSimSMS.h>

// You can use any Serial interface. I recommended HardwareSerial. Please use the library with highiest baudrate.
// In examples, i used HardwareSerial. You can change it anymore.

#define RESET_PIN 10 // you can use any pin.

static volatile int num = 0;

GSMSimSMS sms(Serial1, RESET_PIN); // GSMSimSMS inherit from GSMSim. You can use GSMSim methods with it.

void setup() {
  Serial1.begin(115200); // If you dont change module baudrate, it comes with auto baudrate.

  while(!Serial1) {
    ; // wait for module for connect.
  }

  Serial.begin(115200); // Serial for debug...

  // Init module...
  sms.init(); // use for init module. Use it if you dont have any valid reason.

  Serial.print("Set Phone Function... ");
  Serial.println(sms.setPhoneFunc(1));
  delay(1000);

  Serial.print("is Module Registered to Network?... ");
  Serial.println(sms.isRegistered());
  delay(1000);

  Serial.print("Signal Quality... ");
  Serial.println(sms.signalQuality());
  delay(1000);

  Serial.print("Operator Name... ");
  Serial.println(sms.operatorNameFromSim());
  delay(1000);



  Serial.print("Init SMS... ");
  Serial.println(sms.initSMS()); // Its optional but highly recommended. Some function work with this function.
  delay(1000);

  Serial.print("List Unread SMS... ");
  Serial.println(sms.list(true)); // Its optional but highly recommended. Some function work with this function.
  delay(1000);

  
  Serial.print("SMS to any number... ");
  Serial.println(sms.send("+4915251927860", "Selam kardesim, naber?")); // only use ascii chars please
  //delay(1000);

  // For other methods please look at readme.txt file.

  Serial.println("Begin to listen incoming messages...");

}

void loop() {
  
  // Use your Serial interface...
  if(Serial1.available()) {
      String buffer = "";
      buffer = Serial1.readString();
      num = num + 1;
      Serial.print(num);
      Serial.print(". ");
      //Serial.println(buffer);

      /**/
      // This example for how you catch incoming calls.
      if(buffer.indexOf("+CMTI:") != -1) {
        
        Serial.print("SMS Index No... ");
        int indexno = sms.indexFromSerial(buffer);
        Serial.println(indexno);

        Serial.print("Who send the message?...");
        Serial.println(sms.getSenderNo(indexno));

        Serial.print("Read the message... ");
        Serial.println(sms.readFromSerial(buffer));

        Serial.print("Init SMS... ");
        Serial.println(sms.initSMS()); // Its optional but highly recommended. Some function work with this function.

        Serial.print("SMS to any number... ");
        char buf[20]={'\0'};
        snprintf(buf, 20, "%i", indexno);
        Serial.println(sms.send(buf)); // only use ascii chars please
        
      } else {
        Serial.println(buffer);
      }
      
  }
  
  // put your main code here, to run repeatedly:
}

Moin :slight_smile:
Danke für eure Antworten.

Bei deinem Code kam diese Fehlermeldung:

...In function 'void loop()':
sketch_jul14b:92:36: error: no matching function for call to 'GSMSimSMS::send(char [20])'
         Serial.println(sms.send(buf)); // only use ascii chars please
                                    ^
...Documents\Arduino\libraries\GSMSim\src/GSMSimSMS.h:81:10: note: candidate: bool GSMSimSMS::send(char*, char*)
     bool send(char* number, char* message);
          ^~~~
...Documents\Arduino\libraries\GSMSim\src/GSMSimSMS.h:81:10: note:   candidate expects 2 arguments, 1 provided
exit status 1
no matching function for call to 'GSMSimSMS::send(char [20])'

Er merkert wieder wegen den ascii chars. Deshalb hab ich oben im Beispiel versucht die indexno in einen String zu packen und dann den String zu ascii zu wandeln. hat auch geklappt, aber danach komm ich auch nicht weiter, weil ich nicht weiß z.b., wie ich den ascii samt leerzeichen weiter mache.

Mit snprintf werde ich mich jetzt mal intensiver auseinandersetzen. Danke. Steh im coden ganz am Anfang.

Beste Grüße Maik

HA!
Die Ausgangslage war falsch interpretiert.
Ich hab mal das Original angeschaut:

  Serial.println(sms.send("xxxxxxxxxxxx", "Selam kardesim, naber?")); // only use ascii chars please

Das Ding ist, das da zwei Parameter übergeben werden und das nicht ein Satz ist.

Also die Zeile berichtigen und nach buf ein Komma und einen Text.

        Serial.println(sms.send(buf, "einenText")); // only use ascii chars please

Trotzdem glaube ich daran, das in buf nicht das steht, was Du erwartest und Dein Code noch immer keine Zeile 109 hat.

Tatsächlich hatte ich mich im Programmfenster geirrt. Hab mittlerweile so viele offen, dass ich da durcheinander komme.

Die 109 ist jetzt die 61. Die Beschreibungen zum indexno stimmen aber. Bei dem Code den ich hier gepostet habe, fehlt oben nur die Beschreibung des Codes. Das ist der Beispielcode vom GSMSim_SMS.

Ändert leider nichts. :\

....In function 'void loop()':
sketch_jul14b:92:36: error: no matching function for call to 'GSMSimSMS::send(char [20])'
         Serial.println(sms.send(buf), "geschafft"); // only use ascii chars please
                                    ^
...Documents\Arduino\libraries\GSMSim\src/GSMSimSMS.h:81:10: note: candidate: bool GSMSimSMS::send(char*, char*)
     bool send(char* number, char* message);
          ^~~~
...Documents\Arduino\libraries\GSMSim\src/GSMSimSMS.h:81:10: note:   candidate expects 2 arguments, 1 provided
exit status 1
no matching function for call to 'GSMSimSMS::send(char [20])'

Habe mal den buf im Monitor ausgelesen und den Fehlerbereich weg geklammert und er schreibt bei buf= 26,

#include <GSMSimSMS.h>

// You can use any Serial interface. I recommended HardwareSerial. Please use the library with highiest baudrate.
// In examples, i used HardwareSerial. You can change it anymore.

#define RESET_PIN 10 // you can use any pin.

static volatile int num = 0;

GSMSimSMS sms(Serial1, RESET_PIN); // GSMSimSMS inherit from GSMSim. You can use GSMSim methods with it.

void setup() {
  Serial1.begin(115200); // If you dont change module baudrate, it comes with auto baudrate.

  while(!Serial1) {
    ; // wait for module for connect.
  }

  Serial.begin(115200); // Serial for debug...

  // Init module...
  sms.init(); // use for init module. Use it if you dont have any valid reason.

  Serial.print("Set Phone Function... ");
  Serial.println(sms.setPhoneFunc(1));
  delay(1000);

  Serial.print("is Module Registered to Network?... ");
  Serial.println(sms.isRegistered());
  delay(1000);

  Serial.print("Signal Quality... ");
  Serial.println(sms.signalQuality());
  delay(1000);

  Serial.print("Operator Name... ");
  Serial.println(sms.operatorNameFromSim());
  delay(1000);



  Serial.print("Init SMS... ");
  Serial.println(sms.initSMS()); // Its optional but highly recommended. Some function work with this function.
  delay(1000);

  Serial.print("List Unread SMS... ");
  Serial.println(sms.list(true)); // Its optional but highly recommended. Some function work with this function.
  delay(1000);

  
  Serial.print("SMS to any number... ");
  Serial.println(sms.send("+4915251927860", "Selam kardesim, naber?")); // only use ascii chars please
  //delay(1000);

  // For other methods please look at readme.txt file.

  Serial.println("Begin to listen incoming messages...");

}

void loop() {
  
  // Use your Serial interface...
  if(Serial1.available()) {
      String buffer = "";
      buffer = Serial1.readString();
      num = num + 1;
      Serial.print(num);
      Serial.print(". ");
      //Serial.println(buffer);

      /**/
      // This example for how you catch incoming calls.
      if(buffer.indexOf("+CMTI:") != -1) {
        
        Serial.print("SMS Index No... ");
        int indexno = sms.indexFromSerial(buffer);
        Serial.println(indexno);

        Serial.print("Who send the message?...");
        Serial.println(sms.getSenderNo(indexno));

        Serial.print("Read the message... ");
        Serial.println(sms.readFromSerial(buffer));

        Serial.print("Init SMS... ");
        Serial.println(sms.initSMS()); // Its optional but highly recommended. Some function work with this function.

        Serial.println("SMS to any number... ");
        char buf[20]={'\0'};
        snprintf(buf, 20, "%i", indexno);
//        Serial.println(sms.send(buf), "geschafft"); // only use ascii chars please
        Serial.print("buf= ");
        Serial.println(buf);        
      } else {
        Serial.println(buffer);
      }
      
  }
  
  // put your main code here, to run repeatedly:
}

Hier der Serielle Monitor ab dem Moment, ab dem er eine SMS bekommt:

21:59:08.636 -> Begin to listen incoming messages...
21:59:25.003 -> 1. SMS Index No... 26
21:59:25.003 -> Who send the message?...+4915251927860
21:59:26.027 -> Read the message... FOLDER:INCOMING|STATUS:UNREAD|PHONENO:+4915251927860|DATETIME:23/07/14,21:59:17+08|MESSAGE:kop
21:59:27.010 -> Init SMS... 1
21:59:31.027 -> SMS to any number... 
21:59:31.027 -> buf= 26

So ähnlich hatte ich das mit ASCII auch schon. Der sah z.b. so aus 63 32 43 usw. Da hatte ich auch nur eine Zahl für das + raus bekommen.

btw. die Nummer steht auch auf meinem Auto bzw. im Internet ^^

Beste Grüße Maik

Das ist das, was ich Dir geschrieben habe!
Du willst nicht den Index -> hier 26, sondern die Nummer, die sich dahinter verbirgt.

Also muss die auch irgendwie da raus kommen.
Das wäre mein Ansatz:


        Serial.print("SMS to any number... ");
        Serial.println(sms.send(sms.getSenderNo(indexno), "MeinText")); // only use ascii chars please

Tausche die 4 Zeilen die ich Dir vorgegeben habe damit aus.

Moin :slight_smile:
Danke für deine Mühen

...In function 'void loop()':
sketch_jul14b:92:69: error: no matching function for call to 'GSMSimSMS::send(String, const char [9])'
         Serial.println(sms.send(sms.getSenderNo(indexno), "MeinText"));
                                                                     ^
...note: candidate: bool GSMSimSMS::send(char*, char*)
     bool send(char* number, char* message);
          ^~~~
...note:   no known conversion for argument 1 from 'String' to 'char*'
exit status 1
no matching function for call to 'GSMSimSMS::send(String, const char [9])'

Auch

        Serial.println(sms.send(sms.getSenderNo(indexno)), "MeinText"); // only use ascii chars please      

funktioniert nicht.

Auch Moin,

aehm.. ich ahne was.
Las mir mal bis Nachmittag Zeit. Muss mich mal mit der lib und den Parametern befassen

Ein String Objekt ist kein Text (char*).
Aber es hat einen. Den bekommt man mit der Funktion c_str()

Wie ichs mir dachte - @michael_x hats ja auch schon angepinnt... Die arbeiten da mit String und ich mit chararray...
Aber gut, bekommt man auch gelöst.
Und dann fallen einem solche Dinger auch noch in die Hände, die schon im Example drin stehen:

/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/examples/GSMSim_SMS/GSMSim_SMS.ino: In function 'void setup()':
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/examples/GSMSim_SMS/GSMSim_SMS.ino:100:67: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   Serial.println(sms.send("xxxxxxxxxxxx", "Selam kardesim, naber?")); // only use ascii chars please
                                                                   ^
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/examples/GSMSim_SMS/GSMSim_SMS.ino:100:67: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

Und in der lib gibts auch einige Schnitzer:

/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimFMRadio.cpp: In member function 'bool GSMSimFMRadio::fmSetVolume(uint8_t)':
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimFMRadio.cpp:178:13: warning: comparison is always false due to limited range of data type [-Wtype-limits]
  if (volume < 0) {
      ~~~~~~~^~~
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimGPRS.cpp: In member function 'String GSMSimGPRS::getIP()':
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimGPRS.cpp:127:23: warning: statement has no effect [-Wunused-value]
    "ERROR:NO_IP_FETCH";
                       ^
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimGPRS.cpp:130:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimSMS.cpp: In member function 'bool GSMSimSMS::initSMS()':
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimSMS.cpp:48:45: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   if(setPreferredSMSStorage("ME", "ME", "ME")) {
                                             ^
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimSMS.cpp:48:45: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimSMS.cpp:48:45: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimSMS.cpp:50:24: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
     if(setCharset("IRA")) {
                        ^
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimSMS.cpp: In member function 'String GSMSimSMS::read(unsigned int)':
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimSMS.cpp:259:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < mesaj.length(); i++) {
                  ~~^~~~~~~~~~~~~~~~
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimSMS.cpp: In member function 'String GSMSimSMS::read(unsigned int, bool)':
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimSMS.cpp:338:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < mesaj.length(); i++) {
                  ~~^~~~~~~~~~~~~~~~
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimHTTP.cpp: In member function 'String GSMSimHTTP::get(String, bool)':
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimHTTP.cpp:193:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimHTTP.cpp: In member function 'String GSMSimHTTP::getWithSSL(String, bool)':
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimHTTP.cpp:375:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimHTTP.cpp: In member function 'String GSMSimHTTP::post(String, String, String, bool)':
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimHTTP.cpp:578:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimHTTP.cpp: In member function 'String GSMSimHTTP::postWithSSL(String, String, String, bool)':
/home/user1/arduino-1.8.19/portable/sketchbook/libraries/GSMSim-master/src/GSMSimHTTP.cpp:793:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^

Aber versuchs mal mit dem Code:

#include <GSMSimSMS.h>

// You can use any Serial interface. I recommended HardwareSerial. Please use the library with highiest baudrate.
// In examples, i used HardwareSerial. You can change it anymore.

#define RESET_PIN 10 // you can use any pin.

static volatile int num = 0;

GSMSimSMS sms(Serial1, RESET_PIN); // GSMSimSMS inherit from GSMSim. You can use GSMSim methods with it.

void setup()
{
  Serial1.begin(115200); // If you dont change module baudrate, it comes with auto baudrate.
  while (!Serial1)
  {
    ; // wait for module for connect.
  }
  Serial.begin(115200); // Serial for debug...
  // Init module...
  sms.init(); // use for init module. Use it if you dont have any valid reason.
  Serial.print(F("Set Phone Function... "));
  Serial.println(sms.setPhoneFunc(1));
  delay(1000);
  Serial.print(F("is Module Registered to Network?... "));
  Serial.println(sms.isRegistered());
  delay(1000);
  Serial.print(F("Signal Quality... "));
  Serial.println(sms.signalQuality());
  delay(1000);
  Serial.print(F("Operator Name... "));
  Serial.println(sms.operatorNameFromSim());
  delay(1000);
  Serial.print(F("Init SMS... "));
  Serial.println(sms.initSMS()); // Its optional but highly recommended. Some function work with this function.
  delay(1000);
  Serial.print(F("List Unread SMS... "));
  Serial.println(sms.list(true)); // Its optional but highly recommended. Some function work with this function.
  delay(1000);
  Serial.print(F("SMS to any number... "));
  Serial.println(sms.send("+4915251927860", "Selam kardesim, naber?")); // only use ascii chars please
  //delay(1000);
  // For other methods please look at readme.txt file.
  Serial.println(F("Begin to listen incoming messages..."));
}

void loop()
{
  // Use your Serial interface...
  if (Serial1.available())
  {
    String buffer = "";
    buffer = Serial1.readString();
    num = num + 1;
    Serial.print(num);
    Serial.print(". ");
    //Serial.println(buffer);
    /**/
    // This example for how you catch incoming calls.
    if (buffer.indexOf("+CMTI:") != -1)
    {
      Serial.print(F("SMS Index No... "));
      int indexno = sms.indexFromSerial(buffer);
      Serial.println(indexno);
      Serial.print(F("Who send the message?..."));
      Serial.println(sms.getSenderNo(indexno));
      Serial.print(F("Read the message... "));
      Serial.println(sms.readFromSerial(buffer));
      Serial.print(F("Init SMS... "));
      Serial.println(sms.initSMS()); // Its optional but highly recommended. Some function work with this function.
      Serial.print(F("SMS to number: "));
      String content = sms.getSenderNo(indexno);
      Serial.print(content);
      Serial.print(' ');
      Serial.println(sms.send(content.c_str(), "MeinText")); // only use ascii chars please
    }
    else
    {
      Serial.println(buffer);
    }
  }
  // put your main code here, to run repeatedly:
}

DANKE :slight_smile: Es funktioniert

Auf dieser Basis kann ich auch die Nachrichten vom Programm änderbar machen und/oder das ganze am Display im Menü ändern.

Habe wieder viel gelernt!

Das ist Sinn und Zweck des Ganzen :slight_smile:
Noch ein Tipp:
DATEI - VOREINSTELLUNGEN -> dort die ausführlichen Meldungen genau so wie hier aktivieren.
Dann bekommst gleich einiges mehr angezeigt und kannst drauf reagieren.
grafik

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.