Home Sensors and alarm.

Hi all,

I always wanted to build my own version of a Home alarm system for my house.

First things first, let me just say that the house was pre-wired for an alarm system during it was built.
So other than the doors/Windows traps ( N.O. reed switches) there is a 4-wire shielded cable going to each room for the PIR traps.
There are also the same type of cables for the keyboard and the external siren.

Now to the point. While a conventional type of alarm would still be complicated but within my design capabilities (I'm being overconfident here), I would like to take advantage of the existing cabling infrastructure to gather also Temperature/Humidity data. The reasoning behind this is that in the future I might also want to control the air-conditioning in each room, either based on those data, or remotely via WEB or SMS (but thats way ahead in the future).

As the whole construction needs to have the highest WAF** possible, I need to be using as less additional to the alarm components as possible, meaning that it would be ideal if the additional components fit inside the plastic cover of the PIR sensor it self, or they fit in a small plastic box that the PIR will be mounted on (like a plastic wall mount for the PIR).

**WAF: Wife Acceptance Factor

I came up with the bellow block diagram (seems like Arduino forum automatically resize the image):

On the far right you see the PIR and the Humidity/Temperature sensor. The sensor is a HUT21D sensor using I2C for communication. It is far more reliable and accurate than the cheep DHT's are. The way I'm planning it is that a small uC like ATTiny85 sits in a small box, or even inside the PRI plastic cover and handles communication with the HUT21D and at the same time senses the NO switch of the PIR sensor.

The ATTiny on the Room Unit, communicates via Serial to another ATtiny (or similar) to the main Unit. This is done, as there will be 4 such sensors and concurrent serial communication can be troublesome if the main uC is not equipted with 4 UARTS (plus at least one more needed for keyboard).

The ATTiny's of the main unit will act as slaves on a I2C bus, where the main uC ATMega328 will read their data and at the same time sense the other Window/Door traps and the keyboard and act as the heart of the alarm.

Now, what I want is for the temperature/Humidity data to end up on the Raspberry Pi. The Pi is already connected through the SPI with an nRF24L01 module and communicates with a ATTiny which in turns controls the communication with a HUT21D outside the house. There is also Network connectivity there (not shown) so the Pi will host a small internal web server to display statistics.

So that is what I have till now. I would like your thoughts/experiences on what I plan so far and more:

  • Is what I plan so far feasible? Can the ATTiny work with I2C and SerialSoftware concurently?
  • Will internal clock on the ATTiny be sufficient, or is it better to have an external clock? will that leave pins available? (MainUnit -> RoomUnit might be the future I was telling you about)...
  • Anyone having any experience with Alarm keyboards? As WAF is a major pain here, I'm thinking of going with a commercial keyboard/LCD and either hack it, or try to understand its protocol...
  • Any suggestions on how to connect to the Raspberry? Serial? I2C slave, SPI?
  • Any suggestions on how to connect the siren?

Thank you all for even spending the time to read this!

First impression, a damn lot of uC's... Especially in the Main Unit (MU?). It's really not that hard to connect more then one node (Room Unit/RU) to another uC.

Also, just plain serial isn't a good choice for long cables in a house. I would go for something like RS485. Uses a pair (is the cable twisted?) to transmit (and receive) data so you can use the fourth wire in the cable. Only "problem", RS485 isn't designed for a star network (cables from one main unit to each individual node) but for a chained network (one cable out, go to first node, then second etc). Is the cabling really an star network? If you want to use RS485 you can just parallel multiple RS485 IC's.

Another option would be to use something like current communication instead of voltage. Instead of 0V and 5V you send for example 0mA and 10mA. This way you can have a lower input impedance.

Also, the power on the 4-wire cable. I wouldn't use 5V for that but 12V. You can have voltages drops and noise because of the cables. With 12V you can fix this by regulating the voltage in the node.

Now the rest of the questions:

nikosk:
Is what I plan so far feasible?

It is feasible. I'm not that great with the RaspberryPi (Orange Pi?) part but it's possible.

nikosk:
Can the ATTiny work with I2C and SerialSoftware concurently?

I'm not a ATtiny expert but from what I know there is no hardware serial nor hardware I2C. Only 1 USI you can use for both. But that means, not at the same time... It doesn't need to be a problem. You only have one (not very critical) sensor connected so you can bitbang the I2C.

Another option would be to use Arduino Pro Mini's. They are sooooooo cheap and use the "normal" ATmega328.

nikosk:
[Will internal clock on the ATTiny be sufficient, or is it better to have an external clock? will that leave pins available?

Have a look at the datasheet. In there you can find info about internal clocks, clock errors and most of the time things about bad baud rates with certain clocks. And an external crystal oscillator takes 2 pins so do the math :wink:

nikosk:
[lAnyone having any experience with Alarm keyboards? As WAF is a major pain here, I'm thinking of going with a commercial keyboard/LCD and either hack it, or try to understand its protocol...

I have no experience, I don't even know what's on the market... Are there pretty ones? But I think you are better of designing your own. I think it can be a hassle to reverse engineer a existing unit or to hack it. With 3D printing and laser cutting you can make very good looking units. For example a nice laser cut acrylic front panel, place a good printed layout behind it and touche electronics behind that and it already looks good :smiley: I think that has a hight WAF then a basic Alarm keyboard.

nikosk:
Any suggestions on how to connect to the Raspberry? Serial? I2C slave, SPI?

I think serial would be a easy choice. It's like the default computer interface for DIY...

nikosk:
Any suggestions on how to connect the siren?

Uhm, with a wire :wink: Just let the Arduino drive a MOSFET and connect it :slight_smile:

Good luck!

septillion:
First impression, a damn lot of uC's... Especially in the Main Unit (MU?). It's really not that hard to connect more then one node (Room Unit/RU) to another uC.

Indeed. This is surely overengineered. I was wondering if I could make the the RoomUnit(RU) communicate with the Main Unit any other way... Any ideas? Perhaps sending a modulated tone or something like that...
Any sugestions are welcome. The only issue is that it might be dificult working with SMD components, at least smaller than 2520 size (that imperial 1008).

septillion:
Also, just plain serial isn't a good choice for long cables in a house. I would go for something like RS485. Uses a pair (is the cable twisted?) to transmit (and receive) data so you can use the fourth wire in the cable. Only "problem", RS485 isn't designed for a star network (cables from one main unit to each individual node) but for a chained network (one cable out, go to first node, then second etc). Is the cabling really an star network? If you want to use RS485 you can just parallel multiple RS485 IC's.

Well, longest run would be 5 meters, not that far, but RS485 might be an option. No, the cabling is as described, after all it was supposed to serve a legacy alarm system consisting only of the +12V and a Normal Open switch which gets closed when a movement is detected.

septillion:
Another option would be to use something like current communication instead of voltage. Instead of 0V and 5V you send for example 0mA and 10mA. This way you can have a lower input impedance.

Any links how this is made?

septillion:
I'm not a ATtiny expert but from what I know there is no hardware serial nor hardware I2C. Only 1 USI you can use for both. But that means, not at the same time... It doesn't need to be a problem. You only have one (not very critical) sensor connected so you can bitbang the I2C.

bitbang? that sound cruel!!!! Need to google that....

septillion:
I have no experience, I don't even know what's on the market... Are there pretty ones?

Indeed they are. Siemens has some beautiful units out ther....

septillion:
Good luck!

Thank you Septillion

I had in mind the following factors when chosing the way things will communicate.

The Room Unit IC will transmit its status constantly with a specific rate lets say every 1 second. I could have one ATmega328 (instead of 4xtiny) listening to those transmissions but I do not think it can handle that nor the softserial library can listen to more that one port at the same time...

Any suggestions are more that welcome!!!!

Thanks

Okay, a lot of questions again :stuck_out_tongue:

nikosk:
I was wondering if I could make the the RoomUnit(RU) communicate with the Main Unit any other way... Any ideas?

Serial is not a bad idea. But you need just 1 serial... Only, let the RU idle the TX pin when not sending (clearing bit TXENn in UCSRnB) (but that's not nomarlly supperted with the Serial library...) Or, connect every RU's TX via a diode to the MU's RX (cathode to RU, anode to MU) and give the MU's RX a pullup. Image here. Or, if you use multiple MAX485 you can just enable them one by one.

But you need to be sure only one is sending. You can do this by letting the MU pull all the RU's one by one. Like, MU asks RU1 for status, RU1 replies, MU asks RU2 for status, RU2 relplies etc

nikosk:
Well, longest run would be 5 meters, not that far, but RS485 might be an option. No, the cabling is as described, after all it was supposed to serve a legacy alarm system consisting only of the +12V and a Normal Open switch which gets closed when a movement is detected.

5m is doable over shielded cable I guess. Don't make the baud rate to high and I would use some kind of check sum to be sure.

I don't know what kind of cabling they normally use so I thought, maybe it's already twisted :smiley:

nikosk:
Any links how this is made?

Uhm, not a direct one. You can use something like the middle one here to create a simple switchable constant current driver. If you use a R of 68ohm you have a drain of 10mA when enabled and 0mA when disabled. Instead of the LED's you connect the wire back to the MU. There you connect it via a resistor (lets say 400ohm) to the 5V. Image here.

This way input impedance is +-400ohm. Only the signal is inverted but hey :stuck_out_tongue:

nikosk:
bitbang? that sound cruel!!!! Need to google that....

Just a term for a software solution. :smiley:

nikosk:
Indeed they are. Siemens has some beautiful units out ther....

Good to know. Easy to interface?

Good Luck!

Hi again,

still here! Trying to comprehend all this information.

I will try the trick with just one serial, just for clarifying this, the Tx of the main unit, I suppose goes to all the Rx'es of the Room Units, right? Then I will need some code to identify if the message was addresses to one self so it can reply, right?
Can I do some other kind of "muting" ? ie an number of AND gates, where one input of the AND gate will be the a sort-of Chip select and the other the actual TTL-level serial? or something like thatm instead of the Diodes?

Another question, as I can find no info on the net.... You mentioned something but I did not quite get it... Can a ATTiny85 run Software serial and TinyWireM (master mode) at the same time?

It will take some time to test everything, as it seems ATTIny85's are not currently available in the Greek market and ebay is not an option... (Capital Control rules.....)...

septillion:
Good to know. Easy to interface?

No idea. I haven't got the slightest clue on how they communicate... I assume its serial RS232/432 or something, but the communication protocol I can find nowhere...