happyff
Posts: 5
Joined: Sat Sep 14, 2013 7:22 pm

Smoke detector to text message

Sat Sep 14, 2013 8:01 pm

This is my first post. I have read other posts and grabbed tidbits of info from here and there. So, I want to give back.
I wanted something to connect to my hard wired AC smoke detectors that would send me a text when they alert. We had a fire a couple of years ago, and the detectors were activating for 4 hours before my wife returned home to find the fire. This would have saved a lot of headaches....

Any ways here goes:
The hard wired detectors have 3 wires. Hot, neutral and a sensing wire. The sensing wire sends 9 volts to the other detectors if one activates. So, I connected that to input 17 using an interface circuit that can be made for only a few bucks with parts from Radio Shack. I added an LED to the base of the transistor just to watch the 9v activation.

The program waits 4 seconds before sending the text just to avoid a low battery chirp sending the text. I may have to adjust that later. It will resend every 60 seconds. I will be changing this to 5 minutes.

To power the Pi, I used an old phone charger and a cheap female AC outlet to tie into the hot and neutral powering the smoke detector.

#import mod
import smtplib
from email.mime.text import MIMEText
import RPi.GPIO as GPIO
import time
#setup gpio pins
GPIO.cleanup()
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.IN)
#Print message on screen
print ("Activate to proceed")
time.sleep (25)
#start loop
loop = "1"
while loop == "1":
#test GPIO for input
if not GPIO.input(17):
time.sleep (4)
if not GPIO.input(17):
#create email
message = """Smoke Detector Activation"""
msg = MIMEText(message)
msg['subject'] = 'My Address'
msg['from'] = '[email protected]'
msg['to'] = 'myverizonphone#@vtext.com'
# send mail
s = smtplib.SMTP('smtp.gmail.com', 587)
s.ehlo()
s.starttls()
s.login('[email protected]' , 'myemailpassword')
s.sendmail(msg['From'], msg['To'], msg.as_string())
s.quit
print ("Message sent")
time.sleep(60)
while not GPIO.input(17):
pass
Attachments
finishedpi2.jpg
finishedpi2.jpg (57.34 KiB) Viewed 27957 times
interface.jpg
interface.jpg (21.57 KiB) Viewed 27957 times

garethbrown
Posts: 1
Joined: Wed Oct 02, 2013 8:07 am

Re: Smoke detector to text message

Wed Oct 02, 2013 8:15 am

Hi, I took this another step further and created a wireless version. I had originally thought of hardwiring them, but didn't like the idea of having the raspberry pinned to the ceiling.

If you are interested here is the project.

http://www.safefiredirect.co.uk/blog/pr ... alarm.aspx

The next part of this project, will be to configure it to accept feedback from more than one smoke alarm.

happyff
Posts: 5
Joined: Sat Sep 14, 2013 7:22 pm

Re: Smoke detector to text message

Wed Oct 02, 2013 10:47 pm

I have noticed a problem with my setup, and I think it is more of a Pi issue than the task it is performing.
It seems like the Pi will lock up or go to sleep after several days. If I test the smoke detector every day, it works fine. If I let it sit for 5 or 6 days it will not respond to the smoke or remote desktop.

A simple power cycle of the Pi has the smoke detector to text task working fine each time.

Has anybody used a simple code to cause it to reboot itself every day or couple of days?

billybojangles
Posts: 9
Joined: Fri Feb 15, 2013 2:58 am

Re: Smoke detector to text message

Thu Oct 03, 2013 12:33 am

Hey happff

I have one of my pi's reboot everyday at 7:30am..

from the command line type:

Code: Select all

sudo crontab -e
Page down to the bottom of the file, remember to adjust the time as needed. Add the follow:

Code: Select all

30 7 * * * /sbin/shutdown -r now
Ctrl+X and then Y to save the file and your done..

The also sends me a text to say it rebooted, just so I know it's still working and on the network.

I can give you that code as well if you want it.
happyff wrote:I have noticed a problem with my setup, and I think it is more of a Pi issue than the task it is performing.
It seems like the Pi will lock up or go to sleep after several days. If I test the smoke detector every day, it works fine. If I let it sit for 5 or 6 days it will not respond to the smoke or remote desktop.

A simple power cycle of the Pi has the smoke detector to text task working fine each time.

Has anybody used a simple code to cause it to reboot itself every day or couple of days?

txt3rob
Posts: 368
Joined: Sat Aug 11, 2012 3:45 pm
Location: Liverpool

Re: Smoke detector to text message

Thu Oct 03, 2013 2:36 pm

any one who is in the uk wants help with the sms side i can help :)
https://www.github.com/random-robbie - Infosec tools

happyff
Posts: 5
Joined: Sat Sep 14, 2013 7:22 pm

Re: Smoke detector to text message

Fri Oct 04, 2013 1:37 am

Thank you.
billybojangles wrote:Hey happff

I have one of my pi's reboot everyday at 7:30am..

from the command line type:

Code: Select all

sudo crontab -e
Page down to the bottom of the file, remember to adjust the time as needed. Add the follow:

Code: Select all

30 7 * * * /sbin/shutdown -r now
Ctrl+X and then Y to save the file and your done..

The also sends me a text to say it rebooted, just so I know it's still working and on the network.

I can give you that code as well if you want it.
happyff wrote:I have noticed a problem with my setup, and I think it is more of a Pi issue than the task it is performing.
It seems like the Pi will lock up or go to sleep after several days. If I test the smoke detector every day, it works fine. If I let it sit for 5 or 6 days it will not respond to the smoke or remote desktop.

A simple power cycle of the Pi has the smoke detector to text task working fine each time.

Has anybody used a simple code to cause it to reboot itself every day or couple of days?

burnhaj
Posts: 25
Joined: Sun Mar 09, 2014 3:43 am

Re: Smoke detector to text message

Tue Dec 09, 2014 9:41 pm

I have set up a smoke detector to send me texts as outlined in this post. It works well except for the false alarms. I have traced this to the sensing wire and ground connections to the transistor. Simply grasping the wire that would connect to the sense wire activates the program. It appears to me that the transistor is sensitive to very small voltage changes. I know almost nothing about transistors so I am hoping someone here can help. I bought a pack of three different variety NPN transistors at RadioShack. I am using the 2N222A unit. Should I be using a different transistor? If so, what are the specs for the unit that should be used.

Thank you for your help.

billybojangles
Posts: 9
Joined: Fri Feb 15, 2013 2:58 am

Re: Smoke detector to text message

Tue Dec 09, 2014 10:33 pm

I had the same issue when connected to a CO/smoke detector. But not when attached to a smoke only detector..

happyff
Posts: 5
Joined: Sat Sep 14, 2013 7:22 pm

Re: Smoke detector to text message

Wed Dec 10, 2014 2:08 am

Hello,
glad to see there is still interest in this. I would make sure all of the grounds have a good connection.

What voltage does your sensing wire put out? Mine is 9 volts, which this was designed around.

I also put a LED (a small light will work also) on the sensing wire line to have a visual for troubleshooting. (it sits beside the 2.2k)

Verify you are using the transistor pins correctly. I can find a "2N2222A", but I don't see a "2N222A"

Here is the down n dirty of how the transistor works in this setup.
Normally (A) the 3.3v flows to pin 11. The transistor acts like a switch that is open.

When the smoke detector activates, (1) it sends voltage to the base which closes the switch. (2) This then routes the 3.3v down through the transistor to ground, since there is less resistance.

Pin 11 sees the change in voltage which starts the whole process.

Let us know if this helps or any other questions.
Attachments
rpi.jpg
rpi.jpg (46.71 KiB) Viewed 25015 times

User avatar
aTao
Posts: 1095
Joined: Wed Dec 12, 2012 10:41 am
Location: Howlin Eigg

Re: Smoke detector to text message

Wed Dec 10, 2014 2:30 am

Great project.

