Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SoftwareSerial.h>
- //SIM800L TX is connected to Arduino D7
- #define SIM800L_TX_PIN 7
- //SIM800L RX is connected to Arduino D6
- #define SIM800L_RX_PIN 6
- //Create software serial object to communicate with SIM800L
- SoftwareSerial serialSIM800L(SIM800L_TX_PIN, SIM800L_RX_PIN);
- void setup() {
- Serial.begin(9600);
- //Being serial communication witj Arduino and SIM800L
- serialSIM800L.begin(9600);
- delay(15000);
- Serial.println("Setup Complete!");
- //sendSMSon();
- delay(10000);
- //sendSMSoff();
- sendSMSon();
- }
- void loop() {
- }
- void sendSMSon() {
- Serial.println("Sending Text...");
- serialSIM800L.print("AT+CMGF=1\r"); // Set the shield to SMS mode
- delay(100);
- serialSIM800L.print("AT+CMGS=\"0555541625\"\r");
- delay(200);
- serialSIM800L.print("text here ");
- serialSIM800L.print("Sensor Value:");
- serialSIM800L.print(15);
- serialSIM800L.print(" , Moisture:");
- serialSIM800L.print(15);
- serialSIM800L.print("%");
- 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 sendSMSoff() {
- Serial.println("Sending Text...");
- serialSIM800L.print("AT+CMGF=1\r"); // Set the shield to SMS mode
- delay(100);
- serialSIM800L.print("AT+CMGS=\"0555541625\"\r");
- delay(200);
- serialSIM800L.print("Water Pump is OFF ");
- serialSIM800L.print("Sensor Value:");
- serialSIM800L.print(100);
- serialSIM800L.print(" , Moisture:");
- serialSIM800L.print(100);
- serialSIM800L.print("%");
- 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);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement