06-30-2022, 12:52 AM
[Arduino IDE demo source code for KC868-A8S]--#12-KC868-A8S_sms_code
Code:
//code use for KC868-A8S board
const char phone[] = "13100000000"; //replace for your mobile phone number
int data;
String message;
unsigned long int last;
void setup()
{
Serial.begin(115200);
Serial2.begin(115200);
Serial.print("start test");
send_sms("Test message from KinCony KC868-A8S");
}
void loop()
{
check_sms_responce();
}
void send_sms ( String sms)
{
Serial2.print("AT+CMGF=1\r"); //Set text mode
delay(1000);
Serial2.print("AT+CMGS=\""+String(phone)+"\"\r"); //Send message
delay(1000);
Serial2.print(sms);//Text message
Serial2.println((char)0x1A); //Ctrl+Z
}
void check_sms_responce()
{
if(Serial2.available()>0)
{
delay(60);
message="";
while(Serial2.available())
{
message+=(char)Serial2.read();
}
Serial.print(message);
}
}