Just 1 question, why the transistor? You could just use a resistor potential divider, say 20k and 10k.
>)))'><'(((<

happyff
Posts: 5
Joined: Sat Sep 14, 2013 7:22 pm

Re: Smoke detector to text message

Wed Dec 10, 2014 2:42 am

aTao wrote:Great project.

Just 1 question, why the transistor? You could just use a resistor potential divider, say 20k and 10k.
This was over a year ago, but... I guess I was looking at it from the standpoint of "steering the 3.3v" rather than "dividing the 9v".
And it looks like I may have way over complicated it... :D

burnhaj
Posts: 25
Joined: Sun Mar 09, 2014 3:43 am

Re: Smoke detector to text message

Wed Dec 10, 2014 11:38 am

Thanks a bunch! I will try the voltage divider as my next step. Yes, my detector outputs 9v. to the sense wire upon alarm. Your circuit with the transistor works exactly as you describe, when I apply voltage to the base of the transistor it grounds the collector causing the pin 11 voltage to drop to zero. The problem appears to be that small transient voltages at the base leg cause enough fluctuation at the collector to cause activation. I measure about 3.2 v. at the pin 11 connection with nothing connected to the base leg. If I simply grab the base leg with my fingers that 3.2 v. drops to 2.8- 2.9v. I will keep at it and report back on my findings. I am glad to find that you guys are still out there after this thread sat inactive for over a year!

Here is a simple explanation of voltage dividers: http://hyperphysics.phy-astr.gsu.edu/hb ... oldiv.html

It looks like I need the value of R1 to be twice that of R2. Maybe 20k and 10k for starters?

burnhaj
Posts: 25
Joined: Sun Mar 09, 2014 3:43 am

Re: Smoke detector to text message

Wed Dec 10, 2014 4:45 pm

Update:

I made the voltage divider from materials on hand which were a 4.7k ohm resistor and a 2.2k ohm resistor. Divides the 9v. to about 2.9 v. This seems to be working fine. At least much better than the transistor was! Another change that I made was to use edge detection on the GPIO pin rather than polling it for its status. Polling is very processor intensive (used about 97% CPU when I had it running) Edge detection uses really no CPU until it changes. Here is my code. Please comment on it as I am a neophyte in this regard.

I have my pi also set up to autostart upon restoration of power after a failure. I use a cron job to load the smoke detector at boot and also to reboot the pi daily to keep things clean.


#import mod
import smtplib
from email.mime.text import MIMEText
import RPi.GPIO as GPIO
import time
# setup try loop from the security camera program. Not really sure what it does.
try:
while True:
#setup gpio pins
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.IN)
print ("Activate to proceed")
time.sleep (5)
#wait for rising edge
GPIO.wait_for_edge(17, GPIO.RISING)
#create email
message = """GARAGE Smoke Detector Activation """ + time.strftime("%m/%d/%Y %H:%M")
msg = MIMEText(message)
msg['subject'] = 'ADDRESS'
msg['from'] = '[email protected]'
msg['to'] = '[email protected], [email protected]'
# send mail
s = smtplib.SMTP('smtp.gmail.com', 587)
s.ehlo()
s.starttls()
s.login('[email protected]' , 'password')
s.sendmail(msg["From"], msg["To"].split(","), msg.as_string()) #(msg['From'], msg['To'], msg.as_string())
s.quit
print ("Message sent "), (time.strftime("%m/%d/%Y %H:%M:%S"))
#Wait 5 minutes before checking again.
time.sleep(300)
GPIO.cleanup()

#cleanup
finally:
GPIO.cleanup()

HickoryPi
Posts: 10
Joined: Mon Jan 19, 2015 2:29 pm

Re: Smoke detector to text message

Mon Jan 19, 2015 2:36 pm

Hello everyone. I've been working with the Pi for about 8 months now and have benefited from this forum so I thought I'd chime in on how I solved the smoke detector problem for my vacation property. Having read several other forums about electrical codes and the violation of such codes by connecting directly to the house's smoke detector system, I decided to go a different route. I built a Voice Activated Switch from a kit at rainbowkits.com for $6.45. Upon detection of the smoke detector sound, the switch closes a relay for an adjustable amount of time. I connected the Normally Open part of the SPDT to ground and one GPIO pin defined as input, pulled High. Upon detecting a FALLING EDGE when the relay closes, I generate an SMS and EMAIL 3 times over 15 minutes. I then wait for the condition to clear and signal an all clear the same way when the relay opens up again. In this manner, I have not violated any electrical code and I did not need to touch the smoke detector.

trelex
Posts: 1
Joined: Sun Feb 15, 2015 8:26 am

Re: Smoke detector to text message

Sun Feb 15, 2015 8:38 am

HickoryPi wrote:Hello everyone. I've been working with the Pi for about 8 months now and have benefited from this forum so I thought I'd chime in on how I solved the smoke detector problem for my vacation property. Having read several other forums about electrical codes and the violation of such codes by connecting directly to the house's smoke detector system, I decided to go a different route. I built a Voice Activated Switch from a kit at rainbowkits.com for $6.45. Upon detection of the smoke detector sound, the switch closes a relay for an adjustable amount of time. I connected the Normally Open part of the SPDT to ground and one GPIO pin defined as input, pulled High. Upon detecting a FALLING EDGE when the relay closes, I generate an SMS and EMAIL 3 times over 15 minutes. I then wait for the condition to clear and signal an all clear the same way when the relay opens up again. In this manner, I have not violated any electrical code and I did not need to touch the smoke detector.
HickoryPi, I don't suppose you would mind elaborating on your setup as I am thinking about working on a similar project. Does the kit you use detect the sound from your smoke detector system based on its frequency or does it simply detect all sound but activates the switch according to the length of time the sound is present? Also, at roughly what distance from the smoke detector does your voice activated switch operate? Any additional information would be really helpful.

HickoryPi
Posts: 10
Joined: Mon Jan 19, 2015 2:29 pm

Re: Smoke detector to text message

Sun Feb 15, 2015 4:01 pm

Hello,

My Voice Activated Switch (VOX) "listens" for the smoke detector. Because the microphone naturally hears everything, you have to adjust the gain so that normal sounds like talking don't falsely activate the VOX. I bought a package of Electret microphones for like $2 and used that with the VOX board. The nice thing about those cheap little microphones is that the gain is absolutely not linear across the audio frequency spectrum. What I mean is that the microphones are have alot more gain on higher frequencies than they do at lower frequencies, like the human voice. Typical smoke detectors put out a beep that is around 30K Hz. The microphone is so sensitive, that I originally had an issue with the microphone hearing the relay opening so it would trigger again causing an infinite loop. I fixed this by adding about 3 feet of wire to offset the microphone away from the board. I put my microphone right next to the smoke detector and basically turned down the OP AMP gain, but to be honest, it works over 25 feet away. My code logic is pretty simple. In english, it goes like this:

Define gpio pin as input pulled high
Start infinite loop
Issue a "wait for falling edge command"
***sound causing vox relay to close thus grounding the GPIO pin above and causing it to "fall" in voltage***
Wait about 10 seconds just to see if the pin is still grounded (this filters out false activations)
Restart loop if false
If true alarm, call my SEND MESSAGE code
Increment max number of messages
check to see if the pin is still grounded (in case it cleared)
Repeat SEND MESSAGE loop until max number of messages reached
if pin is no longer grounded, call SEND CLEAR code
SEND CLEAR code once max number messages sent AND pin finally goes high again
Go back to the top and start all over


My VOX closes the relay for about 4 seconds after hearing something and keeps it closed while there is a sound. So basically, it opens +4 seconds after all sound has stopped.

nigratruo
Posts: 27
Joined: Tue Sep 24, 2013 2:20 am

Re: Smoke detector to text message

Sun Aug 02, 2015 2:54 am

This is a very interesting project and I want to also implement it. Is there a revision on the circuit diagram with all the knowhow that you gathered through experimentation? I'm not that well versed in electronics, so I would have a hard time bulding and modifying it myself after reading all the posts on the forum.

HickoryPi
Posts: 10
Joined: Mon Jan 19, 2015 2:29 pm

Re: Smoke detector to text message

Sun Aug 02, 2015 6:12 pm

Actually, all you need to do is buy the RainbowKits Voice Activated Switch. It has all of the information on which resistors to change to make the VOX microphone be more or less sensitive. It also tells you which resistor to change to increase the vox "hang time". All the box really does is open/close it's relay contacts in the presence or loss of sound. The Raspberry Pi just checks the pin connected to the relay and when the relay closes on the vox it routes the GPIO pin to ground causing the voltage to drop to zero. The code does all the rest.

nigratruo
Posts: 27
Joined: Tue Sep 24, 2013 2:20 am

Re: Smoke detector to text message

Sat Aug 08, 2015 11:22 pm

Unfortunately, that is way beyond my skill of electronics. And tuning the voice switch to only detect the smoke alarm and nothing else that is loud (like something falling down or a thunder clap) might be a big challenge.
Also, I already got the smoke alarm with the special lead (interconnect) that "lights up" when the alarm goes off, I wonder why it is so difficult just to detect that signal. Can I maybe use a relay, that the smoke alarm triggers that relay with the signal and that closes a GPIO pin?

HickoryPi
Posts: 10
Joined: Mon Jan 19, 2015 2:29 pm

Re: Smoke detector to text message

Mon Aug 10, 2015 12:12 am

There is absolutely no electrical reason why you can't connect directly to the smoke alarm and detect an activation. The problem is that there are electrical codes that in many areas dictate that cannot do it without violating the code. If you put in a separate smoke detector that isn't connected to the main system in the house you'll be fine. If the smoke detector puts out a voltage on the interconnect pin then all you have to do is connect a relay that opens and closes based on voltage from that pin. That is by far the simplest way to do it. Just be careful with running wires to the rasbperry pi GPIO that are over about 5 feet. You can pick up noise that translates into voltage and is detected by the GPIO pin and causes a false alarm detection.

BassFishin
Posts: 2
Joined: Sat Sep 19, 2015 2:57 am

Re: Smoke detector to text message

Sat Sep 19, 2015 3:02 am

This is a great idea and tutorial. I am inspired by this project and will build it soon.

In the meantime, I was looking up on using a transistor circuit to do something very similar on another project. I have a device that constantly has an LED on. When that LED is on, I have 1.90 VDC constantly. When it drops for one second or less, the voltage drops to 0.00 then back up to 1.90VDC. What are your recommendations to use and to build a circuit to trigger the pi scripts you have to alert me with the one second drop in voltage.

Thanks in advance
Mike

BassFishin
Posts: 2
Joined: Sat Sep 19, 2015 2:57 am

Re: Smoke detector to text message

Sat Sep 19, 2015 3:14 am

That's a great idea HickoryPi. Something to remember for sure. I am working on a project kinda similar to this, my security system.
HickoryPi wrote:Hello everyone. I've been working with the Pi for about 8 months now and have benefited from this forum so I thought I'd chime in on how I solved the smoke detector problem for my vacation property. Having read several other forums about electrical codes and the violation of such codes by connecting directly to the house's smoke detector system, I decided to go a different route. I built a Voice Activated Switch from a kit at rainbowkits.com for $6.45. Upon detection of the smoke detector sound, the switch closes a relay for an adjustable amount of time. I connected the Normally Open part of the SPDT to ground and one GPIO pin defined as input, pulled High. Upon detecting a FALLING EDGE when the relay closes, I generate an SMS and EMAIL 3 times over 15 minutes. I then wait for the condition to clear and signal an all clear the same way when the relay opens up again. In this manner, I have not violated any electrical code and I did not need to touch the smoke detector.

HickoryPi
Posts: 10
Joined: Mon Jan 19, 2015 2:29 pm

Re: Smoke detector to text message

Sun Sep 20, 2015 5:02 pm

Thanks BassFishin. My security system trips the Smoke Detector circuit also. It is ok, since I go to the camera's the first thing no matter what it is. Also, I had to modify the code because Google stopped supporting SMS messages from unapproved apps. Thankfully, T-Mobile supports email to sms so I just use Gmail filtering to create multiple emails and added my T-mobile email address to the stack and I still get an SMS plus emails to different accounts.
BassFishin wrote:That's a great idea HickoryPi. Something to remember for sure. I am working on a project kinda similar to this, my security system.
HickoryPi wrote:Hello everyone. I've been working with the Pi for about 8 months now and have benefited from this forum so I thought I'd chime in on how I solved the smoke detector problem for my vacation property. Having read several other forums about electrical codes and the violation of such codes by connecting directly to the house's smoke detector system, I decided to go a different route. I built a Voice Activated Switch from a kit at rainbowkits.com for $6.45. Upon detection of the smoke detector sound, the switch closes a relay for an adjustable amount of time. I connected the Normally Open part of the SPDT to ground and one GPIO pin defined as input, pulled High. Upon detecting a FALLING EDGE when the relay closes, I generate an SMS and EMAIL 3 times over 15 minutes. I then wait for the condition to clear and signal an all clear the same way when the relay opens up again. In this manner, I have not violated any electrical code and I did not need to touch the smoke detector.

Return to “Automation, sensing and robotics”