Send alarm over temp VDO
Add more flame sensor
Wiring Flame sensor
Library  
https://www.dropbox.com/s/owwkbx4p3k8rsc0/GSM900.rar?dl=0
credit:  github
Code
#include "SIM900.h"
#include <SoftwareSerial.h>
//If not used, is better to exclude the HTTP library,
//for RAM saving.
//If your sketch reboots itself proprably you have finished,
//your memory available.
//#include "inetGSM.h"
//If you want to use the Arduino functions to manage SMS, uncomment the lines below.
#include "sms.h"
SMSGSM sms;
//To change pins for Software Serial, use the two lines in GSM.cpp.
//GSM Shield for Arduino
//www.open-electronics.org
//this code is based on the example of Arduino Labs.
//Simple sketch to send and receive SMS.
int numdata;
boolean started=false;
char smsbuffer[160];
char n[20];
//LCD 
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x27 for a 16 chars and 2 line display
//temp
int tempC;
int reading;
int tempPin = 0;
//flame
int flame = A3 ;// define the flame interface analog 0 interface
int Beep = 8 ; // buzzer interface defines the interface number 7
int val = 0 ; // define numeric variables val 
void setup()
{
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  digitalWrite(4, HIGH);
  digitalWrite(5, HIGH);
  digitalWrite(6, HIGH);
  digitalWrite(7, HIGH);
//stup lcd
lcd.init(); 
//flame 
 pinMode(Beep, OUTPUT) ;// define LED as output interface
pinMode (flame, INPUT) ;// define the buzzer as the input interface
//setup temp
analogReference(INTERNAL);
     //Serial connection.
     Serial.begin(9600);
     Serial.println("GSM Shield testing.");
     //Start configuration of shield with baudrate.
     //For http uses is raccomanded to use 4800 or slower.
     if (gsm.begin(2400)) {
          Serial.println("\nstatus=READY");
          started=true;
     } else Serial.println("\nstatus=IDLE");
     if(started) {
          //Enable this two lines if you want to send an SMS.
          if (sms.SendSMS("0843545655", "GSM Factory Alarm"))
          Serial.println("\nSMS sent OK");
     }
};
void loop()
{
  temp();
  lcd11();
  flame1();
  lcd11();
  flame1();
     if(started) {
          //Read if there are messages on SIM card and print them.
          if(gsm.readSMS(smsbuffer, 160, n, 20)) {
               Serial.println(n);  //Print out phone number
               Serial.println(smsbuffer); // Text 
              char* ptr = smsbuffer;
  while ( strlen(ptr) >= 2 ) {
    if ( ptr[0] == 'a' ) {
      if ( ptr[1] == '1' )
        digitalWrite(4, LOW);
      else
        digitalWrite(4, HIGH);
    }
    if ( ptr[0] == 'b' ) {
      if ( ptr[1] == '1' )
        digitalWrite(5, LOW);
      else
        digitalWrite(5, HIGH);
    }
     if ( ptr[0] == 'c' ) {
      if ( ptr[1] == '1' )
        digitalWrite(6, LOW);
      else
        digitalWrite(6, HIGH);
    }
    if ( ptr[0] == 'd' ) {
      if ( ptr[1] == '1' )
        digitalWrite(7, LOW );
      else
        digitalWrite(7, HIGH);
    }
     if ( ptr[0] == 'x') {
      if ( ptr[1] == '1'){
        digitalWrite(4,LOW);
        digitalWrite(5,LOW);
        digitalWrite(6,LOW);
        digitalWrite(7,LOW);}
     else
     {
        digitalWrite(4,HIGH);
        digitalWrite(5,HIGH);
        digitalWrite(6,HIGH);
        digitalWrite(7,HIGH);
      }
     }
    ptr += 2;
  }
          }
          delay(100);
     }
};
void flame1()
 {val = analogRead (flame) ;// read the analog value flame sensor
//delay(2000);
Serial.println (val) ;// output analog values, and print them out
 if (val >= 600) // When the analog value is greater than 600 when the buzzer sounds
{ digitalWrite (Beep, HIGH);} 
else {digitalWrite (Beep, LOW);
}
 if(val>=600)
 {
sms.SendSMS("0843545655", "flame over 600");
  }
}
void temp()
{
  reading = analogRead(tempPin);
tempC = reading / 7;
  if(tempC > 60 )
  {
sms.SendSMS("0843545655", "Temp over 60 C");
  }
}
void lcd11()
{ lcd.backlight();
  lcd.setCursor(3,0);
  lcd.print("Temp");
  lcd.setCursor(2,1);
  lcd.print(tempC);
  lcd.setCursor(5,1);
  lcd.print("C");
  lcd.setCursor(8,0);
  lcd.print("Flame");
  lcd.setCursor(8,1);
  lcd.print(val);
 }


ไม่มีความคิดเห็น:
แสดงความคิดเห็น