Home alarm system retrofit.


37 posts   Page 1 of 2   1, 2
by lmcc » Tue Aug 28, 2012 3:23 pm
Hello Forum,

I have a simple project underway that might be of interest to some RPi users. I'm retrofitting the burglar alarm in my house with an RPi.

My house already had an alarm system in it when we moved in. I couldn't bring myself to have it activated or monitored by the alarm company. (Why would I pay a monthly monitoring fee to have them call me after I've been burglarized?)

So anyway, I've installed my RPi in the same cabinet as the old alarm system. It's powered by an old ATX computer power supply. (The older ones are great since the 5V stand-by power line is rated at 2.2A with the PS turned "off".)

One-by-one I've moved three door sensors (magnetic reed switches), an infra-red motion detector, and a smoke detector to the GPIOs on the RPi. All the devices switch between impedance states when activated. All I had to do was set the GPIO pull-ups and connect the sensors. (I was thinking about putting some Zeners across the inputs to protect them, but I might not bother....)

On the software side I have test code (python script using RPi.GPIO-0.3.1a ) which confirms the sensor input's correct operation. I have test code which will send my cell phone a text message from my GMail account. I've installed Postgres to log alarm system events.

All I need to do now is glue it all together into some kind of coherent alarm software system. If this gets a few reads and replies I will post an image of my horrible wiring.

Thanks for reading.

-L
Posts: 25
Joined: Wed Jul 25, 2012 11:25 pm
Location: Winnipeg, Canada
by joshmosh » Wed Aug 29, 2012 12:25 pm
Hi,
interesting to read for me. I do not (yet) have an alarm system, since a couple of weeks ago somebody broke in, I'm now have started thinking about it.
Currently my Raspi mainly does nothing, besides acting as print server and ebook server. An alarm system is not CPU consuming, so I guess the Raspi could do that job as well and still would be idling 99% of the time.
The main road block for me is the required cabling for door/window contacts.

Looking forward for your next report
Joshi
Posts: 62
Joined: Fri Aug 03, 2012 12:04 pm
by sjfaustino » Wed Aug 29, 2012 2:40 pm
lmcc wrote:I have test code which will send my cell phone a text message from my GMail account. I've installed Postgres to log alarm system events.

I'm interested in this, is it possible to paste your code?
Posts: 87
Joined: Tue Jun 12, 2012 5:21 pm
by lmcc » Wed Aug 29, 2012 3:14 pm
sjfaustino wrote:
lmcc wrote:I have test code which will send my cell phone a text message from my GMail account. I've installed Postgres to log alarm system events.

I'm interested in this, is it possible to paste your code?


I basically stole this dude's example, and ran it on my RPi. (It ran fine.) :

http://www.drewconway.com/zia/?p=2707

My telecom service provider (MTS) has an email-to-text gateway which lets you send email messages to 1204xxxxxxx@text.mts.net. (I assume other providers have similar.) Of course, you kids with your shiney IPhones and Androids probably don't need to bother with conversion to text messages.

-L
Posts: 25
Joined: Wed Jul 25, 2012 11:25 pm
Location: Winnipeg, Canada
by lmcc » Wed Aug 29, 2012 6:05 pm
As promised I've taken an image of the wiring. The picture is grainy to protect delicate sensibilities from the horror (and because there is poor lighting under my stairs) .

Legacy alarm control board on top. Prototyping breadboard underneath. RPi board below. Decorative 12V backlup battery on the bottom left. ATX power supply to the right of the cabinet.

Image

-L
Posts: 25
Joined: Wed Jul 25, 2012 11:25 pm
Location: Winnipeg, Canada
by ld13 » Sun Sep 30, 2012 8:25 pm
Any progress on this? Mind posting your exact code and maybe a higher quality picture so that we can have a look at your exact setup there?

Thx
Posts: 3
Joined: Sun Jul 08, 2012 1:02 pm
Location: Cape Town, South Africa
by lmcc » Tue Oct 02, 2012 2:51 am
ld13 wrote:Any progress on this? Mind posting your exact code and maybe a higher quality picture so that we can have a look at your exact setup there?

Thx


Not much progress. I wanted to log system activity to a Postgres DB and was looking at various object-persistence libraries. I think I will try playing KiokuDB (perl) and see what I can hack together. The weather is getting colder here so I will likely put more effort into it in the coming weeks. Thanks for your interest.

-L
Posts: 25
Joined: Wed Jul 25, 2012 11:25 pm
Location: Winnipeg, Canada
by rlust » Tue Oct 02, 2012 1:11 pm
Looking forward to your code! Thanks for your work on this!
Posts: 2
Joined: Thu Aug 30, 2012 4:22 pm
by joe2act » Thu Oct 04, 2012 3:09 pm
Hi,

Interesting idea for me. The email alarm notification is very useful. Looking forward for your next report.
Posts: 40
Joined: Tue Jul 24, 2012 4:21 am
by tedhale » Thu Oct 04, 2012 4:54 pm
I am also using one of my RasPis for an alarm/automation system. It monitors the door switches and motion detectors via GPIO input and uses X10 to control lighting.
Eventually I will add temperature inputs to monitor indoors, outdoors, hot tub, and my beer fridge (I'm a homebrewer)

I have had such a system running on a PC for several years, but it died a few months ago, so I am replacing it with a RasPi.
I'm still working on the interface board, so I don't have it hooked up yet. (I am too busy to get much hobby time at the moment.)

You can follow my progress on my blog (listed in my sig block)

Note - I am targeting this blog for beginner hobbyists so the content will seem pretty lame to anyone with much experience.

After reading about sending data to cosm.com (the internet of things) in the MagPi, I have decided to add that to my software.
- Ted B. Hale
http://raspberrypihobbyist.blogspot.com
User avatar
Posts: 105
Joined: Thu Sep 20, 2012 4:52 pm
Location: Williamsburg, VA, USA
by lmcc » Thu Oct 04, 2012 6:18 pm
Well geeze Ted, If you're going to go steal all my (both my) fans I guess I better post something.

Here is the email test script I poached and mangled from http://www.drewconway.com:

Code: Select all
#!/usr/bin/env python

import smtplib
from datetime import datetime

def sendEMail(usr, psw, fromaddr, toaddr):
    """
Send a test email message through GMail.
usr : the GMail username, as a string
psw : the GMail password, as a string
fromaddr : the email address the message will be from, as a string
toaddr : a email address, or a list of addresses, to send the message to
"""

    # Initialize SMTP server
    server=smtplib.SMTP('smtp.gmail.com:587')
    server.starttls()
    server.login(usr,psw)

    # Send email
    senddate=datetime.strftime(datetime.now(), '%Y-%m-%d')
    subject="Test Message from RPi"
    m="Date: %s\r\nFrom: %s\r\nTo: %s\r\nSubject: %s\r\nX-Mailer: My-Mail\r\n\r\n" % (senddate, fromaddr, toaddr, subject)
    msg='''Hello all my friends. How are you today?'''

    server.sendmail(fromaddr, toaddr, m+msg)
    server.quit()


if __name__ == '__main__':

    # Fill these in with the appropriate info...
    usr='joe.user'
    psw='nicetrywiseguy'
    fromaddr='joe.user@gmail.com'
    toaddr='12045551234@text.mts.net'

    # Send notification email
    sendEMail(usr, psw, fromaddr, toaddr)


Here is the test script that I used to validate my alarm system sensor to RPi wiring. Its very simple and crude and basically a corruption of the Python PRi.GPIO module's example code.

Code: Select all
#!/usr/bin/env python

from time import sleep
from datetime import datetime
import RPi.GPIO as GPIO

# to use Raspberry Pi board pin numbers
GPIO.setmode(GPIO.BOARD)

# set up GPIO input with pull-up control
#   (pull_up_down be PUD_OFF, PUD_UP or PUD_DOWN, default PUD_OFF)
GPIO.setup(3, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(5, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(7, GPIO.IN, pull_up_down=GPIO.PUD_UP)

GPIO.setup(11, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(13, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(15, GPIO.IN, pull_up_down=GPIO.PUD_UP)

###################

if __name__ == '__main__':

    i=0
    prev_pin_3 = GPIO.input(3)
    prev_pin_5 = GPIO.input(5)
    prev_pin_7 = GPIO.input(7)

    prev_pin_11 = GPIO.input(11)
    prev_pin_12 = GPIO.input(12)
    prev_pin_13 = GPIO.input(13)
    prev_pin_15 = GPIO.input(15)

    while (True):
        sleep(1)

        pin_3 = GPIO.input(3)
        pin_5 = GPIO.input(5)
        pin_7 = GPIO.input(7)

        pin_11 = GPIO.input(11)
        pin_12 = GPIO.input(12)
        pin_13 = GPIO.input(13)
        pin_15 = GPIO.input(15)

        if ( ( prev_pin_3  != pin_3  ) or
             ( prev_pin_5  != pin_5  ) or
             ( prev_pin_7  != pin_7  ) or

             ( prev_pin_11 != pin_11 ) or
             ( prev_pin_12 != pin_12 ) or
             ( prev_pin_13 != pin_13 ) or
             ( prev_pin_15 != pin_15 ) ):

            print "%s - State Change %d" % (datetime.now(), i)

        if ( prev_pin_7 != pin_7  ) :
            if ( pin_7 == True ) :
                print "Front door is open."
            else:
                print "Front door is closed."

        if ( prev_pin_11 != pin_11  ) :
            if ( pin_11 == True ) :
                print "Garage door is open."
            else:
                print "Garage door is closed."

        if ( prev_pin_12 != pin_12  ) :
            if ( pin_12 == True ) :
                print "Smoke detector is quiescent."
            else:
                print "Smoke detector is active."

        if ( prev_pin_13 != pin_13 ) :
            if ( pin_13 == True ) :
                print "Patio door is open."
            else:
                print "Patio door is closed."

        if ( prev_pin_15 != pin_15 ) :
            if ( pin_15 == True ) :
                print "Motion detector active."
            else:
                print "Motion detector quiescent."


        if ( ( prev_pin_3  != pin_3  ) or
             ( prev_pin_5  != pin_5  ) or
             ( prev_pin_7  != pin_7  ) or

             ( prev_pin_11 != pin_11 ) or
             ( prev_pin_12 != pin_12 ) or
             ( prev_pin_13 != pin_13 ) or
             ( prev_pin_15 != pin_15 ) ):

            prev_pin_3 = pin_3
            prev_pin_5 = pin_5
            prev_pin_7 = pin_7

            prev_pin_11 = pin_11
            prev_pin_12 = pin_12
            prev_pin_13 = pin_13
            prev_pin_15 = pin_15

            i += 1


I've been pondering this little project ever since I moved into my house in 2007. I never did anything with it until I bought my RPi. The replies to this thread are encouraging me. Thanks guys.

Now i'm going to head over to Ted's place and see what ideas I can poach from him...

-L
Posts: 25
Joined: Wed Jul 25, 2012 11:25 pm
Location: Winnipeg, Canada
by joe2act » Fri Oct 05, 2012 1:15 am
lmcc wrote:Well geeze Ted, If you're going to go steal all my (both my) fans I guess I better post something.

Here is the email test script I poached and mangled from http://www.drewconway.com:

[code]#!/usr/bin/env python

import smtplib
....

I've been pondering this little project ever since I moved into my house in 2007. I never did anything with it until I bought my RPi. The replies to this thread are encouraging me. Thanks guys.

Now i'm going to head over to Ted's place and see what ideas I can poach from him...

-L


@lmcc:

Thanks for sharing your python source codes for email and monitoring. It is a very good reference project. The hardware modifications are at least. It is especially helpful reference project for people with existed alarm system hardware. The old alarm controller is replaced by a new and powerful alarm controller -- RasPi. RasPi can do a lot of things.
Posts: 40
Joined: Tue Jul 24, 2012 4:21 am
by joe2act » Fri Oct 05, 2012 1:33 am
tedhale wrote:I am also using one of my RasPis for an alarm/automation system. It monitors the door switches and motion detectors via GPIO input and uses X10 to control lighting.
Eventually I will add temperature inputs to monitor indoors, outdoors, hot tub, and my beer fridge (I'm a homebrewer)

I have had such a system running on a PC for several years, but it died a few months ago, so I am replacing it with a RasPi.
I'm still working on the interface board, so I don't have it hooked up yet. (I am too busy to get much hobby time at the moment.)

You can follow my progress on my blog (listed in my sig block)

Note - I am targeting this blog for beginner hobbyists so the content will seem pretty lame to anyone with much experience.

After reading about sending data to cosm.com (the internet of things) in the MagPi, I have decided to add that to my software.


A very good blog. It is an exciting project. There are a lot of detailed project hardware descriptions and schematics in your blog. That is very good for beginner hobbyists.

On the software side, I cannot found your software yet. What is the language you are going to use for your software? Is it c/c++, python, or others?
Posts: 40
Joined: Tue Jul 24, 2012 4:21 am
by lmcc » Fri Oct 05, 2012 2:15 am
joe2act wrote:A very good blog. It is an exciting project. There are a lot of detailed project hardware descriptions and schematics in your blog. That is very good for beginner hobbyists.

On the software side, I cannot found your software yet. What is the language you are going to use for your software? Is it c/c++, python, or others?


I was thinking about developing my app post by post here in this thread. What language would you like to see? I know Python is especially popular with the RPi, but I'm feeling rather Perlish...

-L
Posts: 25
Joined: Wed Jul 25, 2012 11:25 pm
Location: Winnipeg, Canada
by joe2act » Fri Oct 05, 2012 3:54 am
lmcc wrote:
I was thinking about developing my app post by post here in this thread. What language would you like to see? I know Python is especially popular with the RPi, but I'm feeling rather Perlish...

-L


I do not have a particular favourite language requirement. Both Perl and Python are good programming language. It is up to you to choose one. You can put more effect on system design using your favourite language.
Posts: 40
Joined: Tue Jul 24, 2012 4:21 am
by lmcc » Fri Oct 05, 2012 12:58 pm
LOLCODE it is!

-L
Posts: 25
Joined: Wed Jul 25, 2012 11:25 pm
Location: Winnipeg, Canada
by tedhale » Fri Oct 05, 2012 1:32 pm
joe2act wrote:
tedhale wrote:I am also using one of my RasPis for an alarm/automation system. It monitors the door switches and motion detectors via GPIO input and uses X10 to control lighting.
Eventually I will add temperature inputs to monitor indoors, outdoors, hot tub, and my beer fridge (I'm a homebrewer)

I have had such a system running on a PC for several years, but it died a few months ago, so I am replacing it with a RasPi.
I'm still working on the interface board, so I don't have it hooked up yet. (I am too busy to get much hobby time at the moment.)

You can follow my progress on my blog (listed in my sig block)

Note - I am targeting this blog for beginner hobbyists so the content will seem pretty lame to anyone with much experience.

After reading about sending data to cosm.com (the internet of things) in the MagPi, I have decided to add that to my software.


A very good blog. It is an exciting project. There are a lot of detailed project hardware descriptions and schematics in your blog. That is very good for beginner hobbyists.

On the software side, I cannot found your software yet. What is the language you are going to use for your software? Is it c/c++, python, or others?


I'm an old fart that prefers to code in C (started with FORTRAN and BASIC back in the seventies. Oh the fun we had using punch cards ;) )
Although now I have been forced to start using C# and .Net at work :cry:

The code is pretty messy since it's been ported back and forth from windows to linux a couple of times.
I will try to clean it up and add lots of comments (I tend to leave them out of my personal projects. It's a bad habit.)
I will probably make the entire project available for download at some point, but I think the best thing for the blog is to cover the code in sections with lots of explanations.

My system does some things that may seem odd - like doing UDP broadcasts of events which can be picked up by any system on my LAN. I have a Windows program that listens and outputs synthesized speech.
I doubt anyone would want to use the system as is, but pieces of it could be very useful for some people.
My main fear is that people will expect me to support it. I barely have time for my hobby as it is, so there will be a disclaimer that the code is totally un-supported.
Another odd thing it has to do is deal with the flakiness of X10. My outside flood lights tend to turn themselves on occasionally and they use a LOT of electricity, so one of my threads sends an off command to all outside lights once every five minutes during the day. The trick then is knowing when it is day or night. It's not as easy as it sounds. Photo sensors won't work, because as soon as I turn on the light it thinks it's daytime and turns it off.
The trick I finally came up with is to use curl_lib to pull a webpage from the US Naval Observatory site that will tell me the times for sunrise and sunset for my location.

I have been in major crunch time at work getting a new release of our software out (I'm a Systems Architect for large defense contractor) but that should let up soon.
Hopefully I can get some good hobby time next week.

I will monitor this thread and post back here when I put up new stuff.
- Ted B. Hale
http://raspberrypihobbyist.blogspot.com
User avatar
Posts: 105
Joined: Thu Sep 20, 2012 4:52 pm
Location: Williamsburg, VA, USA
by tedhale » Tue Oct 09, 2012 2:39 pm
I have a post on my blog now with some of my source code describing:

- How to make a daemon process in C
- How to use background threads
- My data structures
- My GPIO polling thread

at the address in my sig block below.
- Ted B. Hale
http://raspberrypihobbyist.blogspot.com
User avatar
Posts: 105
Joined: Thu Sep 20, 2012 4:52 pm
Location: Williamsburg, VA, USA
by tedhale » Tue Oct 16, 2012 3:47 am
Updated the source code post on my blog with a few corrections. Also, the GPIO poller code supports the multiplexed input.

Also added a new post with a picture of my interface. It is nearly complete.
- Ted B. Hale
http://raspberrypihobbyist.blogspot.com
User avatar
Posts: 105
Joined: Thu Sep 20, 2012 4:52 pm
Location: Williamsburg, VA, USA
by lmcc » Sun Nov 11, 2012 8:51 pm
lmcc wrote:LOLCODE it is!

-L


Well no LOLCODE, but here is an event logger in a few lines of Python. Using Postgres, I store the sensor configuration to one table and log all the alarm sensor events to another. I will think on how to handle alarm event notification and enabling-disabling the system. Suggestions are welcome.

-L

Code: Select all
#!/usr/bin/env python

import psycopg2
from time import sleep
import RPi.GPIO as GPIO

db="lmcc"
db_user="lmcc"
db_host="localhost"
db_password='1234567890'

polling_interval = 1
tss_table = "two_state_sensors"
tss_event = "two_state_sensor_events"

class Sensor:
    pass

class Event:
    pass

def table_exists(conn, cur, table):

    try :
        cur.execute("select * from information_schema.tables where table_name=%s", (table,))
    except Exception, e:
        print "I am have failed to check for the existence of table %s." % table
        print str(e)
        exit()

    return bool(cur.rowcount)

def create_sensor_table(conn, cur, tss_table):

    sensorTableCreationCmd = """
    CREATE TABLE %s (
        name text,
        pin_index integer,
        normal_state integer,
        normal_text text,
        abnormal_text text
    );
    """ % tss_table

    sensorTablePopulateCmd = """
    INSERT INTO %s (name, pin_index, normal_state, normal_text, abnormal_text) VALUES
    """ % tss_table

    try :
        cur.execute(sensorTableCreationCmd)
    except Exception, e:
        print "I am unable to create sensor table.", str(e)
        exit()

    for sensor_record in [ ('Front Door',       7, 0, 'closed',    'open'),
                           ('Garage Door',     11, 0, 'closed',    'open'),
                           ('Smoke Detector',  12, 1, 'quiescent', 'in alarm'),
                           ('Patio Door',      13, 0, 'closed',    'open'),
                           ('Motion Detector', 15, 0, 'quiescent', 'detects motion') ]:
        cur.execute(sensorTablePopulateCmd + " (%s, %s, %s, %s, %s)", sensor_record)

    conn.commit()

def create_event_table(conn, cur, tss_events):

    eventTableCreationCmd = """
    CREATE TABLE %s (
        description text,
        pin_index integer,
        pin_state integer,
        time_of_occurance timestamp
    );
    """ % tss_events

    cur = conn.cursor()
    try :
        cur.execute(eventTableCreationCmd)
        conn.commit()
    except Exception, e:
        print "I am unable to create event table.", str(e)
        exit()

    conn.commit()

def init_sensors(cur, sensor_table):

    try:
        cur.execute("select * from %s;" % sensor_table )
    except Exception, e:
        print "Unable to read sensor table", str(e)
        exit()

    rows = cur.fetchall()

    sensors = []

    for r in rows:
        s = Sensor()
        (s.name, s.pin_index, s.normal_state, s.normal_text, s.abnormal_text) = r
        s.state = s.normal_state
        s.previous_state = s.normal_state

        sensors.append(s)

    return sensors

def init_GPIO(sensors):

    GPIO.setmode(GPIO.BOARD)

    for s in sensors:
        GPIO.setup(s.pin_index, GPIO.IN, pull_up_down=GPIO.PUD_UP)

def log_2state_events(conn, cur, event_table, sensors):

    insert_statement = "INSERT INTO %s " % event_table
    insert_statement += "(description, pin_index, pin_state, time_of_occurance) VALUES (%s, %s, %s, 'now');"

    for s in sensors:
        if GPIO.input(s.pin_index):
            s.state = 1
        else:
            s.state = 0

        if (s.state != s.previous_state):

            e = Event()

            if (s.state == s.normal_state):
                e.description = "%s is %s." % (s.name, s.normal_text)
            else:
                e.description = "%s is %s." % (s.name, s.abnormal_text)

            try:
                cur.execute(insert_statement, (e.description, s.pin_index, s.state ))
            except Exception, e:
                print "Unable to insert into sensor table", str(e)
                exit()

            s.previous_state = s.state

    conn.commit()

if __name__ == "__main__":

    try:
      conn = psycopg2.connect(database=db, user=db_user, host=db_host, password=db_password)
    except Exception, e:
      print "I am unable to connect to the database", str(e)
      exit()

    cur = conn.cursor()

    if (not table_exists(conn, cur, tss_table)):
        create_sensor_table(conn, cur, tss_table)
    if (not table_exists(conn, cur, tss_event)):
        create_event_table(conn, cur, tss_event)
    sensors = init_sensors(cur, tss_table)
    init_GPIO(sensors)

    while (True):
        log_2state_events(conn, cur, tss_event, sensors)
        sleep(polling_interval)

    cur.close()
    conn.close()
Posts: 25
Joined: Wed Jul 25, 2012 11:25 pm
Location: Winnipeg, Canada
by tedhale » Mon Nov 12, 2012 3:36 pm
Polling GPIO with Python is fine if the signals you need to read do not change too quickly.
If you poll using C, you will see several orders of magnitude increase in speed. (or far less CPU used if you throttle the polling.)
For a home alarm system, Python should be OK.
- Ted B. Hale
http://raspberrypihobbyist.blogspot.com
User avatar
Posts: 105
Joined: Thu Sep 20, 2012 4:52 pm
Location: Williamsburg, VA, USA
by lmcc » Mon Nov 12, 2012 3:47 pm
tedhale wrote:Polling GPIO with Python is fine if the signals you need to read do not change too quickly.
If you poll using C, you will see several orders of magnitude increase in speed. (or far less CPU used if you throttle the polling.)
For a home alarm system, Python should be OK.


You're absolutely right. If someone kicks down my door and closes it within 1s, they may defeat my alarm system.

-L
Posts: 25
Joined: Wed Jul 25, 2012 11:25 pm
Location: Winnipeg, Canada
by tedhale » Mon Nov 12, 2012 4:10 pm
Yep.
I use two levels of alarms. Door switches and motion detectors.

The motion detectors will remain on for a pre-defined period of time once triggered, so there is no way that a program in Python would miss that.

Plus, they have to do this without making my dog bark. Good luck with that. She even barks at me when I come in.
- Ted B. Hale
http://raspberrypihobbyist.blogspot.com
User avatar
Posts: 105
Joined: Thu Sep 20, 2012 4:52 pm
Location: Williamsburg, VA, USA
by joe2act » Wed Nov 21, 2012 8:57 pm
lmcc wrote:Well no LOLCODE, but here is an event logger in a few lines of Python. Using Postgres, I store the sensor configuration to one table and log all the alarm sensor events to another. I will think on how to handle alarm event notification and enabling-disabling the system. Suggestions are welcome.

-L


Glad to see new system functions.

I suggest that you give each sensor's event a alarm priority. If event has high priority, your alarm system send email to you, or sound a loud alarm. If event has low priority, then your alarm system just log event, or turn on a warning LED indicator on GPIO. For example, an event with both Front Door Sensor and Motion Detector has the highest priority. Moreover, email or a switch on GPIO may be use to enable-disable the system.

Can plain text as event log file save some time and resource in alarm system?
Posts: 40
Joined: Tue Jul 24, 2012 4:21 am
by joe2act » Wed Nov 21, 2012 9:30 pm
tedhale wrote:Polling GPIO with Python is fine if the signals you need to read do not change too quickly.
If you poll using C, you will see several orders of magnitude increase in speed. (or far less CPU used if you throttle the polling.)
For a home alarm system, Python should be OK.


Glad to see you have suggestion for lmcc. Hobbyist developers like you and lmcc maybe can cooperate with each other on the next generation RPi home alarm system?

C program is faster than python program.

However, you can use hardware to solve performance problem because RPi's cheap. If single RPi hardware is not fast enough in python, alarm system can have an additional RPi. Then, RPi#1 polls one group sensors, and RPi#2 polls another group sensors. In future, a new RPi model C can boost python performance too.
Posts: 40
Joined: Tue Jul 24, 2012 4:21 am