Hallo,
ich versuche etwas mit meinen Arduino und dem SIM800L v2 zu basteln. Leider bekomme ich beim Sende der SMS immer einen Fehler:
AT+CMGF=1
ERROR
AT+CMGS="+49172XXXXXXXXX"
ERROR
Ich hoffe mir kann jemand helfen Das Modul ist an 5V angeschlossen, sowie TX und RX ist nach Code richtig angeschlossen. AT Befehle lassen sich ausführen.
Hier mein verwendeter Code:
/* This code works with Sim800L and a push button
Press the button to send a simple SMS/Text to a specified phone number
Refer to www.SurtrTech.com for more details
Arduiono Uno Elego Port 6
16.04.2022
*/
#include <SoftwareSerial.h>
SoftwareSerial sim800l(11, 10); // RX,TX for Arduino and for the module it's TXD RXD, they should be inverted
#define button1 7 //Button pin, on the other pin it's wired with GND
bool button_State; //Button state
void setup()
{
pinMode(button1, INPUT_PULLUP); //The button is always on HIGH level, when pressed it goes LOW
sim800l.begin(9600); //Module baude rate, this is on max, it depends on the version
Serial.begin(9600);
Serial.print("Sketch: "); Serial.println(__FILE__);
Serial.print("Uploaded: "); Serial.println(__DATE__);
Serial.println("Start");
delay(1000);
}
void loop()
{
// AT-Befehle im Monitor ausgeben
while(sim800l.available()) {
Serial.write(sim800l.read());
}
while(Serial.available()) {
sim800l.write(Serial.read());
}
button_State = digitalRead(button1); //We are constantly reading the button State
if (button_State == LOW) { //And if it's pressed
Serial.println("Button pressed"); //Shows this message on the serial monitor
delay(200); //Small delay to avoid detecting the button press many times
SendSMS(); //And this function is called
}
if (sim800l.available()) { //Displays on the serial monitor if there's a communication from the module
Serial.write(sim800l.read());
}
}
void SendSMS()
{
Serial.println("Sending SMS..."); //Show this message on serial monitor
sim800l.print("AT+CMGF=1\r"); //Set the module to SMS mode
delay(100);
sim800l.print("AT+CMGS=\"+49172XXXXXX\"\r"); //Your phone number don't forget to include your country code, example +212123456789"
delay(500);
sim800l.print("SIM800l is working"); //This is the text to send to the phone number, don't make it too long or you have to modify the SoftwareSerial buffer
delay(500);
sim800l.print((char)26);// (required according to the datasheet)
delay(500);
sim800l.println();
Serial.println("Text Sent.");
delay(500);
}