Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Sim800l.h"
- #include <SoftwareSerial.h>
- #include "call.h"
- #include <DHT.h>
- #include "sms.h"
- SoftwareSerial mySerial(2, 3); // RX, TX
- SMSGSM sms;
- #define DHTPIN 7
- #define DHTTYPE DHT22
- CallGSM call;
- boolean started=false;
- char sms_text[160];
- DHT dht(DHTPIN, DHTTYPE);
- void setup()
- {
- dht.begin();
- Serial.begin(9600);
- if (gsm.begin(9600))
- {
- Serial.println("\nstatus=READY");
- started=true;
- }
- else
- Serial.println("\nstatus=IDLE");
- }
- void loop()
- {
- float humidity, temperature;
- String smsText ="";
- switch (call.CallStatus())
- {
- case CALL_NONE: // Nothing is happening
- break;
- case CALL_INCOM_VOICE : // Yes! Someone is calling us
- Serial.println("RECEIVING CALL");
- call.HangUp();
- delay(2000);
- humidity = dht.readHumidity();
- temperature = dht.readTemperature();
- delay(2000);
- smsText = "Temperature: "+String(temperature,1)+"C Humidity: "+String(humidity,1)+"%";
- smsText.toCharArray(sms_text,160);
- //Serial.println(smsText);
- sms.SendSMS("+49",sms_text);
- break;
- case CALL_COMM_LINE_BUSY: // In this case the call would be established
- Serial.println("TALKING. Line busy.");
- break;
- }
- delay(1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement