Arduino で AT コマンドからの出力をキャプチャするにはどうすればよいですか?
GSMシールド付きのArduino Uno R3を使用しています。私はすべてのATコマンドを持っています(それらはここで見ることができます)。ターミナルを使用して出力を取得すれば、問題なく入力できます。ただし、結果の出力をコードでキャプチャするにはどうすればよいですか? 以下のコードは私が試したことを示していますが、うまくいきません。特に、アナログ入力を取得して結果を印刷しようとする場合。
#include <SoftwareSerial.h>
SoftwareSerial mySerial(7, 8);
void setup()
{
char sensorValue[32] ="";
Serial.begin(9600);
mySerial.begin(9600);
Serial.println("\r");
//Wait for a second while the modem sends an "OK"
delay(1000);
//Because we want to send the SMS in text mode
Serial.println("AT+CMGF=1\r");
delay(1000);
mySerial.println("AT+CADC?"); //Query the analog input for data
Serial.println(Serial.available());
Serial.println(Serial.read()); //Print out result???
//Start accepting the text for the message
//to be sent to the number specified.
//Replace this number with the target mobile number.
Serial.println("AT+CMGS=\"+MSISDN\"\r");
delay(1000);
Serial.println("!"); //The text for the message
delay(1000);
Serial.write(26); //Equivalent to sending Ctrl+Z
}
void loop()
{
/*
if (mySerial.available())
Serial.write(mySerial.read());
if (Serial.available())
mySerial.write(Serial.read());
*/
}
私は出力を取得します:
AT+CMGF=1
AT+CADC? 21 13
また
AT+CMGF=1
AT+CADC? 18 65
アナログ ソースの変更に関係なく