Advertisement
Guest User

Untitled

a guest
Nov 15th, 2020
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.32 KB | None | 0 0
  1. #include "Sim800l.h"
  2. #include <SoftwareSerial.h>
  3. #include "call.h"
  4. #include <DHT.h>
  5. #include "sms.h"
  6.  
  7. SoftwareSerial mySerial(2, 3); // RX, TX
  8.  
  9. SMSGSM sms;
  10. #define DHTPIN 7  
  11. #define DHTTYPE DHT22  
  12.  
  13. CallGSM call;
  14. boolean started=false;
  15. char sms_text[160];
  16.  
  17. DHT dht(DHTPIN, DHTTYPE);
  18.  
  19. void setup()
  20. {
  21.     dht.begin();
  22.     Serial.begin(9600);
  23.    
  24.     if (gsm.begin(9600))
  25.     {
  26.         Serial.println("\nstatus=READY");
  27.         started=true;
  28.     }
  29.     else
  30.         Serial.println("\nstatus=IDLE");
  31. }
  32.  
  33. void loop()
  34. {
  35.    float humidity, temperature;
  36.    String smsText ="";
  37.  
  38.   switch (call.CallStatus())
  39.   {
  40.     case CALL_NONE: // Nothing is happening
  41.  
  42.       break;
  43.  
  44.     case CALL_INCOM_VOICE : // Yes! Someone is calling us
  45.  
  46.       Serial.println("RECEIVING CALL");
  47.        call.HangUp();
  48.        delay(2000);
  49.        humidity = dht.readHumidity();
  50.        temperature = dht.readTemperature();
  51.        delay(2000);
  52.        smsText = "Temperature: "+String(temperature,1)+"C Humidity: "+String(humidity,1)+"%";
  53.        smsText.toCharArray(sms_text,160);
  54.        //Serial.println(smsText);
  55.        sms.SendSMS("+49",sms_text);
  56.       break;
  57.  
  58.     case CALL_COMM_LINE_BUSY:  // In this case the call would be established
  59.  
  60.       Serial.println("TALKING. Line busy.");
  61.      
  62.       break;
  63.   }
  64.   delay(1000);
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement