New Homepage Forums Sensor Shields Data Logger Shield

This topic contains 35 replies, has 2 voices, and was last updated by avatar sheryline 2 years, 3 months ago. This post has been viewed 1108 times

Viewing 15 posts - 1 through 15 (of 36 total)
  • Author
    Posts
  • #67985
    avatarsheryline
    Participant

    Hi there, I am new to arduino and I am making my first home security system model using pir sensor, flame and smoke/gas sensors. I was able to have it working with the arduino program but I recently discovered 1sheeld and want to use it as my control panel. I am working on the keypad and sms for now. I would like to ask if the Data Logger shield can log each of my sensors activity? I am having a little trouble finding some sample codes. Thank you

    #68014
    avatarAhmed ismail
    Keymaster

    Hey Shery, yeah sure you can, please check out the Data Logger shield documentation and you will find a description for all the functions included in the shield and of course, if you need any help with the code, just let me know ๐Ÿ™‚

    #68453
    avatarsheryline
    Participant

    Sorry for the delayed reply, thank for this document, I would really love to ask help with the codes but I will try first if I can finish it ๐Ÿ™‚

    #68457
    avatarsheryline
    Participant

    Hi Ahmed,

    I tried to understand the documentation and tried my own codes based also on the data logger sample but I got an error after compiling. Can you please help me? I currently have 3 sensors working with arduino uno and I am planning to add 1sheeld so my phone will act as a control panel that has SMS, Data Logs, and Keypad feature. I am struggling a little on how to mix arduino codes and 1sheeld codes but I tried to add SMS and Data Logger shield codes in my system. Every triggered sensor should send an SMS notification and at the same time log the activities if the sensors with a time stamp. I have attached my file. Please tell me what is my mistake. Thank you ๐Ÿ™‚

    #68459
    avatarsheryline
    Participant

    /*to avoide memory overload*/
    #define CUSTOM_SETTINGS
    #define INCLUDE_CLOCK_SHIELD /*clock*/
    #define INCLUDE_SMS_SHIELD /*sms*/
    #define INCLUDE_DATA_LOGGER_SHIELD /*data log*/

    /*DECLARING VARIABLES*/
    /*for motion sensor*/
    int calibrationTime = 30;
    long unsigned int lowIn;
    long unsigned int pause = 1000;
    boolean lockLow = true;
    boolean takeLowTime;
    int pirPin = 3; /*the digital pin connected to the PIR sensor’s output*/
    int ledPin = 13;
    /*for flame sensor*/
    int Buzzer = 9; /*Use buzzer for alert*/
    int FlamePin = 2; /*This is for input pin*/
    int Flame = HIGH; /*HIGH when FLAME Exposed*/
    /*for SMOKE sensor*/
    int buzzer = 5;
    int smokeA0 = A5; /*the digital pin connected to the smoke sensor’s output*/
    int sensorThres = 100;

    /* Include 1Sheeld library. */
    #include <OneSheeld.h>

    /* Reserve a counter. */
    int counter = 0;
    /* Define a boolean flag. */
    boolean isMessageSent = false; /*sms*/
    bool startFlag = false; /*data log*/

    /*SETUP*/
    void setup(){

    /*start communication*/
    OneSheeld.begin();
    Serial.begin(9600);
    /* Save any previous logged values. */
    Logger.stop();
    /* Start the clock shield. */
    Clock.queryDateAndTime();
    /*motion setup*/
    pinMode(pirPin, INPUT);
    pinMode(ledPin, OUTPUT);
    digitalWrite(pirPin, LOW);
    /*flame setup*/
    pinMode(Buzzer, OUTPUT);
    pinMode(FlamePin, INPUT);
    /*gas setup*/
    pinMode(buzzer, OUTPUT);
    pinMode(smokeA0, INPUT);

    /*MOTION calibrating*/
    Serial.print(“calibrating sensor “);
    for(int i = 0; i < calibrationTime; i++){
    Serial.print(“.”);
    delay(1000);
    }
    Serial.println(” done”);
    Serial.println(“SENSOR ACTIVE”);
    delay(10);
    }

    /*LOOP*/
    void loop(){
    Flame = digitalRead(FlamePin);
    int analogSensor = analogRead(smokeA0);

    /*motion_condition*/
    if(digitalRead(pirPin) == HIGH)
    {
    digitalWrite(ledPin, HIGH);
    /* First insure to save previous logged values. */
    Logger.stop();
    /* Set a delay. */
    OneSheeld.delay(500);
    /* Start logging in a new CSV file. */
    Logger.start(“Motion Sensor Triggered”);
    /* Set startFlag. */
    startFlag = true;

    if(lockLow){
    lockLow = false;
    /* Send the SMS. */
    SMS.send(“09967054800″,”Intruder Detected!”);
    /* Set the flag. */
    isMessageSent = true;
    delay(100);
    }
    takeLowTime = true;
    }

    /* Check logging started. */
    if(startFlag)
    {
    /* Add noise level values as a column in the CSV file. */
    Logger.add(“Motion Detected at “,Clock.getHours(),”:”,Clock.getMinutes());
    /* Log the row in the file. */
    Logger.log();
    /* Delay for 1 second. */
    OneSheeld.delay(1000);
    /* Increment counter. */
    counter++;
    /* Stop logging after 20 readings and save the CSV file. */
    if(counter==20)
    {
    /* Save the logging CSV file. */
    Logger.stop();
    /* Reset counter. */
    counter=0;
    /* Start Logging again. */
    Logger.start(“Motion Sensor Triggered”);
    }
    }
    if(digitalRead(pirPin) == LOW){
    digitalWrite(ledPin, LOW);
    if(takeLowTime){
    lowIn = millis();
    takeLowTime = false;
    }
    if(!lockLow && millis() – lowIn > pause){
    lockLow = true;
    Serial.print(“motion ended at “);
    Serial.print((millis() – pause)/1000);
    Serial.println(” sec”);
    isMessageSent = false;
    delay(100);
    }
    }
    /*flame_condition*/
    Flame = digitalRead(FlamePin);
    if (Flame== HIGH)
    {
    Serial.println(“NO FLAME”);
    digitalWrite(Buzzer, LOW);
    isMessageSent = false;
    }
    else
    {
    Serial.println(“HIGH flame”);
    digitalWrite(Buzzer, HIGH);
    Logger.stop();
    OneSheeld.delay(500);
    Logger.start(“Fire Sensor Triggered!”);
    startFlag = true;
    SMS.send(“09967054800″,”Fire Detected!”);
    isMessageSent = true;
    }
    /* Check logging started. */
    if(startFlag)
    {
    Logger.add(“Fire Alert! at”,Clock.getHours(),”:”,Clock.getMinutes());
    Logger.log();
    OneSheeld.delay(1000);
    counter++;
    if(counter==20)
    {
    Logger.stop();
    counter=0;
    Logger.start(“Fire Sensor Triggered!”);
    }
    }
    /*smoke_condition*/
    if (analogSensor > sensorThres)
    {

    tone(buzzer, 1000, 200);
    Logger.stop();
    OneSheeld.delay(500);
    Logger.start(“Smoke/Gas Sensor Triggered!”);
    startFlag = true;
    SMS.send(“09967054800″,”Smoke Detected!”);
    isMessageSent = true;
    }
    if(startFlag)
    {
    Logger.add(“Smoke/Gas alert! at”,Clock.getHours(),”:”,Clock.getMinutes());
    Logger.log();
    OneSheeld.delay(1000);
    counter++;
    if(counter==20)
    {
    Logger.stop();
    counter=0;
    Logger.start(“Smoke/Gas Sensor Triggered!”);
    }
    else
    {

    noTone(buzzer);
    isMessageSent = false;
    }

    delay(5000);

    }
    }

    #68477
    avatarAhmed ismail
    Keymaster

    Hey Shery, actually using the serial monitor aside to using 1SHeeld is forbidden, could you please delete all the serial related lines and replace it with 1Sheeld’s Terminal shield, it will be the same as the serial monitor but on your smartphone. Then try again and if you still have an error, please send me the updated code with a pic for the error you got.

    #68516
    avatarsheryline
    Participant

    Thank you for the correction Ahmed. I tried my best and studied the terminal shield codes and replaced them. I am also watching other tutorials and i think I can make the codes shorter next time. Not sure if there are redundant codes but here is my revised codes. I also attached a picture of the error I am getting when I compile.

    /*to avoide memory overload*/
    #define CUSTOM_SETTINGS
    #define INCLUDE_CLOCK_SHIELD /*clock*/
    #define INCLUDE_SMS_SHIELD /*sms*/
    #define INCLUDE_DATA_LOGGER_SHIELD /*data log*/

    /*DECLARING VARIABLES*/
    /*for motion sensor*/
    int calibrationTime = 30;
    long unsigned int lowIn;
    long unsigned int pause = 1000;
    boolean lockLow = true;
    boolean takeLowTime;
    int pirPin = 3; /*the digital pin connected to the PIR sensor’s output*/
    int ledPin = 13;
    /*for flame sensor*/
    int Buzzer = 9; /*Use buzzer for alert*/
    int FlamePin = 2; /*This is for input pin*/
    int Flame = HIGH; /*HIGH when FLAME Exposed*/
    /*for SMOKE sensor*/
    int buzzer = 5;
    int smokeA0 = A5; /*the digital pin connected to the smoke sensor’s output*/
    int sensorThres = 100;

    /* Include 1Sheeld library. */
    #include <OneSheeld.h>

    /* Reserve a counter. */
    int counter = 0;
    /* Define a boolean flag. */
    boolean isMessageSent = false; /*sms*/
    bool startFlag = false; /*data log*/

    /*SETUP*/
    void setup(){

    /*start communication*/
    OneSheeld.begin();

    /* Save any previous logged values. */
    Logger.stop();
    /* Start the clock shield. */
    Clock.queryDateAndTime();
    /*motion setup*/
    pinMode(pirPin, INPUT);
    pinMode(ledPin, OUTPUT);
    digitalWrite(pirPin, LOW);
    /*flame setup*/
    pinMode(Buzzer, OUTPUT);
    pinMode(FlamePin, INPUT);
    /*gas setup*/
    pinMode(buzzer, OUTPUT);
    pinMode(smokeA0, INPUT);

    /*MOTION calibrating*/
    Terminal.print(“calibrating sensor “);
    for(int i = 0; i < calibrationTime; i++){
    Terminal.print(“.”);
    delay(1000);
    }
    Terminal.println(” done”);
    Terminal.println(“SENSOR ACTIVE”);
    delay(10);
    }

    /*LOOP*/
    void loop(){
    Flame = digitalRead(FlamePin);
    int analogSensor = analogRead(smokeA0);

    /*motion_condition*/
    if(digitalRead(pirPin) == HIGH)
    {
    digitalWrite(ledPin, HIGH);
    /* First insure to save previous logged values. */
    Logger.stop();
    /* Set a delay. */
    OneSheeld.delay(500);
    /* Start logging in a new CSV file. */
    Logger.start(“Motion Sensor Triggered”);
    /* Set startFlag. */
    startFlag = true;

    if(lockLow){
    lockLow = false;
    /* Send the SMS. */
    SMS.send(“09967054800″,”Intruder Detected!”);
    /* Set the flag. */
    isMessageSent = true;
    delay(100);
    }
    takeLowTime = true;
    }

    /* Check logging started. */
    if(startFlag)
    {
    /* Add noise level values as a column in the CSV file. */
    Logger.add(“Motion Detected at “,Clock.getHours(),”:”,Clock.getMinutes());
    /* Log the row in the file. */
    Logger.log();
    /* Delay for 1 second. */
    OneSheeld.delay(1000);
    /* Increment counter. */
    counter++;
    /* Stop logging after 20 readings and save the CSV file. */
    if(counter==20)
    {
    /* Save the logging CSV file. */
    Logger.stop();
    /* Reset counter. */
    counter=0;
    /* Start Logging again. */
    Logger.start(“Motion Sensor Triggered”);
    }
    }
    if(digitalRead(pirPin) == LOW){
    digitalWrite(ledPin, LOW);
    if(takeLowTime){
    lowIn = millis();
    takeLowTime = false;
    }
    if(!lockLow && millis() – lowIn > pause){
    lockLow = true;
    Terminal.print(“motion ended at “);
    Terminal.print((millis() – pause)/1000);
    Terminal.println(” sec”);
    isMessageSent = false;
    delay(100);
    }
    }
    /*flame_condition*/
    Flame = digitalRead(FlamePin);
    if (Flame== HIGH)
    {
    Terminal.println(“NO FLAME”);
    digitalWrite(Buzzer, LOW);
    isMessageSent = false;
    }
    else
    {
    Terminal.println(“HIGH flame”);
    digitalWrite(Buzzer, HIGH);
    Logger.stop();
    OneSheeld.delay(500);
    Logger.start(“Fire Sensor Triggered!”);
    startFlag = true;
    SMS.send(“09967054800″,”Fire Detected!”);
    isMessageSent = true;
    }
    /* Check logging started. */
    if(startFlag)
    {
    Logger.add(“Fire Alert! at”,Clock.getHours(),”:”,Clock.getMinutes());
    Logger.log();
    OneSheeld.delay(1000);
    counter++;
    if(counter==20)
    {
    Logger.stop();
    counter=0;
    Logger.start(“Fire Sensor Triggered!”);
    }
    }
    /*smoke_condition*/
    if (analogSensor > sensorThres)
    {

    tone(buzzer, 1000, 200);
    Logger.stop();
    OneSheeld.delay(500);
    Logger.start(“Smoke/Gas Sensor Triggered!”);
    startFlag = true;
    SMS.send(“09967054800″,”Smoke Detected!”);
    isMessageSent = true;
    }
    if(startFlag)
    {
    Logger.add(“Smoke/Gas alert! at”,Clock.getHours(),”:”,Clock.getMinutes());
    Logger.log();
    OneSheeld.delay(1000);
    counter++;
    if(counter==20)
    {
    Logger.stop();
    counter=0;
    Logger.start(“Smoke/Gas Sensor Triggered!”);
    }
    else
    {

    noTone(buzzer);
    isMessageSent = false;
    }

    delay(1000);

    }
    }

    Attachments:
    You must be logged in to view attached files.
    #68524
    avatarsheryline
    Participant

    sorry, i just noticed I have lots of errors, is this because I have not plugged in my hardware yet? I was hoping I could correct my program while waiting for my hardware to arrive

    #68526
    avatarsheryline
    Participant

    Arduino: 1.8.3 (Windows 7), Board: “Arduino/Genuino Uno”

    In file included from C:\Users\Grecilda\Documents\Arduino\libraries\OneSheeld/ShieldsIncludes.h:30:0,

    from C:\Users\Grecilda\Documents\Arduino\libraries\OneSheeld/OneSheeld.h:22,

    from C:\Users\Grecilda\Documents\Arduino\DataLogSystem\DataLogSystem.ino:26:

    C:\Users\Grecilda\Documents\Arduino\libraries\OneSheeld/BuzzerShield.h:45:26: error: conflicting declaration ‘BuzzerShieldClass Buzzer’

    extern BuzzerShieldClass Buzzer;

    ^

    C:\Users\Grecilda\Documents\Arduino\DataLogSystem\DataLogSystem.ino:17:5: note: previous declaration as ‘int Buzzer’

    int Buzzer = 9; /*Use buzzer for alert*/

    ^

    C:\Users\Grecilda\Documents\Arduino\DataLogSystem\DataLogSystem.ino: In function ‘void loop()’:

    DataLogSystem:100: error: no matching function for call to ‘DataLoggerShield::add(const char [20], byte, const char [2], byte)’

    Logger.add(“Motion Detected at “,Clock.getHours(),”:”,Clock.getMinutes());

    ^

    C:\Users\Grecilda\Documents\Arduino\DataLogSystem\DataLogSystem.ino:100:77: note: candidates are:

    In file included from C:\Users\Grecilda\Documents\Arduino\libraries\OneSheeld/ShieldsIncludes.h:51:0,

    from C:\Users\Grecilda\Documents\Arduino\libraries\OneSheeld/OneSheeld.h:22,

    from C:\Users\Grecilda\Documents\Arduino\DataLogSystem\DataLogSystem.ino:26:

    C:\Users\Grecilda\Documents\Arduino\libraries\OneSheeld/DataLoggerShield.h:39:7: note: void DataLoggerShield::add(const char*, float)

    void add(const char * , float);

    ^

    C:\Users\Grecilda\Documents\Arduino\libraries\OneSheeld/DataLoggerShield.h:39:7: note: candidate expects 2 arguments, 4 provided

    C:\Users\Grecilda\Documents\Arduino\libraries\OneSheeld/DataLoggerShield.h:40:7: note: void DataLoggerShield::add(String, float)

    void add(String , float);

    ^

    C:\Users\Grecilda\Documents\Arduino\libraries\OneSheeld/DataLoggerShield.h:40:7: note: candidate expects 2 arguments, 4 provided

    C:\Users\Grecilda\Documents\Arduino\libraries\OneSheeld/DataLoggerShield.h:41:7: note: void DataLoggerShield::add(const char*, const char*)

    void add(const char * ,const char*);

    ^

    C:\Users\Grecilda\Documents\Arduino\libraries\OneSheeld/DataLoggerShield.h:41:7: note: candidate expects 2 arguments, 4 provided

    C:\Users\Grecilda\Documents\Arduino\libraries\OneSheeld/DataLoggerShield.h:42:7: note: void DataLoggerShield::add(String, String)

    void add(String , String);

    ^

    C:\Users\Grecilda\Documents\Arduino\libraries\OneSheeld/DataLoggerShield.h:42:7: note: candidate expects 2 arguments, 4 provided

    DataLogSystem:155: error: no matching function for call to ‘DataLoggerShield::add(const char [15], byte, const char [2], byte)’

    Logger.add(“Fire Alert! at”,Clock.getHours(),”:”,Clock.getMinutes());

    ^

    C:\Users\Grecilda\Documents\Arduino\DataLogSystem\DataLogSystem.ino:155:72: note: candidates are:

    In file included from C:\Users\Grecilda\Documents\Arduino\libraries\OneSheeld/ShieldsIncludes.h:51:0,

    from C:\Users\Grecilda\Documents\Arduino\libraries\OneSheeld/OneSheeld.h:22,

    from C:\Users\Grecilda\Documents\Arduino\DataLogSystem\DataLogSystem.ino:26:

    C:\Users\Grecilda\Documents\Arduino\libraries\OneSheeld/DataLoggerShield.h:39:7: note: void DataLoggerShield::add(const char*, float)

    void add(const char * , float);

    ^

    C:\Users\Grecilda\Documents\Arduino\libraries\OneSheeld/DataLoggerShield.h:39:7: note: candidate expects 2 arguments, 4 provided

    C:\Users\Grecilda\Documents\Arduino\libraries\OneSheeld/DataLoggerShield.h:40:7: note: void DataLoggerShield::add(String, float)

    void add(String , float);

    ^

    C:\Users\Grecilda\Documents\Arduino\libraries\OneSheeld/DataLoggerShield.h:40:7: note: candidate expects 2 arguments, 4 provided

    C:\Users\Grecilda\Documents\Arduino\libraries\OneSheeld/DataLoggerShield.h:41:7: note: void DataLoggerShield::add(const char*, const char*)

    void add(const char * ,const char*);

    ^

    C:\Users\Grecilda\Documents\Arduino\libraries\OneSheeld/DataLoggerShield.h:41:7: note: candidate expects 2 arguments, 4 provided

    C:\Users\Grecilda\Documents\Arduino\libraries\OneSheeld/DataLoggerShield.h:42:7: note: void DataLoggerShield::add(String, String)

    void add(String , String);

    ^

    C:\Users\Grecilda\Documents\Arduino\libraries\OneSheeld/DataLoggerShield.h:42:7: note: candidate expects 2 arguments, 4 provided

    DataLogSystem:180: error: no matching function for call to ‘DataLoggerShield::add(const char [20], byte, const char [2], byte)’

    Logger.add(“Smoke/Gas alert! at”,Clock.getHours(),”:”,Clock.getMinutes());

    ^

    C:\Users\Grecilda\Documents\Arduino\DataLogSystem\DataLogSystem.ino:180:77: note: candidates are:

    In file included from C:\Users\Grecilda\Documents\Arduino\libraries\OneSheeld/ShieldsIncludes.h:51:0,

    from C:\Users\Grecilda\Documents\Arduino\libraries\OneSheeld/OneSheeld.h:22,

    from C:\Users\Grecilda\Documents\Arduino\DataLogSystem\DataLogSystem.ino:26:

    C:\Users\Grecilda\Documents\Arduino\libraries\OneSheeld/DataLoggerShield.h:39:7: note: void DataLoggerShield::add(const char*, float)

    void add(const char * , float);

    ^

    C:\Users\Grecilda\Documents\Arduino\libraries\OneSheeld/DataLoggerShield.h:39:7: note: candidate expects 2 arguments, 4 provided

    C:\Users\Grecilda\Documents\Arduino\libraries\OneSheeld/DataLoggerShield.h:40:7: note: void DataLoggerShield::add(String, float)

    void add(String , float);

    ^

    C:\Users\Grecilda\Documents\Arduino\libraries\OneSheeld/DataLoggerShield.h:40:7: note: candidate expects 2 arguments, 4 provided

    C:\Users\Grecilda\Documents\Arduino\libraries\OneSheeld/DataLoggerShield.h:41:7: note: void DataLoggerShield::add(const char*, const char*)

    void add(const char * ,const char*);

    ^

    C:\Users\Grecilda\Documents\Arduino\libraries\OneSheeld/DataLoggerShield.h:41:7: note: candidate expects 2 arguments, 4 provided

    C:\Users\Grecilda\Documents\Arduino\libraries\OneSheeld/DataLoggerShield.h:42:7: note: void DataLoggerShield::add(String, String)

    void add(String , String);

    ^

    C:\Users\Grecilda\Documents\Arduino\libraries\OneSheeld/DataLoggerShield.h:42:7: note: candidate expects 2 arguments, 4 provided

    exit status 1
    no matching function for call to ‘DataLoggerShield::add(const char [20], byte, const char [2], byte)’

    This report would have more information with
    “Show verbose output during compilation”
    option enabled in File -> Preferences.

    #68571
    avatarsheryline
    Participant

    I was able to fix the buzzer error. The only error I am getting is from the Data Logger shield.

    #68735
    avatarAhmed ismail
    Keymaster

    Hey Shery,

    Actually, the error is here due to miss use of the add function of the Datalogger shield.

    The Add function just takes two parameters, the Column name, and the values being logged inside. so you just need to make two columns for both the hours and minutes.

    #68737
    avatarsheryline
    Participant

    Hello ๐Ÿ™‚

    I was able to fix all errors after trying many times. But I cannot seem to get how to display the time stamp of the sensor’s activity.

    My code is:

    Logger.add(“Motion Detected at”,hour);
    but i think this will only display the hour.

    I was getting the error before because what I tried was like this:

    Logger.add(“Motion Detected at”,hour,minute,month,day,year);

    what should be the correct syntax?

    Thanks a lot ๐Ÿ™‚

    #68739
    avatarsheryline
    Participant

    Here is my new code, all the errors are gone ๐Ÿ™‚

    /*to avoide memory overload*/
    #define CUSTOM_SETTINGS
    #define INCLUDE_CLOCK_SHIELD /*clock*/
    #define INCLUDE_SMS_SHIELD /*sms*/
    #define INCLUDE_DATA_LOGGER_SHIELD /*data log*/
    #define INCLUDE_TERMINAL_SHIELD

    /* Include 1Sheeld library. */
    #include <OneSheeld.h>
    /*DECLARING VARIABLES*/
    /*for motion sensor*/
    int pirPin = 3; /*the digital pin connected to the PIR sensor’s output*/
    int ledPin = 13;
    int val=0;
    int PIR = LOW;
    /*for flame sensor*/
    int BuzzPin = 9;
    int FlamePin = 2; /*This is for input pin*/
    int Flame = HIGH; /*HIGH when FLAME Exposed*/
    /*for SMOKE sensor*/
    int buzzPin = 5;
    int smokeA0 = A5; /*the digital pin connected to the smoke sensor’s output*/
    int sensorThres = 100;

    /* Reserve a counter. */
    int counter = 0;
    bool startFlag = false; /*data log, Define a boolean flag.*/
    boolean isMessageSent = false; /*sms*/

    int hour, minute, day, month, year;
    /*SETUP*/
    void setup(){

    /*start communication*/
    OneSheeld.begin();
    Clock.queryDateAndTime();
    Logger.stop();
    /*motion setup*/
    pinMode(pirPin, INPUT);
    pinMode(ledPin, OUTPUT);
    digitalWrite(pirPin, LOW);
    /*flame setup*/
    pinMode(BuzzPin, OUTPUT);
    pinMode(FlamePin, INPUT);
    /*gas setup*/
    pinMode(buzzPin, OUTPUT);
    pinMode(smokeA0, INPUT);

    }

    /*LOOP*/
    void loop(){
    Flame = digitalRead(FlamePin);
    int analogSensor = analogRead(smokeA0);
    val = digitalRead(pirPin);
    hour = Clock.getHours();
    minute = Clock.getMinutes();
    day = Clock.getDay();
    month = Clock.getMonth();
    year = Clock.getYear();

    /*motion_condition*/
    if (val == HIGH) { // check if the input is HIGH
    digitalWrite(ledPin, HIGH); // turn LED ON
    delay(150);

    if (PIR == LOW) {
    Logger.stop();
    OneSheeld.delay(500);
    Logger.start(“Motion Sensor Triggered”);
    startFlag = true;
    SMS.send(“09967054800″,”Motion DETECTED”);
    PIR = HIGH;
    }
    }
    if(startFlag)
    {
    Logger.add(“Motion Detected at”,hour);
    Logger.log();
    OneSheeld.delay(1000);
    counter++;
    if(counter==20)
    {
    Logger.stop();
    counter=0;
    Logger.start(“Motion Sensor Triggered”);
    }
    }
    else {
    digitalWrite(ledPin, LOW); // turn LED OFF
    if (PIR== HIGH){
    PIR = LOW;
    }
    }
    /*flame_condition*/
    Flame = digitalRead(FlamePin);
    if (Flame== HIGH)
    {
    Terminal.println(“NO FLAME”);
    digitalWrite(BuzzPin, LOW);
    Logger.stop();
    OneSheeld.delay(500);
    Logger.start(“Flame Sensor Triggered”);
    startFlag = true;
    isMessageSent = false;
    }
    if(startFlag)
    {
    Logger.add(“Flame Detected at”,hour);
    Logger.log();
    OneSheeld.delay(1000);
    counter++;
    if(counter==20)
    {
    Logger.stop();
    counter=0;
    Logger.start(“Flame Sensor Triggered”);
    }
    }
    else
    {
    Terminal.println(“HIGH flame”);
    digitalWrite(BuzzPin, HIGH);
    SMS.send(“09967054800″,”Fire Detected!”);
    isMessageSent = true;
    }

    /*smoke_condition*/
    if (analogSensor > sensorThres)
    {

    tone(buzzPin, 1000, 200);
    SMS.send(“09967054800″,”Smoke Detected!”);
    isMessageSent = true;
    Logger.stop();
    OneSheeld.delay(500);
    Logger.start(“Smoke/Gas Sensor Triggered”);
    startFlag = true;
    }
    if(startFlag)
    {
    Logger.add(“Smoke/Gas Detected at”,hour);
    Logger.log();
    OneSheeld.delay(1000);
    counter++;
    if(counter==20)
    {
    Logger.stop();
    counter=0;
    Logger.start(“Smoke/Gas Sensor Triggered”);
    }
    }
    else
    {

    noTone(buzzPin);
    isMessageSent = false;
    }

    delay(1000);

    }

    #68741
    avatarAhmed ismail
    Keymaster

    Hey Shery, I recommend naming the whole file “Motions Detected”

    And then you will make a column for each time parameter:

    And so on…

    #68743
    avatarsheryline
    Participant

    Do you mean it should be like:

    Logger.add(โ€œMotion Detected atโ€,hour);
    Logger.add(โ€œMotion Detected atโ€,minute);

    like this?

    I would like it to display in the smart phone like:

    “Motion Detected at 6:17 03-19-2018”

Viewing 15 posts - 1 through 15 (of 36 total)

You must be logged in to reply to this topic.