C++ 将存储在SD卡上的电话号码插入sms发送AT命令Arduino

C++ 将存储在SD卡上的电话号码插入sms发送AT命令Arduino,c++,c,arduino,gsm,C++,C,Arduino,Gsm,当声级阈值激活时,我尝试使用Arduino UNO和SIM800L GSM模块发送SMS消息。我已经能够在所有方面做到这一点,除了一个。我有文本消息要发送到的电话号码存储在SD卡上的CONFIG.BAT文件中,我需要解决的问题是如何将SD卡中的号码添加到AT命令中,该命令指定SMS发送到的电话号码。我目前掌握的代码如下: 以下代码在选择启动设备时调用的函数中,该过程从读取A0引脚上的输出开始,以识别声音何时超过阈值int中设置的音量,然后将引脚13设置为高,然后该过程启动SD卡,检查卡上是否有C

当声级阈值激活时,我尝试使用Arduino UNO和SIM800L GSM模块发送SMS消息。我已经能够在所有方面做到这一点,除了一个。我有文本消息要发送到的电话号码存储在SD卡上的CONFIG.BAT文件中,我需要解决的问题是如何将SD卡中的号码添加到AT命令中,该命令指定SMS发送到的电话号码。我目前掌握的代码如下:

以下代码在选择启动设备时调用的函数中,该过程从读取A0引脚上的输出开始,以识别声音何时超过阈值int中设置的音量,然后将引脚13设置为高,然后该过程启动SD卡,检查卡上是否有CONFIG.BAT,如果没有CONFIG.BAT文件,则通知用户转到设置并设置警报的电话号码。如果CONFIG.BAT确实存在,则进程将继续读取CONFIG.BAT文件的内容。下一步是将sms设置为ASCII格式,然后设置电话号码,然后设置消息内容

void sound_detect(){

  int sensorValue = analogRead(A0);//use A0 to read the electrical signal

  if(sensorValue > thresholdvalue) {

  digitalWrite(ledPin1,HIGH);//if the value read from A0 is larger than 400,then light the LED
  delay(10);
  digitalWrite(ledPin1,LOW);

 Serial.print("Initializing SD card...");

  pinMode(10, OUTPUT);

  if (!SD.begin(SD_CS_PIN)) {
    Serial.println("initialization failed!");
    return;
  }

  Serial.println("initialization done.");  

  if (!SD.exists("CONFIG.DAT")) {

    Serial.println("No Number Exists! Please go to Setup Device to add Number for Alert");

  }else{

  // open the file for reading:
  myFile = SD.open("CONFIG.DAT");

  if (myFile) {

    Serial.println("CONFIG.DAT:");

    // read from the file until there's nothing else in it:
    while (myFile.available()) {

      Serial.write(myFile.read());

    }

      //Serial.println(myFile);    

    // close the file:
    myFile.close();

  } else {

    // if the file didn't open, print an error:
    Serial.println("error opening CONFIG.DAT");

  }

  }


    //Set SMS format to ASCII
  serialSIM800.write("AT+CMGF=1\r\n");
  delay(1000);

  //Send new SMS command and message number
  serialSIM800.write("AT+CMGS=\"+44*************\"\r\n");
  delay(1000);

  //Send SMS content
  serialSIM800.write("TEST SMS NOISE DETECT");
  delay(1000);

  //Send Ctrl+Z / ESC to denote SMS message is complete
  serialSIM800.write((char)26);
  delay(1000);

  Serial.println("SMS Sent!");


  } 

}
我需要有关如何从SD卡获取电话号码的帮助或建议,SD卡保存在这段代码中的“myFile”变量中

while (myFile.available()) {

      Serial.write(myFile.read());

    }
在此处替换AT命令中的电话号码

  //Send new SMS command and message number
  serialSIM800.write("AT+CMGS=\"+44*************\"\r\n");
我已经查看了at命令,看看是否有一种明确的方法可以做到这一点,但没有效果,我尝试将“myFile”变量放在花括号中{myFile}

  //Send new SMS command and message number
  serialSIM800.write("AT+CMGS=\"{myFile}\"\r\n");
但那没用

任何帮助都将不胜感激

在循环()中声明字符串:

Concat从文件中读取的字符:

while (myFile.available()) {

  number.concat(myFile.read());

}
在comand处连接至
的Concat编号:

serialSIM800.write("AT+CMGS=\"+44"+number+"\"\r\n");

这就是我的想法,但是你可以用很多方法来实现它。

我现在已经尝试过了,在代码
serialSIM800.write的行上,调用
'SoftwareSerial::write(StringSumHelper&')
时出现了一个错误:没有匹配函数Serial.println(number)
我可以看到ascii码。我一直在试图找出如何编写AT码,以便它读取ascii码并自动将其读取为电话号码,但我还无法理解或识别该过程。以下是我用于发送SMD的AT码,以下是我用于发送smd:
//将SMS格式设置为ASCII serialSIM800.write(“AT+CMGF=1\r\n”);delay(1000);//发送新的SMS命令和消息编号serialSIM800.write(“AT+CMGS=\“+44”+number+“\”\r\n”);delay(1000);//发送SMS内容serialSIM800.write(“测试SMS噪音检测”);delay(1000);//发送Ctrl+Z/ESC表示SMS消息已完成serialSIM800.write((char)26);delay(1000);Serial.println(“SMS发送!”);
serialSIM800.write("AT+CMGS=\"+44"+number+"\"\r\n");