New Homepage Forums Sensor Shields Data Logger Shield

This topic contains 35 replies, has 2 voices, and was last updated by avatar sheryline 1 year, 10 months ago. This post has been viewed 1002 times

Viewing 15 posts - 16 through 30 (of 36 total)
  • Author
    Posts
  • #68746
    avatarAhmed ismail
    Keymaster

    Then Make it like that:

    #68805
    avatarsheryline
    Participant

    Okay will try that. Thanks Ahmed! πŸ™‚

    #68817
    avatarsheryline
    Participant

    I would like to ask if its okay, since this is for a home security system i would like to know more on how the 1sheeld hardware works so I can explain it better too.
    1. does this work only when your smartphone is at home? I was hoping this 1sheeld app can still get the data logs even if you are away.
    2. for the keypad feature I will be adding, can I program this to arm or disarm when I am far from home?
    3. do we need internet usage for this if its possible to control the system while I’m away?
    4. does the sms shield use standard texting rates? how does it work?

    #68884
    avatarAhmed ismail
    Keymaster

    1- Yeah, there must be any smartphone connected to the system and should be within 30 feet from the 1Sheeld. But you can let a cheap smartphone back home to log the data and then it can send you the logged data through Email πŸ™‚
    2- Could you please explain more with what do you mean by arm and disarm?
    3- Yeah sure, just if you can keep an iOS device connected to the 1Sheeld at your home so you can use the IOT shield
    4-The SMS shield work on the standards of your service provider in terms of cost and no. of characters per SMS.

    #68927
    avatarsheryline
    Participant

    Great Info! Thanks Ahmed πŸ™‚ for number 2, I mean can I activate/deactivate my sensors or my system when I am away from home through the use of SMS? Like example a receive an SMS notif and a camera shot in my email and I found out it was just a cat or something so I want to turn off the alarms and sensors so I was hoping if I could send an SMS back to my 1sheeld to turn my system off/on? in case I cannot use the Iot Shield.

    #68952
    avatarsheryline
    Participant

    I tried to study the sms documentation in the website and there is this code:

    char * getSms(void)

    is this where I can use the app to receive an sms and maybe program the sms received to act as input and return an output of turning of the alarm? πŸ™‚

    #68961
    avatarsheryline
    Participant

    Hi Ahmed, i just cant stop exploring πŸ˜€
    I tried the codes I saw in the sms documentation and tried it on my end.
    This program should turn off my alarm if a sensor is triggered and the user wants to turn the alarm of using an SMS reply.

    I am not getting any error when I compiled it but I haven’t uploaded it in the 1sheeld hardware yet. I was hoping if you can check if my logic or program is correct?

    void setup(){

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

    SMS.setOnSmsReceive(&myFunction);

    }

    void loop(){
    /*my normal sensor codes here*/
    }

    void myFunction (String phoneNumber ,String messageBody)
    {
    phoneNumber = “09967054800”;

    if (messageBody == “MOTION OFF”)
    {
    digitalWrite(ledPin,LOW);
    PIR = LOW;
    }
    if (messageBody = “FIRE OFF”)
    {
    digitalWrite(BuzzPin,LOW);
    Flame = LOW;
    }
    if (messageBody = “SMOKE OFF”)
    {
    digitalWrite(buzzPin,LOW);
    analogSensor = LOW;
    }
    else
    {
    SMS.send(“09967054800″,”Invalid Command”);
    isMessageSent – true;
    }
    }

    #68965
    avatarAhmed ismail
    Keymaster

    Hey Shery, yeah sure you can do that using the SMS shield and your code is pretty good, you just need to add the country code before the used phone number like adding +1 if you are in the states and so on.

    And for the phone number used, if the number sent you the command doesn’t matter you can delete this line: phoneNumber = β€œ09967054800”;

    But if it matters and you need to check messages only from this message then you need to make the function like that:

    #69155
    avatarsheryline
    Participant

    Wonderful! I have corrected the codes, I was about to test the sms receive part when I got more problems:

    1-camera shield takes pictures even if my motion sensor did not pick up anything yet and there was no LED on first, is there a problem with my delay codes for both arduino and onesheeld?

    2-sms and data logger shows Fire detected when only motion was detected πŸ™

    by the way how did you post your codes in this page like that?

    #69157
    avatarsheryline
    Participant

    /*to avoide memory overload*/
    #define CUSTOM_SETTINGS
    #define INCLUDE_SMS_SHIELD /*sms*/
    #define INCLUDE_TERMINAL_SHIELD
    #define INCLUDE_CAMERA_SHIELD
    #define INCLUDE_DATA_LOGGER_SHIELD /*data log*/
    #define INCLUDE_CLOCK_SHIELD /*clock*/
    /* 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 = 400;
    /* Reserve a counter. */
    int counter = 0;
    bool startFlag = false; /*data log, Define a boolean flag.*/
    boolean isMessageSent = false;

    int hour, minute, day, month, year;

    /*SETUP*/
    void setup(){

    /*start communication*/
    OneSheeld.begin();
    /*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);
    delay(10000);

    if (PIR == LOW)
    {
    Camera.setFlash(ON);
    Camera.rearCapture();
    OneSheeld.delay(5000);
    Logger.stop();
    Logger.start(“Motion Sensor Triggered”);
    SMS.send(“09967054800″,”Motion DETECTED”);// turn LED ON

    PIR = HIGH;
    }
    }
    if(startFlag)
    {
    Logger.add(“Motion Detected at”,”Motion Detected at”);
    Logger.add(“Hour”,hour);
    Logger.add(“:”,”:”);
    Logger.add(“Minute”,minute);
    Logger.add(“Month”,month);
    Logger.add(“-“,”-“);
    Logger.add(“Day”,day);
    Logger.add(“-“,”-“);
    Logger.add(“Year”,year);
    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*/
    if (Flame== HIGH)
    {

    Terminal.println(“HIGH flame”);
    digitalWrite(BuzzPin, HIGH);
    Camera.rearCapture();
    Logger.stop();
    Logger.start(“Flame Sensor Triggered”);
    OneSheeld.delay(10000);
    SMS.send(“09967054800″,”Fire Detected!”);
    isMessageSent = true;
    }
    if(startFlag)
    {
    Logger.add(“Fire Detected at”,”Fire Detected at”);
    Logger.add(“Hour”,hour);
    Logger.add(“:”,”:”);
    Logger.add(“Minute”,minute);
    Logger.add(“Month”,month);
    Logger.add(“-“,”-“);
    Logger.add(“Day”,day);
    Logger.add(“-“,”-“);
    Logger.add(“Year”,year);
    Logger.log();
    OneSheeld.delay(1000);
    counter++;
    if(counter==20)
    {
    Logger.stop();
    counter=0;
    Logger.start(“Fire Sensor Triggered”);
    }
    }
    else
    {

    Terminal.println(“NO FLAME”);
    digitalWrite(BuzzPin, LOW);
    isMessageSent = false;
    }

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

    analogWrite(buzzPin, HIGH);
    Camera.rearCapture();
    Logger.stop();
    Logger.start(“Smoke/Gas Sensor Triggered”);
    OneSheeld.delay(10000);
    SMS.send(“09967054800″,”Smoke Detected!”);
    isMessageSent = true;
    delay(10000);
    }
    if(startFlag)
    {
    Logger.add(“Smoke/Gas Detected at”,”Smoke/Gas Detected at”);
    Logger.add(“Hour”,hour);
    Logger.add(“:”,”:”);
    Logger.add(“Minute”,minute);
    Logger.add(“Month”,month);
    Logger.add(“-“,”-“);
    Logger.add(“Day”,day);
    Logger.add(“-“,”-“);
    Logger.add(“Year”,year);
    Logger.log();
    OneSheeld.delay(1000);
    counter++;
    if(counter==20)
    {
    Logger.stop();
    counter=0;
    Logger.start(“Smoke/Gas Sensor Triggered”);
    }
    }
    else
    {

    analogWrite(buzzPin, LOW);
    isMessageSent = false;
    }

    }

    void myFunction (String phoneNumber ,String messageBody)
    {
    int analogSensor = analogRead(smokeA0);

    if (phoneNumber == “+639967054800”)
    {

    if (messageBody == “MOTION OFF”)
    {
    digitalWrite(ledPin,LOW);
    PIR = LOW;
    }
    if (messageBody = “FIRE OFF”)
    {
    digitalWrite(BuzzPin,LOW);
    Flame = LOW;
    }
    if (messageBody = “SMOKE OFF”)
    {
    digitalWrite(buzzPin,LOW);
    analogSensor = LOW;
    }

    else
    {
    SMS.send(“+639967054800″,”Invalid Command”);
    isMessageSent = true;
    }
    }
    else
    {
    isMessageSent = false;
    }
    }

    #69159
    avatarsheryline
    Participant

    I am not sure if there is something wrong about my conditions or the brackets in my loop that maybe causes to give me an sms or log for fire sensor even if the alarm triggered was for motion πŸ™

    #69288
    avatarsheryline
    Participant

    Hi ahmed i made revisions to my codes and is now working as intended πŸ™‚ But still the sms receive function is still not working, i tried to reply to my own number and the LED and buzzer did not turn off πŸ™ what could be wrong?

    #69290
    avatarsheryline
    Participant

    #define CUSTOM_SETTINGS
    #define INCLUDE_SMS_SHIELD /*sms*/
    #define INCLUDE_CAMERA_SHIELD
    //1sheeld.cm for the steps on adding the libraries to your arduino program

    #include <OneSheeld.h>
    int ledPin = 13; // choose the pin for the LED
    int pirPin = 3; // choose the input pin (for PIR sensor)
    /*for flame sensor*/
    int FireBuzzer = 9;
    int FlamePin = 2; /*This is for input pin*/
    /*for SMOKE sensor*/
    int smokeBuzzer = 5;
    int smokeA0 = A5; /*the digital pin connected to the smoke sensor’s output*/
    int sensorThres = 400;

    void setup() {
    pinMode(ledPin, OUTPUT); // declare LED as output
    pinMode(pirPin, INPUT); // declare sensor as input
    /*flame setup*/
    pinMode(FireBuzzer, OUTPUT);
    pinMode(FlamePin, INPUT);
    /*gas setup*/
    pinMode(smokeBuzzer, OUTPUT);
    pinMode(smokeA0, INPUT);
    OneSheeld.begin();

    }

    void loop(){

    if (digitalRead(pirPin) == HIGH) { // check if the input is HIGH
    digitalWrite(ledPin, HIGH); // turn LED ON
    delay(5000);
    SMS.send(“09967054800″,”Motion DETECTED”);
    Camera.setFlash(ON);
    Camera.rearCapture();
    OneSheeld.delay(5000);

    }

    if (digitalRead(pirPin) == LOW)
    {
    digitalWrite(ledPin, LOW); // turn LED OFF

    }

    /*flame_condition*/
    if (digitalRead(FlamePin)== HIGH)
    {
    digitalWrite(FireBuzzer, LOW);
    }

    if (digitalRead(FlamePin)== LOW)
    {
    digitalWrite(FireBuzzer, HIGH);
    SMS.send(“09967054800″,”Fire Detected!”);
    Camera.setFlash(ON);
    Camera.rearCapture();
    OneSheeld.delay(5000);
    }

    if (analogRead(smokeA0) > sensorThres)
    {
    tone(smokeBuzzer, 1000, 200);
    delay(150);
    SMS.send(“09967054800″,”Smoke Detected!”);
    Camera.setFlash(ON);
    Camera.rearCapture();
    OneSheeld.delay(5000);
    }
    else
    {
    noTone(smokeBuzzer);
    }
    }

    void myFunction (String phoneNumber ,String messageBody)
    {

    if (phoneNumber == “+639967054800”)
    {

    if (messageBody == “MOTION OFF”)
    {
    digitalWrite(ledPin,LOW);
    digitalWrite(pirPin,LOW);
    }
    if (messageBody = “FIRE OFF”)
    {
    digitalWrite(FireBuzzer,LOW);
    digitalWrite(FlamePin,LOW);
    }
    if (messageBody = “SMOKE OFF”)
    {
    digitalWrite(smokeBuzzer,LOW);
    digitalWrite(smokeA0,LOW);
    }

    else
    {
    SMS.send(“+639967054800″,”Invalid Command”);
    }
    }
    }

    #69292
    avatarsheryline
    Participant

    i removed the data logger because it caused more errors, i will try it again next time. For now the most important thing is the sms receive.

    #69366
    avatarAhmed ismail
    Keymaster

    Hey Shery, I’m very sorry for my late reply.

    Actually, the problem is only that you didn’t invoke the function responsible for checking the received functions so it can enter to “myFubction”.

    So please add this line to your void loop function: SMS.setOnSmsReceive(&myFunction);

Viewing 15 posts - 16 through 30 (of 36 total)

You must be logged in to reply to this topic.