Skip to content

Instantly share code, notes, and snippets.

@Nsk1107
Created September 27, 2017 16:49
Show Gist options
  • Save Nsk1107/a6cde54c6d4078a9936de8107a07996d to your computer and use it in GitHub Desktop.
Save Nsk1107/a6cde54c6d4078a9936de8107a07996d to your computer and use it in GitHub Desktop.
This simple code can be use to send a text message and make a voice call using AI Thinker A6 GSM/GPRS Module.
#include <SoftwareSerial.h>
SoftwareSerial A6Module(10, 11); //RX,TX
char input='\0';
void setup() {
A6Module.begin(115200);
Serial.begin(9600);
delay(500);
}
void loop()
{
if (Serial.available() > 0) {
input = Serial.read();
}
if (input == 't') {
sendMSM();
input = '\0';
} else if (input == 'c') {
makeCall();
input = '\0';
}
}
void sendMSM() {
A6Module.println("AT+CMGF=1");
delay(2000);
A6Module.print("AT+CMGS=\"94710000000");
A6Module.print(char(34)); // "
A6Module.print(char(13)); // CR
A6Module.print('\r'); // hex equivalent of newline
delay(2000);
A6Module.print("A6 test message");
delay(500);
A6Module.println (char(26)); //ctrl_z
}
void makeCall() {
A6Module.println("ATD+94710000000");
delay(20000);
A6Module.println("ATH"); //end call
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment