sim800L mit der Library

Hallo Ihr Lieben,

ich ahabe jetzt fleißig im Forum gelesen und vieles gelernt, dafür VIELEN DANK schonmal :wink:
Mit meinem Halbwissen und den Infos aus dem Forum habe ich es per AT-Commands und dem Sim800L geschafft SMS zu empfangen und zu versenden. ERFOLGREICH!

Da ich jetzt eine etwas aufwendigere Anwendung plane wollte ich anfangen mit der Library
das ganze etwas strukturierter zu gestalten.

Leider habe ich keinen Erfolg und ich finde auch nicht was schief läuft da trotzt DEBUG Option auf aktiv keinerlei Ausgabe auf dem Software Serial kommt und der Code auch nicht das tut was erwartet wird. Er verarbeitet nix eingehendes und sendet auch nix ab.

Ich bin Noob ja ich weiß. ABer wenn einer doch mal erbarmen haben könnte und vielleicht was findet wäre ich sehr dankbar. Ansonsten bitte einfach das Thema ignorieren.

Die Kommentare im Code stammen aus der ursprünglichen Beispielsketch und der Library

Gruß
Tobi

/* 
 *  This library was written by Vittorio Esposito
 *    https://github.com/VittorioEsposito
 *
 *  Designed to work with the GSM Sim800L.
 *
 *  ENG
 *    This library uses SoftwareSerial, you can define RX and TX pins
 *    in the header "Sim800L.h", by default pins are RX=10 and TX=11.
 *    Be sure that GND is connected to arduino too. 
 *    You can also change the RESET_PIN as you prefer.

 *    
 *  Original version by:   Cristian Steib
 *        
 *
*/

#include <Sim800L.h>
#include <SoftwareSerial.h>               

#define RX  2
#define TX  3

Sim800L GSM(RX, TX);

/*
 * In alternative:
 * Sim800L GSM;                       // Use default pinout
 * Sim800L GSM(RX, TX, RESET);        
 * Sim800L GSM(RX, TX, RESET, LED);
 */

String textSms,numberSms;
uint8_t index1;
uint8_t LOCK=5; // unlock the door lock pin
uint8_t BUZZER=6; // buzzer for main door pin
char* text;
char* number;
bool error;           //to catch the response



void setup(){
number = "+49ZENSIERT ;)";
pinMode(LOCK,OUTPUT); 
pinMode(BUZZER,OUTPUT); 
digitalWrite(LOCK,LOW);
digitalWrite(BUZZER,LOW);

    Serial.begin(9600); // only for debug the results . 
    GSM.begin(); // initializate the library. 
    GSM.reset();
    //don't forget to catch the return of the function delAllSms! 
    error=GSM.delAllSms(); //clean memory of sms;
    
}

void loop(){
  String sms = GSM.readString();
    Serial.println(sms);
    
    textSms=GSM.readSms(1); //read the first sms

    
    if (textSms.indexOf("OK")!=-1) //first we need to know if the messege is correct. NOT an ERROR
        {           
        if (textSms.length() > 7)  // optional you can avoid SMS empty
            {
                
                numberSms=GSM.getNumberSms(1);  // Here you have the number
                // for debugin
                Serial.println(numberSms); 
                textSms.toUpperCase();  // set all char to mayus ;)

                if (textSms.indexOf("UNLOCK")!=-1){
                    Serial.println("Schaltbefehl ÖFFNEN an Tür gesendet");
                    digitalWrite(LOCK,1);
                    error=GSM.sendSms(number,"UNLOCKED");
                }
                else if (textSms.indexOf("LOCK")!=-1){
                    Serial.println("Schaltbefehl VERRIEGELN an Tür gesendet");
                    digitalWrite(LOCK,0);
                    error=GSM.sendSms(number,"LOCKED");
                }
                else if (textSms.indexOf("TEST")!=-1){
                    Serial.println("Test OK");
                    digitalWrite(LOCK,1);
                    error=GSM.sendSms(number,"TEST OK");
                }
                else if (textSms.indexOf("BUZZER")!=-1){
                    Serial.println("Schaltbefehl TÜRSUMMER AKTIV gesendet");
                    digitalWrite(BUZZER,1);
                    error=GSM.sendSms(number,"BUZZERON");
                    delay(5000);
                    Serial.println("Schaltbefehl TÜRSUMMER DEAKTIV gesendet");
                    digitalWrite(BUZZER,0);
                    error=GSM.sendSms(number,"BUZZEROFF");
                }
                else{
                    Serial.println("Not Compatible ...sorry.. :D");
                }


            GSM.delAllSms(); //do only if the message is not empty,in other case is not necesary
             //delete all sms..so when receive a new sms always will be in first position
            } 



        }
    }
 

GRR...

Richtig:
https://github.com/vittorioexp/Sim800L-Arduino-Library-revised

Ansonsten herzlich willkommen.

Ich versteh noch nicht Dein Problem. (ja gut, es geht nicht ...)
Und wenn ich in das readsms-example schaue ist dort 4800 als Baudrate drin...
https://github.com/vittorioexp/Sim800L-Arduino-Library-revised/blob/master/examples/readSms/readSms.ino

Wenn Du das Beispiel - das sollte sich unter DATEI-BEISPIELE finden - nimmst und RX und TX anpasst, sollte es funktionieren.
Also eine SMS an das Ding senden muss ausgegeben werden.
Wenn das geht, dann gehts weiter.

Das geht leider auch nicht das Beispiel das ist ja genau der Knackpunkt.
Ok, habe ich die falsche Library? Habe die über die IDE installiert in der Suche. Dann versuche ich mal die aus deinem Link. Danke erstmal

Na Moment...
Also:
Du hast einen Sketch, der geht. Dann häng den mal ran.
Dann hast ne lib installiert... und der Code in #1 ist jetzt der aus einem example der lib?

Der Kommentar verweist auf eine Seite, die ich vesucht habe, die hier nicht aufrufbar ist. Hast Du die Seite probiert?

Ansonsten kann Dir passieren, das sich Deine Pins beissen, wenn die lib z.B. Pin 2 als reset nutzt.

Du musst wissen, woher die lib kommt und wissen, was die macht - sonst wird das nur raten.

Der Code den ich gepostet habe ist der angepasste Beispielcode aus der Library. Der Author hat selber die URL falsch geschrieben in der Example Code file.

Mein Code der geht mit dem Sim800L ist komplett auf AT gestützt und eigenkonstruktion.
Wolle jetzt aber eben mit dem o.g. code das schäner gestalten.

Das hier ist mein eigener funktionierender code:

#include <SoftwareSerial.h>

String Grsp;

SoftwareSerial SIM800(2, 3); // SIM800 TX to D2 / RX to D3

void setup() {
//  Begin Serial Connection
Serial.begin(9600);

// Connect SIM800 to Serial
SIM800.begin(9600);
delay(1000);
Serial.println("Initialisiere Modem ...");
delay(1000);

// Handshake SIM800
SIM800.println("AT");
updateSerial();

// Check netquality
SIM800.println("AT+CSQ");
updateSerial();

// Check if Network is connected
SIM800.println("AT+CREG?");
updateSerial();

// Set Textformat of Messages to plain text
SIM800.println("AT+CMGF=1");
updateSerial();

// Send new SMS directly to Arduino and delete on SIM800
SIM800.println("AT+CNMI=1,2,0,0,0");
updateSerial();
}

void loop() {
  // put your main code here, to run repeatedly:
updateSerial();
}


void updateSerial()
{
  delay(500);
  while (Serial.available()) // Check if Serial is enabled
  {
  SIM800.write(Serial.read()); // Send data from SIM800 to softwareserial port
  }
    while (SIM800.available())
  {
    String sms = SIM800.readString();
    Serial.println(sms);
  }
}

Nur mit der Library wollte ich für mein komplettprojekt das etwas aufwendiger wird als nur eine SMS zu lesen es etwas besser gestelten und darum die library verwenden (hatte erst ohne versucht um die funktionsweise erstmal zu verstehen)

EDIT:
Habe jetzt nochmal die Library complett neu installiert und das simpelste Example genommen (readSms). Es passiert nix. Serial Monitor bleibt entgegen meiner AT-Commands lösung einfach nuer leer. nix.

/* 
 *  This library was written by Vittorio Esposito
 *    https://github.com/VittorioEsposito
 *
 *  Designed to work with the GSM Sim800L.
 *
 *  ENG
 *    This library uses SoftwareSerial, you can define RX and TX pins
 *    in the header "Sim800L.h", by default pins are RX=10 and TX=11.
 *    Be sure that GND is connected to arduino too. 
 *    You can also change the RESET_PIN as you prefer.
 *  
 *  ESP
 *    Esta libreria usa SoftwareSerial, se pueden cambiar los pines de RX y TX
 *    en el archivo header, "Sim800L.h", por defecto los pines vienen configurado en
 *    RX=10 TX=11.  
 *    Tambien se puede cambiar el RESET_PIN por otro que prefiera
 * 
 *  ITA
 *    Questa libreria utilizza la SoftwareSerial, si possono cambiare i pin di RX e TX
 *    dall' intestazione "Sim800L.h", di default essi sono impostati come RX=10 RX=11
 *    Assicurarsi di aver collegato il dispositivo al pin GND di Arduino.
 *    E' anche possibile cambiare il RESET_PIN.
 *
 *
 *   DEFAULT PINOUT: 
 *        _____________________________
 *       |  ARDUINO UNO >>>   Sim800L  |
 *        -----------------------------
 *            GND      >>>   GND
 *        RX  10       >>>   TX    
 *        TX  11       >>>   RX
 *       RESET 2       >>>   RST 
 *                 
 *   POWER SOURCE 4.2V >>> VCC
 *
 *
 *  SOFTWARE SERIAL NOTES:
 *
 *    PINOUT
 *    The library has the following known limitations:
 *    1. If using multiple software serial ports, only one can receive data at a time.
 *    2. Not all pins on the Mega and Mega 2560 support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69).
 *    3. Not all pins on the Leonardo and Micro support change interrupts, so only the following can be used for RX: 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).
 *    4. On Arduino or Genuino 101 the current maximum RX speed is 57600bps
 *    5. On Arduino or Genuino 101 RX doesn't work on Pin 13
 *  
 *    BAUD RATE
 *    Supported baud rates are 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 31250, 38400, 57600, and 115200.
 *
 *
 *  Edited on:  December 24, 2016
 *    Editor:   Vittorio Esposito
 *    
 *  Original version by:   Cristian Steib
 *        
 *
*/

#include <Sim800L.h>
#include <SoftwareSerial.h>               

#define RX  2
#define TX  3
#define RESET 4

Sim800L GSM(RX, TX, RESET);

/*
 * In alternative:
 * Sim800L GSM;                       // Use default pinout
 * Sim800L GSM(RX, TX, RESET);        
 * Sim800L GSM(RX, TX, RESET, LED);
 */
 
/*
 * NOTICE:
 * FOR THIS TO WORK YOU HAVE TO INCREASE RX BUFFER SIZE
 * Open SoftwareSerial.h and change _SS_MAX_RX_BUFF to 256
 *
 */

void setup() {
  Serial.begin(9600);
  GSM.begin(4800);
  GSM.delAllSms(); // this is optional
  while(!GSM.prepareForSmsReceive())
  {
    delay(1000);
  }
}

void loop() {
  byte index = GSM.checkForSMS();
  if(index != 0)
  {
  	Serial.println(GSM.readSms(index));
  }
}

Spoiler: Das mit der Buffegröße habe ich schon gemacht gehabt :wink:

Dann ist es das Gleiche ??
Ändere als erstes Deine Pins, damit Du das Example 1:1 betreiben kannst.

Hast Du gelesen, was in dem Sketch steht?

/*
 * NOTICE:
 * FOR THIS TO WORK YOU HAVE TO INCREASE RX BUFFER SIZE
 * Open SoftwareSerial.h and change _SS_MAX_RX_BUFF to 256
 *
 */

Na denne....

Danke erstmal ich gebe es wohl auf mit der library zu arbeiten und werde mein aufwendigen code wohl beibehalten.
Bit der Library "wacht" mein Sim800 nichtmal auf. Die LED bleibt auch aus.
Wenn ich meine eigenen AT-Commands direkt sende ohne library funktionirt es perfekt :frowning: Ist halt nur sehr aufwendig dann das zu schreiben alles :frowning:

Hab ich versucht.
Mit Library, Mudi schläft weiter. Direkte AT-Commands: Es geht.
Keine Ahnung wo da der Wurm drin ist. Für heute ist schluss

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