Hi... Building a home alarm system using RPi and Arduinos

Post Reply
earl
Posts: 3
Joined: Mon Nov 06, 2017 7:45 pm

Hi... Building a home alarm system using RPi and Arduinos

Post by earl » Thu Nov 09, 2017 2:41 pm

Just want to says 'Thanks' Roger and all who help out here. Lots off helpful information.

Programming on microcontrollers is a hobby for me. It is great fun to be able to control things at the hardware level. I have a blog site (https://microcontrollerelectronics.com) and post about some of the things I do.

Currently, I am trying to integrate a Rasperry Pi, several arduino unos and an STM32F103C8T6 together over I2C for an alarm system.

Image

User avatar
RogerClark
Posts: 7440
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Hello everyone!

Post by RogerClark » Thu Nov 09, 2017 9:47 pm

Hi Earl

That looks like a complex alarm system.

I wonder why you are using multiple Arduino boards? My guess is that they are the sensors?

PS. I just changed the title so its easier for people to know what you are building

zmemw16
Posts: 1484
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: Hello everyone!

Post by zmemw16 » Thu Nov 09, 2017 10:24 pm

perhaps each handles a set of sensors for each station e.g. rooms, outhouse, sheds.
srp

User avatar
mrburnette
Posts: 1877
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: Hello everyone!

Post by mrburnette » Fri Nov 10, 2017 1:05 am

RogerClark wrote:
Thu Nov 09, 2017 9:47 pm
Hi Earl

That looks like a complex alarm system.

I wonder why you are using multiple Arduino boards? My guess is that they are the sensors?

PS. I just changed the title so its easier for people to know what you are building
Generally, the RPi is not considered a real-time environment since it runs a flavor of Linux, and is in the microprocessor family. Therefore, it is prudent to have microcontrollers buffering real-time needs; generally sensors. The small added cost makes for a far simpler system to design and program... and debug. Such a design is modular and sensors can be classified by "roles" such as PIR, Temp, Norm_Open, Norm_Closed, Latched, etc. Roles can then be assigned to physical locations mapped within the RPi.


Ray

earl
Posts: 3
Joined: Mon Nov 06, 2017 7:45 pm

Re: Hi... Building a home alarm system using RPi and Arduinos

Post by earl » Fri Nov 10, 2017 2:24 pm

Hi,

The arduinos connect to various sensors. I use multiple arduinos because the number of sensors exceeds the number of pins available on one arduino. Of course I could attach one or more ICs to expand the ports but this is simpler right now. The whole idea is to have something that is reliable with easily replaceable parts.

It is all working quite well in a prototype for an office building that i set up here (although with a limited set of sensors).

It is accessed via a web browser using socket.io to talk to the node (and web) server on the Rpi.

The main page is a 3D graphic of the bldg showing the sensor locations. Each sensor is clickable to configure it (hours of operation, icon, other info, etc.) or to inquire about it. Of course this page also shows other info about the alarm system state.

A python script on the Rpi uses I2C to communicate with the Arduinos and uses MQTT to send messages back/forth to the Node server (and thus to the web page via socket.io). So it is pretty close to 'real time'.

I am still 'wrestling' with several designs because I am having problems with integrating I2C on the Rpi with the Arduinos and the STM32F103C8T6. I personally think I2C on the Rpi is broken. I2C with just Ardinos or Arduinos with the STM32F103C8T6 works fine.

I have one design with the Rpi connected as the I2C master to the Arduinos but it sometimes will 'freeze' an arduino and an Rpi I2C with an STM32F103C8T6 just does not work at all. So, in the I2C Arduino sketch sending the sensor data and the python script which collects the data, I had to put CRC checks because of these Rpi 'problems'. The arduino sketch also reboots itself if it detects that it is not being polled.

Another design is to have an I2C arduino (or STM32F103C8T6) as master to collect the data from the other arduinos and serial connect (the master) to the Rpi to eliminate the Rpi I2C problems.

Image

Yet another design is with two I2C masters (Rpi and an arduino) but I am finding that more data is lost in this scenario.

Still working on how to make this near 100% reliable as it is an 'alarm system' after all... :)

earl
Posts: 3
Joined: Mon Nov 06, 2017 7:45 pm

Re: Hi... Building a home alarm system using RPi and Arduinos

Post by earl » Fri Nov 10, 2017 3:11 pm

Here is what the main web page looks like (including a pop up of a selected sensor when in config mode)

Image

There is a graphic of the sensors and location, a legend area to the right, a 'real time' message area below and a text input area below that.
Buttons at the bottom to get into status or config mode, save/restore config info, display or not the messages, and send commands (interact) with the node server.

The message area shows a lot of error messages due to having multiple I2C masters at the time and arduino I2c address 9 having problems.

Post Reply