Previous entries in this blog series:
- Pi Alarm System - Part 1: Project and components description
- Pi Alarm System - Part 2: Wireless sensors
- Pi Alarm System - Part 3: Control unit
- Pi Alarm System - Part 4: Almost there
The dimensions of the enclosure were based on some rough estimations, now I had to make everything fit inside.
I puzzled a bit, figuring out how I would expose the controls, camera and LCD.
The solution I came up with can be seen in the pictures below. It's a bit big, but fully functional.
I even printed some buttons, as the keypad pushbuttons were no longer accessible because of the enclosure.
RF433 I2C Board
As mentioned in previous blog post, I made a prototype of an I2C RF433 transmitter using an ATtiny85.
With the prototype working, I designed a small PCB using Fritzing and had it made.
The result (prototype left, custom PCB right)
A short video of the board being controlled by the Pi via I2C to turn a light on and off:
Power and other pins
I wanted to power every component involved in the most simple way possible, using a single power supply.
For that purpose I made use of the power provided to the Pi Rack and distributed it to the different components by means of jumper wires in case they weren't directly connected to the Pi Rack.
The Pi is also powered by the Pi Rack by providing the power via the GPIO pins. Not ideal, but it works and was simple to achieve: on one of the jumper selections for power, I shorted all three pins in order to have the external power supply reach the Pi 5V GPIO pin and have the module attached still powered also.
Because the Arduino and the Adafruit LCD/Keypad cannot be connected directly to the Pi Rack, I used jumper wires to connect the necessary pins:
- Adafruit LCD/Keypad: Power and Ground + I2C pins
- Arduino with GSM Shield: Power and Ground + Serial pins
I'll have to find a better way to fasten the jumper wires though, as they tended to come loose easily.
With all components enclosed, some tests were required to verify all connections were still functioning properly.
Using the "sudo i2cdetect -y 1" command, I verified both I2C modules (Adafruit LCD/Keypad and custom pcb) were detected properly.
The camera was tested using the "raspistill -o test.jpg" command. The picture and its orientation were correct.
Motion also provides a live stream of the camera feed, which worked properly.
A quick test of the LCD/Keypad:
With the enclosure done and the components working, it was time for a "field" test ...
Because the wireless sensors could detect our little burglar even before she reached the living room (and because there was not much for you to see), we allowed her to start from within the living room.
The system would still detect her, but at least we'd have her reaction on film
Thanks to the pictures and videos, the burglar was identified and apprehended
There are still quite some improvements to be done before this project becomes more than a game to play with my daughter:
- As Mark suggested in a previous post: the wireless sensors should include a mechanism to check in periodically in order to know the batteries are not dead
- The control unit with camera and controls should have some backup power: if the burglars turns off the electricity, the system should keep working for a (little) while
- The solution is very bulky, mainly because all components used were used as is. A custom PCB with the different elements required could be more compact (and cheaper).
Still, this was a great learning experience on different types of communication between the modules, and on the modules themselves.
I'll be posting the full code on GitHub and provide the link when available.
The code consists of following parts:
- Arduino sketch for RF433 sensor reception and GSM shield using UNO
- Arduino sketch for the RF433 I2C transmitter using ATtiny85
- Raspberry Pi python scripts to drive the LCD with keypad, the Piface digital, the lights and the sending of SMS