Hi.
I promised to post some results ones in awhile.. So here goes..
---
Idea has evolved to a full alarm system with camera surveillance (non video, only stills).. With still also working as a doorbell camera, sensors also send other data as well, plans are that "normal" sensor module would be based on maple mini that has 1-3 PIRs, 1 serial jpeg camera, LDR, MQ2, SHT11 or SHT22 (depending is device outside or inside) 1 rgb led, 1 buzzer.
I decided that system needs an automatic reset on failure + I wanted to make it fully modular (while respecting rs485 max. 32 nodes..).. And this system no longer works with just maple and raspberry Pi, I also plan to have atleast: 1 arduino Due and 1 Arduino Mega.
Arduino Due becomes the keyboard and status monitor of this system: it has a touch screen on it and with initial tests it also works. I also posted some libraries on Arduino forums as I added initial picojpeg support to display library. This could propably had been done with Maple too, but I decided to go with Arduino Due, as Arduino(not due) had some libraries premade-- porting them to Due was some work, porting them to Maple - would had been even more..
Okay, what for Arduino mega then? Arduino Mega was chosen since it is a 5v device, I add a mp3 shield for it which is then connected to amp and speakers, there's also 1 button (doorbell) and possibly a rgbled (doorbell device light). Oh, the most important thing - this ships also with a 5x74hc595 chips that are control 4*8x5V relays which power up all the sensors and RasPi + 1*8x12V relays. Relays all are opto-isolated. 12V relays are the to power up, for example, siren.
This mega device also has internal wdt enabled for booting the system if problems are encountered. There should be some ports left, so this could also be monitoring voltage of backup battery..?
---
Ok, how am I planning to make this work?
When system gets powered; Only Arduino Mega controlling relays will start, I earlier told you about my rs-485 initial test. Devices have phone numbers.. Check that.. Arduino Mega is now on called relayBoard. 2 devices on the system get fixed phone numbers:
RelayBoard and RasPi. Although, RasPi is the one calling, so it wouldn't need a number - but it's for future purposes. When other devices start, they have initially phone number 99 or something.. Now one would think that how can this work, all the devices have same phone number, so rs485 line is full of garbage pretty soon since everyone is answering..
On a boot up, relayBoard powers up RasPi and waits for it to end it's booting process (let's say, 2 minutes to be sure..)--
RasPi then asks relayBoard to power up relay1. When device powered up by relay1 is ready it answers to phone number 99 and raspi asks it to take phone number 1 for itself and maps devices capabilities. And this is done for every device connected to system. If a new device is added - and system is rebooted, it gets automaticly included in the system; therefore: modular.
Well, almost. New device still has to be configured in raspi ( is it supposed to start alarm if state is armed, or is it a doorbell like device, for e.g.).. But adding devices should be pretty hassle-free this way..
RasPi also calls these devices one by one and if one isn't answering on.. let's say 3rd time in a row when called.. RasPi decides that device has been lost and asks relayBoard to cycle power on that device. After device reboot, RasPi gives back the phonenumber and what ever raspi had set on the device earlier.
What about raspi then? what if it get's hanged. Well, I could activate raspi's wdt.. But nope. RelayBoard listens for rs485 communications. If there is no data going on the rs485 - it decides that raspi/system has hanged, kills power on all relays and reboots itself by stopping renewing it's wdt timer. When system has restarted - raspi logs that system has started on date+time.. If system is programmed to restart automaticly, let's say.. 1 in a day for some reason.. Before raspi commands halt for itself (rs485 stops and in 2 minutes relayboard resets all) it logs that it's restarting the way it was programmed, so it's easy to find from log if restart was due to failure in the system or.. Requested for reason..
Yes.. Here's some theory, and it's far far far away from any progress-- building relayboard currently and waiting for miscalleneous parts to arrive from the world..