// Include library for 1-Wire communication protocol #include // Include library to communicate easily with the sensors #include // Define the pin Arduino will use with the 1-Wire protocol #define ONE_WIRE_BUS 8 // Create a "oneWire" class to work with the chosen pin OneWire oneWire(ONE_WIRE_BUS); // Pass the data from the 1-Wire protocol to the Dallas library DallasTemperature sensors(&oneWire); // Static Variables int sensorHumidity = A0; // Declare the humidity sensor pin variable int pinModuleOn = 2; // Declare the pin variable to activate GPRS module char phone_number[]="*********"; // the phone number to which the message is sent // Dynamic Variables int valueHumidity = 0; // Variable for the humidity value float valueTemperature = 0; // Variable for the temperature value void activateModule(){ // Function in charge of activating the GPRS module digitalWrite(pinModuleOn,HIGH); delay(2000); digitalWrite(pinModuleOn,LOW); } void setup() { // Initialize the serial port Serial.begin(115200); // Short time delay delay(2000); // Initialize the triggering pin from the module as it exits pinMode(pinModuleOn, OUTPUT); // Turn on the GPRS module activateModule(); // Wait a moment for the module to initialize for (int i=0;i < 5;i++){ delay(20000); } // Initialize the 1-Wire protocol and the sensor sensors.begin(); } void loop() { // Query the temperature on the device sensors.requestTemperatures(); // Store the temperature value valueTemperature = sensors.getTempCByIndex(0); // Read the analog value of the sensor and store it valueHumidity = analogRead(sensorHumidity); // Check that the measurements are within sane ranges if ( (valueHumidity<400) || (valueTemperature<24)) { // The missed call is made when the measurements are dangerous for the plant Serial.print("ATD"); Serial.print(phone_number); Serial.println(";"); // Missed call delay(20000); // Finalize the missed call Serial.println("ATH"); delay(10000); } }