Hallo Ihr Lieben,
ich ahabe jetzt fleißig im Forum gelesen und vieles gelernt, dafür VIELEN DANK schonmal
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
}
}
}