1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Communicate Between Alarm Panel and Raspberry PI

Discussion in 'General Electronics Chat' started by backporch, Mar 11, 2016.

  1. backporch

    backporch New Member

    Joined:
    Mar 11, 2016
    Messages:
    11
    Likes:
    0
    Location:
    NJ USA
    Hello,

    I have a project that I would like to work on that would eventually allow me to monitor and control my home alarm from a remote PC or mobile phone. My alarm panel is a Paradox brand (1728 board) from 2002 that cannot communicate with the outside world except through some Ademco format using a land line.

    I am at the very beginning stages of trying to open up this box to a raspberry pi. Not even sure how to do it yet. Would like to have the raspberry pi connect like a keypad on the four wire communication bus. I think the four wires are power, gnd, clock and data.

    One of the biggest issues is the voltage difference between the RPI 3.3v and the Alarm 12v. I saw an interesting writeup on using optocouplers to transfer the signal, but that was only one way. This may be the best solution and I was wondering if anyone was familiar with an IC that may already include these ( or some other components ) in a pre-built, 2 way communication.
     
  2. Les Jones

    Les Jones Well-Known Member

    Joined:
    May 15, 2015
    Messages:
    1,446
    Likes:
    187
    Location:
    Lancashire UK
    I think your first task will be to analyse the protocol of the communications between the main unit and the remote keypad. I expect that there will be LEDs on the keypad so these will need to be controlled. This means the communication needs to be bidirectional.

    Les.
     
  3. backporch

    backporch New Member

    Joined:
    Mar 11, 2016
    Messages:
    11
    Likes:
    0
    Location:
    NJ USA
    Les,
    I know the system supports more than one kepad, so I was thinking my RPI would act like another keypad and definitely I would like communication to be two way.

    How would I go about analyzing the protocol? Sounds like I need an oscilloscope. I have never done that before but I bet I could learn voltage, maybe communication rate, and based on the kepad actions possibly even what the data stands for. Sounds like it might be a lot of trail and error for some things unless there is a standard that most panels use. They don't sell directly to the public so I didn't see a good way to ask for specs from the manufacturer and I don't know if suppliers would take the time to look up that kind of info.
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. Les Jones

    Les Jones Well-Known Member

    Joined:
    May 15, 2015
    Messages:
    1,446
    Likes:
    187
    Location:
    Lancashire UK

    You will need an oscilloscope to try to analyse the protocol. It will almost certainly be a proprietary protocol that the manufacturer will not release.

    Les.
     
  6. backporch

    backporch New Member

    Joined:
    Mar 11, 2016
    Messages:
    11
    Likes:
    0
    Location:
    NJ USA
    So in your opinion, if I get my hands on some equipment is deciphering this a possibility or am I about to spend a lot of effort in vain?
     
  7. Les Jones

    Les Jones Well-Known Member

    Joined:
    May 15, 2015
    Messages:
    1,446
    Likes:
    187
    Location:
    Lancashire UK
    I suspect will need to learn a lot about electronics and programming before you can get started on this project. You will also need a good understanding of how to transfer data over the internet. Although the internet is easy to use understanding exactly how it works is a complex subject. Only you know your skill level in these subjects so only you can decide if you can do this in a reasonable time.

    Les.
     
  8. backporch

    backporch New Member

    Joined:
    Mar 11, 2016
    Messages:
    11
    Likes:
    0
    Location:
    NJ USA
    Les, Thanks for the reality check. I would still like to pursue this as far as I can go. I have a programming background, but the electronics are fairly new to me. In this case I was hoping to find a component that might get me closer than soldering a solution with resistors and optocouplers. New to soldering also.

    So if there is anyone on this forum that can provide a jump start with how the circuitry for this might be created, or even better, a component that can bridge this gap, that would be very appreciated.
     
  9. Les Jones

    Les Jones Well-Known Member

    Joined:
    May 15, 2015
    Messages:
    1,446
    Likes:
    187
    Location:
    Lancashire UK
    If I was attempting to access the alarm remotely I would take the easy way and emulate the keypad on an extra remote keypad. I would probably use a 8 bit PIC or Atmel micro. (Another nice micro controller for this sort of job is the Texas MPS430 The chip itself is very nice but I find the IDE very messy to use.) I would write the code in assembler for this. I would power this from the alarm system supply to avoid galvanic isolation problems and communicate with it via a serial link using opto isolators or a Bluetooth link. You could use the Raspberry pi as a webserver and write a webpage that had a picture of the front of the keypad so that you could click on the buttons and see the state of the LEDs. It may even be possible to use one of the cheap EPS8266 wifi modules to replace the microproccesor and Raspberry Pi. I have only just started to play with one of these modules so I do not know much about them. I will have to have another attempt to learn to program in "C" as I have not seen any documentation for the instruction set on the microcontroller used on this board.

    Les.
     
    Last edited: Mar 12, 2016
  10. backporch

    backporch New Member

    Joined:
    Mar 11, 2016
    Messages:
    11
    Likes:
    0
    Location:
    NJ USA
    I did a little reading about the EPS8266. Not sure either if one device can handle the communication and be a web server, but it seems like these devices can do either.

    I was also wondering whether the raspberry pi would be able to do both. I think I need to use the I2C capabilities of the RPI. I2C is still new to me, but in my situation it looks like I need to setup a scenario with multiple masters since the panel, keypad and RPI will all initiate communication. If this is possible, I still have the problem with the data signals across the wires being somewhere between 0-12 V. If I attempt communication using optocouplers, this is complicated because it requires two way communication on each wire, so two optocouplers and diodes? for each wire? (is a component for this available?) I also don't understand the drawback of using the house wiring to power both the alarm panel and the RPI. What negative effects might I see because they share a common ground?
     
  11. Les Jones

    Les Jones Well-Known Member

    Joined:
    May 15, 2015
    Messages:
    1,446
    Likes:
    187
    Location:
    Lancashire UK
    The bi directional level conversion is simple. This is the standard circuit to convert between 3.3v and 5V logic it is bi directional and works just as well with 12 volt logic on the high side as it does with 5 volts on the high side. I think your interface eith the alarm just needs to emulate an additional keypad. As you have now mentioned I2C protocol have you now established that is used for communication between the main alarm and the keypads ?



    Les. mosfet_level_converter.jpg
     
    Last edited: Mar 15, 2016
    • Like Like x 2
  12. backporch

    backporch New Member

    Joined:
    Mar 11, 2016
    Messages:
    11
    Likes:
    0
    Location:
    NJ USA
    I don't know that I2C is used between the keypad and panel, but I did see posts online referring to the 4 wires in the bus containing a clock running at 1kHz at 50% duty cycle and the other wire being for data. I kind of jumped to conclusions. Probably need to get my hands on a scope. Thanks for the schematic. I have some 2N7000 transistors on order.
     
  13. ChrisP58

    ChrisP58 Well-Known Member

    Joined:
    Apr 27, 2012
    Messages:
    1,081
    Likes:
    131
    Location:
    Provo, Utah, USA
    I2C or IIC for Inter Integrated Circuit is a communications system developed by NXP for use primarily between chips on the same PCB, and doesn't work well over distance of more than a couple of feet, so it's unlikely that your alarm system uses I2C. This is due to the distributed capacitance that long wires present which cause the rise times to be too slow to keep up with the data rate.

    So yes, getting a scope will be your first step towards understanding what is used. But not just any scope, you want to make sure that it is a Digital Storage Oscilloscope. An analog scope will display repetitive waveforms, but the data packets that you'll be looking at will be short, one time bursts. You'll need to build a table of what data packet goes with each keypress and display change.
     
  14. backporch

    backporch New Member

    Joined:
    Mar 11, 2016
    Messages:
    11
    Likes:
    0
    Location:
    NJ USA
    Makes perfect sense. Thanks. I will work on trying to get my hands on the oscilloscope. Does the bi directional level conversion only work in the case of I2C or does it apply to more general signal transfer?
     
  15. Les Jones

    Les Jones Well-Known Member

    Joined:
    May 15, 2015
    Messages:
    1,446
    Likes:
    187
    Location:
    Lancashire UK
    I agree with Chris that the protocol is very unlikely to be I2C for the reasons he mentioned. I have only ever used I2C protocol to communicate between a microcontroller and an EEPROM a few inches away on the same circuit board. Don't underestimate the difficulty you may have working out the protocol. For example on digital calipers and digital linear scales there are at least 5 different protocols. As far as I know one of these (igaging absolute has not yet been cracked.) This is why I said that if I was doing this I would emulate the keypad on an extra remote keypad unit.

    Les.
     
  16. backporch

    backporch New Member

    Joined:
    Mar 11, 2016
    Messages:
    11
    Likes:
    0
    Location:
    NJ USA
    When you say emulate a remote keypad, are you saying that I should take a keypad, disconnected from the alarm and provide power and connect the oscilloscope to the two wires that are providing data and or the clock signal. Record the data returned based on key presses on the keypad?
     
  17. Les Jones

    Les Jones Well-Known Member

    Joined:
    May 15, 2015
    Messages:
    1,446
    Likes:
    187
    Location:
    Lancashire UK
    You would use a standard remote keypad for your alarm and interface with the keyboard and LEDs. The keypad will almost certainly be scanned as a matrix. for example if there are 16 buttons on the keypad it will probably be treated as a 4 x 4 matrix. This will only use 8 I/O pins on the microcontroller rather than the 16 it would use if each button was connected to am I/O pin. This is how it works on one axis (Say the X axis) the four columns will receive pulses in sequence. The four outputs of the Y axis go to four inputs on the microcontroller. so if the button at X1, Y1 is pressed when column 1 is pulsed the input on the Y axis at Y1 will see that pulse. The micro knows it is at that instant in time sending a pulse to column X1 and it sees a pulse on row Y1 so it knows which button was pressed. Something similar may be done to drive the LED displays. This will depend on the number of individual LEDs or segments of a 7 segment display. You would interface with the keypad signals and LED drive signals.
    The level converter will work for any protocol. I forgot to answer that question in my last post.
    Les.
     
    Last edited: Mar 17, 2016
  18. KeepItSimpleStupid

    KeepItSimpleStupid Well-Known Member Most Helpful Member

    Joined:
    Oct 30, 2010
    Messages:
    9,916
    Likes:
    1,097
    It has EOL resistors, which means it's LIKELY some variant of RS485. 4 connections make it likely RS485 also.

    See: https://en.wikipedia.org/wiki/RS-485

    I just picked one: http://www.bb-elec.com/Products/Ser...Serial-Converters-and-Repeaters.aspx#485OI9TB

    Generally, there will be power, ground, A and B. Power can even be AC as suggested for some of the keypads.

    There are terminator resistors at the ends of the bus.

    Look for IC's that connect to the keypad connector.

    Then the hard part, deceifer the protocol.

    I would recommend the isolated version.

    I'm only guessing RS485. RS485 is tough to get working. Been there. Done that.
     
  19. backporch

    backporch New Member

    Joined:
    Mar 11, 2016
    Messages:
    11
    Likes:
    0
    Location:
    NJ USA
    Thanks. I will check out the rs485

    I did get a chance to look at the signal with an oscilloscope. I saw that there appears to be one line with a 1kHz clock signal that pulses 56 times and then stays low for 25ms and repeats

    The data line will be pulled low by the keypad while the clock pulses high and pulled low by the panel when the clock is low between pulses. The switch on the data line happens on the clock rise and fall.

    I first took the panel out of the loop and watched the data line with only the keypad. With nothing going on the data line was pulled low at clock pulse 2 and 10. I went through all the buttons on the keypad and recorded where else the line was pulled low in addition to 2 and 10. It also appears that the sequence repeats three times and then goes back to just 2 and 10 being low.

    Then I added the panel and recorded where the data signal was pulled low by the panel. It was after pulse 49 that the data line went low until rising again with pulse 50. Since the keypad was still connected the line was also low at pulse 2 and 10. I recorded the signal for each zone but didn't get any further to watching an armed or alarm signal.
     
  20. spec

    spec Well-Known Member Most Helpful Member

    Joined:
    Oct 27, 2015
    Messages:
    5,828
    Likes:
    709
    Location:
    Somerset UK GMT
    Hi back,
    Is this any help:
     

    Attached Files:

  21. backporch

    backporch New Member

    Joined:
    Mar 11, 2016
    Messages:
    11
    Likes:
    0
    Location:
    NJ USA
    Thanks Spec. I have some of those documents and would not be able to setup the alarm system without them. Several I have not seen and are a good reference. I will make sure I keep an electronic copy of all of them. Unfortunately none of them talk about how the panel and keypads talk to each other and I understand why they might keep that information to themselves. Most people shouldn't need to mess with what they have and it is probably more sensible to upgrade to a newer panel to get wifi or mobile support.

    I gave back the oscilloscope, but was lucky enough to find something when I posed a question about controlling these signals in a raspberry pi forum. Piscope. Looks I can use a raspberry pi with software created by someone smart to create a oscilloscope capable enough to do what I need to do. There are also libraries there I can use to manipulate that data signal.

    My next steps are to get the pigpio libraries and piscope software on my raspberry pi, build the simple level converter and see if I can duplicate what I saw on the scope. From there I can use the libraries and capture what the panel is saying and eventually talk back by modifying the data signal. More shortly. Thanks!
     

Share This Page