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
  1. Home
  2. My Project
  3. 'MySensoring' a Kidde Smoke Detector. (Completed)

'MySensoring' a Kidde Smoke Detector. (Completed)

Scheduled Pinned Locked Moved My Project
smoke detector
30 Posts 7 Posters 22.7k Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • RJ_MakeR Offline
    RJ_MakeR Offline
    RJ_Make
    Hero Member
    wrote on last edited by RJ_Make
    #1

    Was going to submit under the contest, but I don't think I'm going to make it. (plus I'm going to need some help with the logic)

    I don't have any pictures yet, but here is here are the basics..
    **
    Mod Goals:**

    1. Detect when the siren is powered up and transmit that "trip" to Vera (for various processes)
    2. Use interrupt to start Arduino with a 9 hour "heart beat".

    What I have now:

    1. The hardware mod is complete. (using a pro-mini but wanted to use a Attiny85 mini but slooooow shipping)
      I'm using Optocoupler for the speaker power isolation (you could probably just sense the 3.3v speaker voltage directly).

    Kidde Detector Used

    I have 2 Questions:

    1. Shouldn't there be a "Tripped" button or something on the device that is created in Vera?

    Screen Shot 02-05-15 at 12.57 PM.PNG

    1. For some reason this code will not allow the sensor to wake on CHANGE, FALLING or FALLING interrupt.

      // Sleep until something happens with the sensor
      sensor_node.sleep(SIREN_SENSE_PIN,FALLING,SLEEP_TIME * 1000);

    Here is the entire (Not anywhere completed) Sketch:

    	// Based on Author: Patrick 'Anticimex' Fallberg Interrupt driven binary switch example with dual interrupts
    
    	#include <MySensor.h>
    	#include <SPI.h>
    	#include <Bounce2.h>
    
    	#define SKETCH_NAME "Smoke Alarm Sensor"
    	#define SKETCH_MAJOR_VER "1"
    	#define SKETCH_MINOR_VER "0"
    
    	#define CHILD_ID 3
    
    	#define SIREN_SENSE_PIN 3   // Arduino Digital I/O pin for optocoupler for siren
    
    	unsigned long SLEEP_TIME = 540; // Sleep time between reads (in seconds)
    	unsigned long CYCLE_TIME = 0; // How long do we want to watch once first detected (in milliseconds)  Used to help stop false alarms
    	unsigned long CYCLE_INTERVAL = 5000; // How long do we want to watch once first detected (in milliseconds)  Used to help stop false alarms
    	int SIREN_AUDIO_COUNT=0;
    	int oldValue=0;
    
    
    	MySensor sensor_node;
    	MyMessage msg(CHILD_ID, V_TRIPPED);
    	Bounce debouncer = Bounce();
    
    	void setup()  
    	{  
    		sensor_node.begin();
    		// Setup the Siren Pin HIGH
    		pinMode(SIREN_SENSE_PIN, INPUT_PULLUP);
    		// Send the sketch version information to the gateway and Controller
    		sensor_node.sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER"."SKETCH_MINOR_VER);
    		sensor_node.present(CHILD_ID, S_SMOKE); 
    		//Set the Cycle Time 
    		CYCLE_TIME = millis ();
    		// After setting up the Siren Pin, setup debouncer interval
    		debouncer.attach(SIREN_SENSE_PIN);
    		debouncer.interval(500);
    	}
    
    	// Loop will iterate on changes on the BUTTON_PINs
    	void loop() 
    	{
    	  if ( (millis () - CYCLE_TIME) >= CYCLE_INTERVAL){
    		 // Short delay to allow buttons to properly settle
    		 sensor_node.sleep(5);
    		 // Check to see if we have a alarm
    		 CheckAlarm();
    		}
    
    	  // Sleep until something happens with the sensor
    	  sensor_node.sleep(SIREN_SENSE_PIN,FALLING,SLEEP_TIME * 1000);
    	} 
    
    	void CheckAlarm()
    	{
    		uint8_t value;
    		static uint8_t sentValue=2;
       
    		debouncer.update();
    		// Get the update value
    		value = debouncer.read();
    
    		Serial.print("Status: ")
    		Serial.println(value)
    
    		if (value != 1) {    //(value != oldValue && value==0) {
    			AlarmDetected();
    		}
    
    	}
    
    	void AlarmDetected()
    	{
    
    
    	}
    

    RJ_Make

    BulldogLowellB 1 Reply Last reply
    0
    • RJ_MakeR RJ_Make

      Was going to submit under the contest, but I don't think I'm going to make it. (plus I'm going to need some help with the logic)

      I don't have any pictures yet, but here is here are the basics..
      **
      Mod Goals:**

      1. Detect when the siren is powered up and transmit that "trip" to Vera (for various processes)
      2. Use interrupt to start Arduino with a 9 hour "heart beat".

      What I have now:

      1. The hardware mod is complete. (using a pro-mini but wanted to use a Attiny85 mini but slooooow shipping)
        I'm using Optocoupler for the speaker power isolation (you could probably just sense the 3.3v speaker voltage directly).

      Kidde Detector Used

      I have 2 Questions:

      1. Shouldn't there be a "Tripped" button or something on the device that is created in Vera?

      Screen Shot 02-05-15 at 12.57 PM.PNG

      1. For some reason this code will not allow the sensor to wake on CHANGE, FALLING or FALLING interrupt.

        // Sleep until something happens with the sensor
        sensor_node.sleep(SIREN_SENSE_PIN,FALLING,SLEEP_TIME * 1000);

      Here is the entire (Not anywhere completed) Sketch:

      	// Based on Author: Patrick 'Anticimex' Fallberg Interrupt driven binary switch example with dual interrupts
      
      	#include <MySensor.h>
      	#include <SPI.h>
      	#include <Bounce2.h>
      
      	#define SKETCH_NAME "Smoke Alarm Sensor"
      	#define SKETCH_MAJOR_VER "1"
      	#define SKETCH_MINOR_VER "0"
      
      	#define CHILD_ID 3
      
      	#define SIREN_SENSE_PIN 3   // Arduino Digital I/O pin for optocoupler for siren
      
      	unsigned long SLEEP_TIME = 540; // Sleep time between reads (in seconds)
      	unsigned long CYCLE_TIME = 0; // How long do we want to watch once first detected (in milliseconds)  Used to help stop false alarms
      	unsigned long CYCLE_INTERVAL = 5000; // How long do we want to watch once first detected (in milliseconds)  Used to help stop false alarms
      	int SIREN_AUDIO_COUNT=0;
      	int oldValue=0;
      
      
      	MySensor sensor_node;
      	MyMessage msg(CHILD_ID, V_TRIPPED);
      	Bounce debouncer = Bounce();
      
      	void setup()  
      	{  
      		sensor_node.begin();
      		// Setup the Siren Pin HIGH
      		pinMode(SIREN_SENSE_PIN, INPUT_PULLUP);
      		// Send the sketch version information to the gateway and Controller
      		sensor_node.sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER"."SKETCH_MINOR_VER);
      		sensor_node.present(CHILD_ID, S_SMOKE); 
      		//Set the Cycle Time 
      		CYCLE_TIME = millis ();
      		// After setting up the Siren Pin, setup debouncer interval
      		debouncer.attach(SIREN_SENSE_PIN);
      		debouncer.interval(500);
      	}
      
      	// Loop will iterate on changes on the BUTTON_PINs
      	void loop() 
      	{
      	  if ( (millis () - CYCLE_TIME) >= CYCLE_INTERVAL){
      		 // Short delay to allow buttons to properly settle
      		 sensor_node.sleep(5);
      		 // Check to see if we have a alarm
      		 CheckAlarm();
      		}
      
      	  // Sleep until something happens with the sensor
      	  sensor_node.sleep(SIREN_SENSE_PIN,FALLING,SLEEP_TIME * 1000);
      	} 
      
      	void CheckAlarm()
      	{
      		uint8_t value;
      		static uint8_t sentValue=2;
         
      		debouncer.update();
      		// Get the update value
      		value = debouncer.read();
      
      		Serial.print("Status: ")
      		Serial.println(value)
      
      		if (value != 1) {    //(value != oldValue && value==0) {
      			AlarmDetected();
      		}
      
      	}
      
      	void AlarmDetected()
      	{
      
      
      	}
      
      BulldogLowellB Offline
      BulldogLowellB Offline
      BulldogLowell
      Contest Winner
      wrote on last edited by BulldogLowell
      #2

      @ServiceXp said:

      1. Shouldn't there be a "Tripped" button or something on the device that is created in Vera?

      yes, if you used Motion... I've not seen the smoke implementation

       // Sleep until something happens with the sensor
      sensor_node.sleep(SIREN_SENSE_PIN,FALLING,SLEEP_TIME * 1000); 
      

      SIREN_SENSE_PIN argument should be a zero or a one you have 3:

      #define SIREN_SENSE_PIN 3   // Arduino Digital I/O pin for optocoupler for siren
      
      RJ_MakeR 1 Reply Last reply
      0
      • BulldogLowellB BulldogLowell

        @ServiceXp said:

        1. Shouldn't there be a "Tripped" button or something on the device that is created in Vera?

        yes, if you used Motion... I've not seen the smoke implementation

         // Sleep until something happens with the sensor
        sensor_node.sleep(SIREN_SENSE_PIN,FALLING,SLEEP_TIME * 1000); 
        

        SIREN_SENSE_PIN argument should be a zero or a one you have 3:

        #define SIREN_SENSE_PIN 3   // Arduino Digital I/O pin for optocoupler for siren
        
        RJ_MakeR Offline
        RJ_MakeR Offline
        RJ_Make
        Hero Member
        wrote on last edited by
        #3

        @BulldogLowell

        Thanks for your help, below worked perfectly.

        sensor_node.sleep(SIREN_SENSE_PIN-2,FALLING,SLEEP_TIME * 1000);
        

        So how do I add a button or some kind of Icon (I guess like a light bulb or something) and get it to change state for smoke detection in Vera (UI1.5) ?

        Something like this would be cool (just one button needed though)...

        2015-02-06_17-51-46.png

        RJ_Make

        1 Reply Last reply
        0
        • BulldogLowellB Offline
          BulldogLowellB Offline
          BulldogLowell
          Contest Winner
          wrote on last edited by
          #4

          Look at the device files for the Motion sensor...

          you can see how the image file is toggled, and you could then toggle between your nice Smoke Sensor image and another (e.g. red) version of the sensor to indicate "tripped"

          RJ_MakeR 1 Reply Last reply
          0
          • BulldogLowellB BulldogLowell

            Look at the device files for the Motion sensor...

            you can see how the image file is toggled, and you could then toggle between your nice Smoke Sensor image and another (e.g. red) version of the sensor to indicate "tripped"

            RJ_MakeR Offline
            RJ_MakeR Offline
            RJ_Make
            Hero Member
            wrote on last edited by
            #5

            @BulldogLowell

            Where does one find these files you speak of? :-)

            RJ_Make

            BulldogLowellB 1 Reply Last reply
            0
            • RJ_MakeR RJ_Make

              @BulldogLowell

              Where does one find these files you speak of? :-)

              BulldogLowellB Offline
              BulldogLowellB Offline
              BulldogLowell
              Contest Winner
              wrote on last edited by
              #6

              @ServiceXp

              each device has xml and json files...

              you can look at Rex's example

              you can create and upload them to your vera.

              Screen Shot 2015-02-06 at 7.21.32 PM.png

              RJ_MakeR 1 Reply Last reply
              0
              • BulldogLowellB BulldogLowell

                @ServiceXp

                each device has xml and json files...

                you can look at Rex's example

                you can create and upload them to your vera.

                Screen Shot 2015-02-06 at 7.21.32 PM.png

                RJ_MakeR Offline
                RJ_MakeR Offline
                RJ_Make
                Hero Member
                wrote on last edited by
                #7

                @BulldogLowell Thank you Sir, I will chew on this for a bit.

                RJ_Make

                1 Reply Last reply
                0
                • RJ_MakeR Offline
                  RJ_MakeR Offline
                  RJ_Make
                  Hero Member
                  wrote on last edited by
                  #8

                  Is there a max sleep time allowed? What am I doing wrong...? it's not sleeping for 9 hours.. Not even close. And I've confirmed it's not waking on interrupt.

                  unsigned long SLEEP_TIME			= 32400;
                  
                  sensor_node.sleep(SIREN_SENSE_PIN-2,FALLING, SLEEP_TIME * 1000);
                  

                  RJ_Make

                  BulldogLowellB 1 Reply Last reply
                  0
                  • RJ_MakeR RJ_Make

                    Is there a max sleep time allowed? What am I doing wrong...? it's not sleeping for 9 hours.. Not even close. And I've confirmed it's not waking on interrupt.

                    unsigned long SLEEP_TIME			= 32400;
                    
                    sensor_node.sleep(SIREN_SENSE_PIN-2,FALLING, SLEEP_TIME * 1000);
                    
                    BulldogLowellB Offline
                    BulldogLowellB Offline
                    BulldogLowell
                    Contest Winner
                    wrote on last edited by BulldogLowell
                    #9

                    @ServiceXp

                    you are overflowing your int!

                    32400 is an int
                    1000 is an int
                    multiply them together and well, there you have it...

                    Try:

                    sensor_node.sleep(SIREN_SENSE_PIN-2,FALLING, SLEEP_TIME * 1000UL);
                    
                    RJ_MakeR 1 Reply Last reply
                    0
                    • BulldogLowellB BulldogLowell

                      @ServiceXp

                      you are overflowing your int!

                      32400 is an int
                      1000 is an int
                      multiply them together and well, there you have it...

                      Try:

                      sensor_node.sleep(SIREN_SENSE_PIN-2,FALLING, SLEEP_TIME * 1000UL);
                      
                      RJ_MakeR Offline
                      RJ_MakeR Offline
                      RJ_Make
                      Hero Member
                      wrote on last edited by RJ_Make
                      #10

                      @BulldogLowell Thanks, Can you point me to an explanation to what the UL does? Coding for me is like herding cats, I can't ever seem to get it right.. :-)

                      RJ_Make

                      BulldogLowellB 1 Reply Last reply
                      0
                      • RJ_MakeR RJ_Make

                        @BulldogLowell Thanks, Can you point me to an explanation to what the UL does? Coding for me is like herding cats, I can't ever seem to get it right.. :-)

                        BulldogLowellB Offline
                        BulldogLowellB Offline
                        BulldogLowell
                        Contest Winner
                        wrote on last edited by BulldogLowell
                        #11

                        @ServiceXp

                        sure,

                        here in arduino land an int is 16 bits, and default is signed

                        so for 16 bit ints, the maximum representable value 2^(16 − 1) =32,768 (signed)

                        adding the UL tells the compiler "Hey dude, I'm an Unsigned Long!"

                        UL's are 32bit... and for 32 bits, well the the maximum representable value 2^32 = 4,294,967,295

                        RJ_MakeR 1 Reply Last reply
                        1
                        • BulldogLowellB BulldogLowell

                          @ServiceXp

                          sure,

                          here in arduino land an int is 16 bits, and default is signed

                          so for 16 bit ints, the maximum representable value 2^(16 − 1) =32,768 (signed)

                          adding the UL tells the compiler "Hey dude, I'm an Unsigned Long!"

                          UL's are 32bit... and for 32 bits, well the the maximum representable value 2^32 = 4,294,967,295

                          RJ_MakeR Offline
                          RJ_MakeR Offline
                          RJ_Make
                          Hero Member
                          wrote on last edited by
                          #12

                          @BulldogLowell ah, very cool, Thanks for the explanation.

                          RJ_Make

                          1 Reply Last reply
                          0
                          • RJ_MakeR Offline
                            RJ_MakeR Offline
                            RJ_Make
                            Hero Member
                            wrote on last edited by
                            #13

                            I think it's complete.

                            Hardware wise this project is VERY easy to complete. The hardest part was arranging the hardware to fit in the case. The sketch on the other hand was a pain in my butt and I'm sure it's VERY inefficient, but does seem to work without ANY false alarms.

                            Thanks to @BulldogLowell for the help!

                            Mod Goals:

                            1. Detect when the siren is powered up and transmit that "trip" to Vera (for various processes)
                            2. Use interrupt to start Arduino with a 9 hour "heart beat".
                            3. Utilize the detectors battery power.

                            Because this detector has on-board battery level checks and warnings, I don't have to mess around with building a battery circuit.

                            BOM:

                            1. Pro Mini
                            2. I'm using Optocoupler for the speaker power isolation (you could probably just sense the 3.3v speaker voltage directly).
                            3. Kidde Detector Used (any can be used providing you have the space inside)

                            Here is the sketch:

                            	// Based on Author: Patrick 'Anticimex' Fallberg Interrupt driven binary switch example with dual interrupts
                            
                            	#include <MySensor.h>
                            	#include <SPI.h>
                            
                            	#define SKETCH_NAME "Smoke Alarm Sensor"
                            	#define SKETCH_MAJOR_VER "1"
                            	#define SKETCH_MINOR_VER "0"
                            
                            	#define CHILD_ID 3
                            
                            	#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		= 9; // 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;
                            
                            
                            	MySensor sensor_node;
                            	MyMessage msg(CHILD_ID, V_TRIPPED);
                            
                            	void setup()  
                            	{  
                            		sensor_node.begin();
                            		// Setup the Siren Pin HIGH
                            		pinMode(SIREN_SENSE_PIN, INPUT_PULLUP);
                            		// Send the sketch version information to the gateway and Controller
                            		sensor_node.sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER"."SKETCH_MINOR_VER);
                            		sensor_node.present(CHILD_ID, S_SMOKE); 
                            	}
                            
                            	// 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
                            		sensor_node.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"));
                            						  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"));
                            					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;
                            				} 	 
                            
                             }
                            

                            Here is the wiring:
                            MySensorsKiddeSmokeDetector_bb.png

                            Here are some finished hardware pics:

                            20150207_104613.jpg

                            20150207_104619.jpg

                            20150207_104640.jpg

                            20150207_104707.jpg

                            20150207_183259.jpg

                            RJ_Make

                            DrJeffD 1 Reply Last reply
                            3
                            • petewillP Offline
                              petewillP Offline
                              petewill
                              Admin
                              wrote on last edited by
                              #14

                              Awesome job! This was on my list of things to do and you have just made it easier for me. Thanks!

                              It also looks like you were able to get the smoke device working, correct? If so, that's even cooler!

                              My "How To" home automation video channel: https://www.youtube.com/channel/UCq_Evyh5PQALx4m4CQuxqkA

                              RJ_MakeR 1 Reply Last reply
                              0
                              • petewillP petewill

                                Awesome job! This was on my list of things to do and you have just made it easier for me. Thanks!

                                It also looks like you were able to get the smoke device working, correct? If so, that's even cooler!

                                RJ_MakeR Offline
                                RJ_MakeR Offline
                                RJ_Make
                                Hero Member
                                wrote on last edited by
                                #15

                                @petewill Thanks, and no the Vera device is not complete. I have A LOT to learn before I can make the device visual active. That said, the default Vera device that is created works; it just doesn't have any visually active changes.

                                The good news it AuthomationHD and ImperiHome have visually active displays that work perfectly with the default Vera device.

                                Hopefully that is clearer then it's written.. :-)

                                RJ_Make

                                1 Reply Last reply
                                0
                                • petewillP Offline
                                  petewillP Offline
                                  petewill
                                  Admin
                                  wrote on last edited by
                                  #16

                                  Yep, that makes sense. Thanks!

                                  My "How To" home automation video channel: https://www.youtube.com/channel/UCq_Evyh5PQALx4m4CQuxqkA

                                  1 Reply Last reply
                                  0
                                  • BulldogLowellB Offline
                                    BulldogLowellB Offline
                                    BulldogLowell
                                    Contest Winner
                                    wrote on last edited by
                                    #17

                                    @ServiceXp said:

                                    That said, the default Vera device that is created works; it just doesn't have any visually active changes.

                                    you could always just add a Motion device until you learn how to mod your device...

                                    Great job here.

                                    1 Reply Last reply
                                    0
                                    • RJ_MakeR RJ_Make

                                      I think it's complete.

                                      Hardware wise this project is VERY easy to complete. The hardest part was arranging the hardware to fit in the case. The sketch on the other hand was a pain in my butt and I'm sure it's VERY inefficient, but does seem to work without ANY false alarms.

                                      Thanks to @BulldogLowell for the help!

                                      Mod Goals:

                                      1. Detect when the siren is powered up and transmit that "trip" to Vera (for various processes)
                                      2. Use interrupt to start Arduino with a 9 hour "heart beat".
                                      3. Utilize the detectors battery power.

                                      Because this detector has on-board battery level checks and warnings, I don't have to mess around with building a battery circuit.

                                      BOM:

                                      1. Pro Mini
                                      2. I'm using Optocoupler for the speaker power isolation (you could probably just sense the 3.3v speaker voltage directly).
                                      3. Kidde Detector Used (any can be used providing you have the space inside)

                                      Here is the sketch:

                                      	// Based on Author: Patrick 'Anticimex' Fallberg Interrupt driven binary switch example with dual interrupts
                                      
                                      	#include <MySensor.h>
                                      	#include <SPI.h>
                                      
                                      	#define SKETCH_NAME "Smoke Alarm Sensor"
                                      	#define SKETCH_MAJOR_VER "1"
                                      	#define SKETCH_MINOR_VER "0"
                                      
                                      	#define CHILD_ID 3
                                      
                                      	#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		= 9; // 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;
                                      
                                      
                                      	MySensor sensor_node;
                                      	MyMessage msg(CHILD_ID, V_TRIPPED);
                                      
                                      	void setup()  
                                      	{  
                                      		sensor_node.begin();
                                      		// Setup the Siren Pin HIGH
                                      		pinMode(SIREN_SENSE_PIN, INPUT_PULLUP);
                                      		// Send the sketch version information to the gateway and Controller
                                      		sensor_node.sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER"."SKETCH_MINOR_VER);
                                      		sensor_node.present(CHILD_ID, S_SMOKE); 
                                      	}
                                      
                                      	// 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
                                      		sensor_node.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"));
                                      						  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"));
                                      					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;
                                      				} 	 
                                      
                                       }
                                      

                                      Here is the wiring:
                                      MySensorsKiddeSmokeDetector_bb.png

                                      Here are some finished hardware pics:

                                      20150207_104613.jpg

                                      20150207_104619.jpg

                                      20150207_104640.jpg

                                      20150207_104707.jpg

                                      20150207_183259.jpg

                                      DrJeffD Offline
                                      DrJeffD Offline
                                      DrJeff
                                      wrote on last edited by DrJeff
                                      #18

                                      @ServiceXp Are you grabbing the 4V8 and inputting to 3V3 arduino RAW pin? Or are you grabbing the power off J3 Pin1 and 2 at 3V3? Did you make your Arduino less Power hungry i.e. remove LEDs, Regulator, and such? How is the battery life so far? Sorry lots of questions I want to build this for my whole house like 10 of them! But gotta start from some where. I'm thinking most of them are A/C powered in my house so a 5V power supply with a regulator for the detector would work also. Please Let me know how yours is working so far.
                                      Thanks! Great Job!

                                      RJ_MakeR 1 Reply Last reply
                                      0
                                      • DrJeffD DrJeff

                                        @ServiceXp Are you grabbing the 4V8 and inputting to 3V3 arduino RAW pin? Or are you grabbing the power off J3 Pin1 and 2 at 3V3? Did you make your Arduino less Power hungry i.e. remove LEDs, Regulator, and such? How is the battery life so far? Sorry lots of questions I want to build this for my whole house like 10 of them! But gotta start from some where. I'm thinking most of them are A/C powered in my house so a 5V power supply with a regulator for the detector would work also. Please Let me know how yours is working so far.
                                        Thanks! Great Job!

                                        RJ_MakeR Offline
                                        RJ_MakeR Offline
                                        RJ_Make
                                        Hero Member
                                        wrote on last edited by
                                        #19

                                        @DrJeff

                                        1. 4v8 into RAW
                                        2. 3v3 pin to radio
                                        3. all LED's removed
                                        4. Regulator remains to power radio

                                        I have not changed the batteries since I posted, and the heart beat is still sending every 9 hrs

                                        RJ_Make

                                        DrJeffD 1 Reply Last reply
                                        0
                                        • RJ_MakeR RJ_Make

                                          @DrJeff

                                          1. 4v8 into RAW
                                          2. 3v3 pin to radio
                                          3. all LED's removed
                                          4. Regulator remains to power radio

                                          I have not changed the batteries since I posted, and the heart beat is still sending every 9 hrs

                                          DrJeffD Offline
                                          DrJeffD Offline
                                          DrJeff
                                          wrote on last edited by
                                          #20

                                          @ServiceXp Cool I just tested it and was ready build my first unit. I will post after I do it tonight! Have you tried to sniff the Jumpers for signals(like the CO2 or Smoke)? You said you are using the built in battery low detection are you talking about the warning that the batteries need to be replaced locally or remote? Oh Nevermind it will alarm so you will know remote and audible siren and voice local.

                                          The 3V3 off the board proves to be clean enough? I read somewhere that that might be a problem.

                                          Thanks

                                          RJ_MakeR 2 Replies Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          11

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


                                          Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

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