Skip to content

Instantly share code, notes, and snippets.

@nguyendung17
Forked from Nsk1107/A6_test.ino
Created September 28, 2018 10:11
Show Gist options
  • Save nguyendung17/213b13aaded35c88eda2d1fad97f3842 to your computer and use it in GitHub Desktop.
Save nguyendung17/213b13aaded35c88eda2d1fad97f3842 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