Skip to content

Instantly share code, notes, and snippets.

@arn-ob
Created December 11, 2018 14:07
Show Gist options
  • Select an option

  • Save arn-ob/bc6c9303641e1429363848b01dfb4a2e to your computer and use it in GitHub Desktop.

Select an option

Save arn-ob/bc6c9303641e1429363848b01dfb4a2e to your computer and use it in GitHub Desktop.
Basic GSM and Arduino Connection
#include <SoftwareSerial.h>
const byte rxPin = 2;
const byte txPin = 3;
SoftwareSerial SIM900(rxPin, txPin);
char msg;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
SIM900.begin(9600);
Serial.println("Smoke Detector Console");
SIM900.print("AT+CMGF=1\r");
delay(100);
SIM900.print("AT+CNMI=2,2,0,0,0\r");
delay(100);
SendMessage();
}
void loop() {
// put your main code here, to run repeatedly:
}
void SendMessage()
{
SIM900.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode
delay(1000); // Delay of 1000 milli seconds or 1 second
SIM900.println("AT+CMGS=\"+88**********\"\r"); // Replace x with mobile number
delay(1000);
SIM900.println("Home on Fire");// The SMS text you want to send
delay(100);
SIM900.println((char)26);// ASCII code of CTRL+Z
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment