Problem with sim800l sms sending

Hi guys. sorry for the stupid question but i just started working with sim800l and arduino uno. I connected the softwareserial.h library, copied a simple code for sending SMS, and then a problem arose. I send an AT+CMGS command but I can't complete it.
After the line
SIM800.println("AT+CMGS=\"+79111112233\"");
An input field appears. The Hello text from the next line is entered, which is the SMS text. And then I have a problem with sending this same sms. As I understand it, <CTRL + Z> should be sent there, but I don’t understand how to do it correctly. This keyboard shortcut has the ASCII code 26. I tried to add it in many ways but no result. Can anyone give a hint?

#include <SoftwareSerial.h>

SoftwareSerial SIM800(8, 9);        // 8 - RX Arduino (TX SIM800L), 9 - TX Arduino (RX SIM800L)
void setup() {
  Serial.begin(9600);               // Скорость обмена данными с компьютером
  SIM800.begin(9600);               // Скорость обмена данными с модемом
  Serial.println("Start!");
  delay(1000);
  SIM800.println("AT");
  updateSerial();
  SIM800.println("AT+CMGF=1");
  updateSerial();
  SIM800.println("AT+CSCS=\"GSM\"");
  updateSerial();
  SIM800.println("AT");
  updateSerial();
  
  SIM800.println("AT+CMGS=\"+79111112233\"");


  
  updateSerial();
  SIM800.println("Hello");

  delay(100);
  SIM800.write(byte(26));

}

void loop() {  
  updateSerial();
}


void updateSerial()
{
  delay(500);                           // Пауза 500 мс
  while (Serial.available()) 
  {
    SIM800.write(Serial.read());      // Переадресация с последовательного порта SIM800L на последовательный порт Arduino IDE
  }
  while(SIM800.available()) 
  {
    Serial.write(SIM800.read());      // Переадресация c Arduino IDE на последовательный порт SIM800L
  }
}

I solved problem like this.

#include <SoftwareSerial.h>

// Create a SoftwareSerial object for SIM800L
SoftwareSerial sim800l(3, 2);

void setup() {
  // Start the serial communication with your computer
  Serial.begin(9600);

  // Start the serial communication with SIM800L
  sim800l.begin(9600);
  sim800l.println("AT");
  delay(2000);  // Wait for SIM800L to initialize
}

void loop() {
  // Check if a message is received
    // Send a text message
  
    sendMessage("+79111112233", "Hello");
  
  delay(5000);  // Wait for 5 seconds
}

void sendMessage(const String& phoneNumber, const String& message) {
  // Set the SIM800L to text mode
  sim800l.println("AT+CMGF=1");
  delay(1000);

  // Set the recipient phone number
  sim800l.print("AT+CMGS=\"");
  sim800l.print(phoneNumber);
  sim800l.println("\"");
  delay(1000);

  // Send the message
  sim800l.print(message);
  delay(100);

  // Send the Ctrl+Z character (end of message)
  sim800l.write(0x1A);
  delay(10000);
}

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