Advertisement
rsbelza

ARDUINO + GSM MODULE

Mar 16th, 2023
561
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Arduino 0.79 KB | Source Code | 0 0
  1. void setup() {
  2.   Serial.begin(9600);
  3. }
  4.  
  5. void loop() {
  6.   // Check if data is available from the NodeMCU
  7.   delay(1000);
  8.  
  9.   if (Serial.available()) {
  10.     // Read the incoming data
  11.  
  12.     // Print the incoming data
  13.     String receivedData = Serial.readString();
  14.    
  15.     Serial.print("Received data: ");
  16.     Serial.println(receivedData);
  17.    
  18.  
  19.   // The text of the message to be sent.
  20.   // String receivedData1=receivedData;
  21.   // Serial.print(String(receivedData1));
  22.     Serial.print("\r");
  23.   delay(10000);                  
  24.   Serial.print("AT+CMGF=1\r");    
  25.   delay(1000);
  26.   // PLACE NUMBER TO SEND A SMS TO
  27.   Serial.print("AT+CMGS=\"09171367340\"\r");  
  28.   delay(1000);
  29.   Serial.print(String(receivedData));  
  30.   delay(1000);  
  31.   Serial.write(0x1A);
  32.   delay(5000);
  33.  
  34.   }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement