Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SoftwareSerial.h>
- //SIM800L TX is connected to Arduino D3
- #define SIM800L_TX_PIN 7
- //SIM800L RX is connected to Arduino D2
- #define SIM800L_RX_PIN 6
- //Create software serial object to communicate with SIM800L
- SoftwareSerial serialSIM800L(SIM800L_TX_PIN, SIM800L_RX_PIN);
- void setup() {
- //Begin serial comunication with Arduino and Arduino IDE (Serial Monitor)
- Serial.begin(9600);
- while (!Serial);
- //Being serial communication witj Arduino and SIM800L
- serialSIM800L.begin(9600);
- delay(1000);
- Serial.println("Setup Complete!");
- delay(15000);
- Serial.println("Sending Text...");
- serialSIM800L.print("AT+CMGF=1\r"); // Set the shield to SMS mode
- delay(100);
- serialSIM800L.print("AT+CMGS=\"0551234567\"\r");
- delay(200);
- serialSIM800L.print("This is a message from DAWAER's Arduino!");
- serialSIM800L.print("\r"); //the content of the message
- delay(500);
- serialSIM800L.print((char)26);//the ASCII code of the ctrl+z is 26 (required according to the datasheet)
- delay(100);
- serialSIM800L.println();
- Serial.println("Text Sent.");
- delay(500);
- }
- void loop() {
- //Read SIM800L output (if available) and print it in Arduino IDE Serial Monitor
- if (serialSIM800L.available()) {
- Serial.write(serialSIM800L.read());
- }
- //Read Arduino IDE Serial Monitor inputs (if available) and send them to SIM800L
- if (Serial.available()) {
- serialSIM800L.write(Serial.read());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement