Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
A

arcidodo

@arcidodo
About
Posts
1
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • 'MySensoring' a GE Washer
    A arcidodo

    Thanks! i updated it to version 2.0 but it's working perfectly

    // Based on Author: Patrick 'Anticimex' Fallberg Interrupt driven binary switch example with dual interrupts
    // Enable debug prints to serial monitor
    #define MY_DEBUG
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    
    //#define MY_REPEATER_FEATURE
    #define MY_NODE_ID 17
    
    #include <SPI.h>
    #include <MySensors.h>
    
    #define CHILD_ID 1
    
    #define SIREN_SENSE_PIN 3   // Arduino Digital I/O pin for optocoupler for siren
    
    unsigned int SLEEP_TIME      = 32400; // Sleep time between reads (in seconds) 32400 = 9hrs?
    long CYCLE_COUNTER          = 3;  // This is the number of times we want the Audio Counter to reach before triggering a signal to controller.
    unsigned long CYCLE_INTERVAL    = 3; // How long do we want to watch once first detected (in seconds) 
                          //Adjust for your smoke detector, you want to pick up the siren signal at least 3 time to help stop false alarms. 
    unsigned long CYCLE_RATE      = 90; // How fast do we want to move checking the Pin state in the Status Check (in Millis) Adjust for your smoke detector
                          //Adjust for your smoke detector, you want to pick up the siren signal at least 3 time to help stop false alarms.
    unsigned long CYCLE_TIME_OKSTATUS = 8; // How long do we want to watch for "all clear" once we have confirmed an Alarm (in seconds)
    unsigned long CYCLE_RATE_OKSTATUS = 500; // How fast do we want to move checking the Pin state when checking for an OK status (in Millis)
    
    int oldValue=1;
    int value=0;
    
    
    //MySensors sensor_node;
    MyMessage msg(CHILD_ID, V_TRIPPED);
    
    void setup()  
    {  
      // Setup the Siren Pin HIGH
      pinMode(SIREN_SENSE_PIN, INPUT_PULLUP);
    }
    
    void presentation()  
    { 
    
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Washer End Cycle", "1.1");
      present(CHILD_ID, S_SMOKE); 
      //Send the state -- Always send Alarm state on power up.
      send(msg.setSensor(CHILD_ID).set("1"), true);
      
    }
    
    // Loop will iterate on changes on the BUTTON_PINs
    void loop() 
    {
      // Check to see if we have a alarm. I always want to check even if we are coming out of sleep for heartbeat.
      AlarmStatus();
      // Sleep until we get a audio power hit on the optocoupler or 9hrs
      sleep(SIREN_SENSE_PIN-2,FALLING, SLEEP_TIME * 1000UL);
      
    } 
    
    void AlarmStatus()
    {
      
    // We will check the status now, this could be called by an interrupt or heartbeat
    int siren_audio_count =0;
    long cycle_time     =0;   
    unsigned long startedAt = millis();
    
      Serial.println("Status Check");
      //Read the Pin
      value = digitalRead(SIREN_SENSE_PIN);
        // If Pin return a 0 (LOW), then we have a Alarm Condition
      if (value != 1) {
         //We are only going to check for status for CYCLE_INTERVAL time I think this should help stabilize Siren Sensing
          while(millis() - startedAt < CYCLE_INTERVAL * 1000)
          {
            //We are going to check CYCLE_RATE fast
            if(millis() - cycle_time > CYCLE_RATE ) {
              // save the last time you Checked
              cycle_time = millis();
                //We will count each time SIREN_SENSE_PIN is 0 (Alarm - LOW) for the above time and at the above rate.
              value = digitalRead(SIREN_SENSE_PIN);  
                if (value != 1)
                {
                  siren_audio_count++;
                  Serial.print("Audio Count: ");
                  Serial.println(siren_audio_count);
                } 
            }
          }
            // Eval siren audio hit count against our limit. If we are => then CYCLE_COUNTER then lets start a loop for "All Clear" reset
            // If we continue to return an audio power hit, then we will continue to send to the controller. 
            if (siren_audio_count>=CYCLE_COUNTER)
            {
              Serial.println("Alarm Detected");
              
              do 
              {
                //update gateway with bad news.
                //sensor_node.send(msg.set("1"));
                send(msg.setSensor(CHILD_ID).set("1"), true);
                Serial.println("Alarm Detected Sent to gateway");
              } while (IsAlarmAllClear()!=1);
            
            }
      }
      //Pin returned a 1 (High) so there is no alarm. 
      else
      {
        IsAlarmAllClear();
      }
    }
    
    int IsAlarmAllClear()
    // We are looking for an gap in time that we no longer see an audio power hit to the optocoupler. 
    
    {
     int alarmOn        =0;
     long cycle_time      =0;
     unsigned long startedAt  = millis();
    
      //We are only going to check for status for CYCLE_TIME_OKSTATUS time  
      while(millis() - startedAt < CYCLE_TIME_OKSTATUS * 1000)
      {
        //We are going to check CYCLE_RATE_OKSTATUS fast
        if(millis() - cycle_time > CYCLE_RATE_OKSTATUS) {
          // save the last time you Checked
          cycle_time = millis();
          int value = digitalRead(SIREN_SENSE_PIN);
          if (value != 1) //We are still in an alarm state
          {
            alarmOn++;
          }
        }
      }
          if (alarmOn < 1)
          {
            // We don't have any sign that we are still in an alarm status
            //Send all clear msg to controller
            //sensor_node.send(msg.set("0"));
            send(msg.setSensor(CHILD_ID).set("0"), true);
            // Used to update the node - NOT used for battery check.
            sendBatteryLevel(random(1, 100) );
            Serial.println("All Clear");
            return 1;
          } 
          else
          {
            // We are still in an alarm status
            //The calling function will handle sending NOT CLEAR to controller        
            Serial.println("NOT CLEAR");
            return 0;
          }    
    }
    
    My Project
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular