'Smart' Front Door
This project started out as a simple 'networked door bell', so we could know if someone had called whilst we were out. This got us thinking as to what else we want our 'front door' to be able to sense and also what useful actions could it take in response. It's an experiment to see what works and what doesn't. We have now had our new front door fitted, so we are in position to do the final wiring and installation. We have now proved that the Raspberry Pi is a perfect way to implement this and will minimise the amount of wiring required to the front door. This project is now progressing quickly :-) We also have some other related pages on the Raspberry Pi:
This is what our 'smart front door' project is going to deliver:
- Know whether it is dark outside or not. This could driven by our twilight sensor sensor but, we are also planning to add an I2C analogue board and light sensor locally. This will then be used to:
- Restrict when convenience lighting is active (manual over-ride aside).
- Restrict when IR lighting is activated, to support the security camera.
- Safety lighting - low level lighting over the door at night time (very low current LED). This will now most likely end up being just a power feed down to the front door only.
- Courtesy lighting - PIR driven lights that light up to welcome anyone at night time. The time delay is controlled by software running on the Raspberry Pi.
- Capture door bell presses and capture image or video when pressed.
- Detect if something has been put through the letter box and also capture image or video. If something is left wedged in the letter box, we will get an SMS message alert after a defined time delay. This is an integral feature of our Home Control System (HCS) controller.
- Capture front door open and close events using a door contact sensor and report them back to our Home Control System (HCS).
- Audio announcements and notifications on opening front door, e.g number of new phone messages. This will be done using a Java Text-To-Speech engine and pre-recorded messages. We are also now playing a door bell sound when the door bell is pushed.
- Capture a series of still images of people coming to the front door (using a PIR sensor) and make them available whilst at home or away from home via cloud storage and associated mobile apps.
- Capture video on movement detection and other events.
- Capture excessive door vibrations. Basically if someone is banging really hard on the front door.
- Support a panic alarm button just inside the front door.
Some secondary features that we are also looking at, though these may also become separate projects:
- Enable local and remote locking using both keys and access codes entered on a keypad, with logging.
- Interrogation of door lock status. Support personal keys and personal access codes.
- Speech recognition.
And these are now definitely separate projects:
Instead of having loads of wiring from the front door to the Home Control System (HCS), we plan to use input capability and local processing capability next to the front door, in the form of a Raspberry Pi. We ill use the Ethernet network to get I/O updates back to the Home Control System (HCS). This will simplify the wiring a lot.
Our current design is looking something like this:
Local Inputs, Outputs & Feeds
The current design assumes the following local input and outputs. The number is important as it affects the implementation options, e.g. does a Raspberry Pi have enough I/O capability to implement this? Our view now is that it does.
Note: The numbering used here is for the initial Revision 1 board. We currently plan the following digital inputs in total:
- PIR Sensor (GPIO15, Pin 10)
- Door contact sensor (GPIO17, Pin 11)
- Door bell (GPIO18, Pin 12)
- Door lock (GPIO21, Pin 13)
- Vibration sensor (GPIO22, Pin 15)
- Panic button (GPIO23, Pin 16)
- The twilight sensor status from Home Control System (HCS) (GPIO24, Pin 18) - used to limit when the courtesy and IR lights come on.
- The Alarm status from Home Control System (HCS) (GPIO25, Pin 22) - not sure how this will be used yet but since there was a spare input.
Door locked sensor may be covered in our front door lock project. Other inputs (not digital) identified include the video camera and microphone.
The inputs are 12V signals and buffered into the GPIO pins using opto-isolators (ILQ74). We are updating our optical-isolated input board design to work with the Raspberry Pi. The electronics are covered in more detail in our digital input & output feature.
We currently plan 2 digital outputs in total but we have developed an optically-isolated output board that supports four. Each output uses a power transistor that can supply 12V dc at 2 amps.
- Convenience lighting - the GPIO pin controls the LED courtesy lighting using a power transistor.
- IR lighting - the GPIO pin controls the LED infr-red lighting using a power transistor.
- 12V dc power
- Alarm status - i.e. on or off
- Internal alarm
- External alarm
- Alarm strobe
- Safety lighting
- Emergency lighting
- The twilight sensor status
Our initial thoughts were that the convenience lighting and the IR camera lighting would both operate at the same time, when the PIR detects movement and it is dark outside. Having given it further thought this is no longer the case. We only turn on the IR lights when about to take an still image or video (and it is dark outside). The courtesy light will have a much longer delay as it is designed for people to use. The courtesy light is also on when we capture images and video though.
We are currently construction a stylish front porch light which contains 40 warm-white LEDs for the convenience lighting and 28 IR LEDs for the IR camera lighting. These will sit behind a white Perspex, curved panel and the PIR sensor will also be out of sight behind this. Both lights are designed for 12V power but, a local mains transformer could be used to power them from mains power supply.
This was a previous project and as part of it, the 12V safety lighting power feed is routed to the front door. This adds some low level ambient lighting over the front door at night time. The plan is to use a single warm white LED, as we have done in other parts of our house. It's hard to describe just how useful this is.
Convenience lighting is lighting that is activated by people approaching the door or opening the door (at night time only). It is activated by the PIR sensor and the door contact sensor. The processor uses the PIR and door contact sensors as inputs into a retriggerable delay timer. We are also considering using the door bell and the letter box sensor to trigger this.
The processor outputs a control signal to the convenience lighting and this is routed via a 3-way light switch (auto, off and on), to provide an overlay layer of manual control. This isn't strictly necessary but, is our preferred way of doing home automation.
Because all the signaling is 12V dc, this control signal could be used to drive low-voltage convenience lighting via a relay or mains lighting via a solid-state relay (SSR).
We also plan to have some IR lighting in place to improve the quality of the images captured by camera. This would only be activated at night time and ideally only activated when the camera is capturing images or video (to save power). We would like this to be very subtle but, there are two types of IR LEDs:
- We have used LEDs that output at a 850 nm wavelength and these are visible and have a dim red glow to the human eye. These are much better for illumination when used with digital cameras.
- There are also invisible IR LEDs and these are best used in IR remotes and similar devices. They output light with a 950 nm wavelength and are not as good for illumination with digital cameras.
We picked up 100 LEDs on eBay for less than £5 delivered. These IR LEDs are rated at 1.5-1.6 V forward, 60mA continuous, 120mA peak.
It is very difficult to actually photograph an IR LED because most digital cameras are responsive to IR light and don't see what the human eye sees. This photo gives you an idea of what an IR LED looks like when lit up though. It has a faint red glow, which is dimmer than this photo implies.
Note: This IR lighting is not designed to light up large areas and long distances. It is purely for the IP camera over our front door and we have a separate camera and lighting system to cover our front drive area.
We already have an internal alarm sounder next to the front door. This is used to remind us that the alarm has been armed or triggered before the external sounder goes off. This could also be done as a voice announcement though.
This is replicated by the front door to give a clear visual indication that the alarm has previously been triggered. The external sounder is switched off after a set time delay but the strobe remains on until the alarm is reset.
The PIR sensor needs to be external type with short range and wide beam. Most internal ones used for alarm systems are 12V dc but, external variants tend to be mains powered and used to control external lighting. They also often include a light level sensor. This makes it harder to find an external 12V dc PIR sensor at a reasonable price.
We require 12V operation and don't require a light level sensor so have decided to take a standard PIR sensor and modify it for external use. Protecting it from the elements is less of an issue in our case, as it is located under a porch and is not subject to direct sunlight and rainfall. We have used a standard internal PIR sensor and clear silicon sealant to ensure the case is sealed from dust and water. We will see how well it survives over the coming months.
Our current door bell is a stainless-steel, waterproof (sealed to IP66 BS5490 1977), vandal proof switch mounted in a bespoke housing. We used this switch because it looks good, is very high quality and very reliable. This is from Maplin (part no. MG75S).
With our new front door fitted, this is what it looks like from the outside. This is the vandal-proof, stainless-steel switch recessed into the door frame, so that it sits flush. The surround is a large washer that we have spray painted gloss black. The wires come out of the frame at the back and are hidden inside, running up to the top right corner of the door frame and into an enclosure. The enclosure is hidden behind a curtain.
IP Network Camera
Our Raspberry Pi IP camera project using a USB webcam covers this part in more detail.
It would be a lot easier to implement in a house where the letter box is to the side of the front door and not mounted in it. This would make it easier to route wires and to hide wiring. It might then even be possible to have a collection cage for the mail that could weigh its contents. Having it not mounted to the side of the front door would also make it less susceptible to vibrations from the door opening and closing.
We initially looked at using a tilt switch mounted to the external letter box flap but, this was at 90º to the way the tilt switch operates.
A more reliable solution is a tiny reed switch mounted on the inside of the letter box and a small magnet stuck to the letter box flap. We use these things on every door in our house.
After much deliberation, we decided it was not possible to hide the wires completely, so we have adopted the wireless approach used on our networked door project and embedded a Z-Wave contact sensor inside the door. We can do this because the composite door has a high-density foam inner element.
One added piece of functionality is that we can now see if the letter box has been wedged open by someone leaving post in the letter box. This is annoying as it lets drafts through. Using in-built functionality written into our controller class, we get an SMS message if the letter box has been stuck open for more than 60 seconds.
The letter box is made of two parts, which slide together, through a slot cut in the composite door. We are mounting the sensor on the inside part.
There are brushes to prevent drafts.
This is the view of the door with the letter box removed. It has a dense foam inner which is easily cut. This is us starting to cut a slot for the Z-Wave sensor.
This shows the magnet and reed switch glued in place.
This looks like a lot of work but it was quite easy to do and was the only way to ensure there are no elements of the letter box automation visible. We do have the pain of replacing batteries in the Z-Wave contact sensor every year or two but, we remotely monitor battery status and our Home Control System (HCS) sends us an SMS message when they need replacing.
Door Contact Sensor
This is a reed switch as shown above with a magnet hidden in the door and the frame, to signal when the door is open or closed. We have managed to hide the wires inside the door frame too, so there are none visible when the door is shut or open.
Door Vibration Sensor
This is probably over-kill but, for the sake of a vibration sensor and a pair of wires, we are interested in understanding if this is a useful thing to do. The purpose of this sensor is to see if anyone is knocking or banging on the door (or trying to break it open!). The vibration switch works at any orientation and contains some mercury. Any vibration causes the contacts to close very briefly. A fast response input is required to work reliably and fortunately our testing shows the Raspberry Pi works plenty quick enough, especially when using interrupts.
Internal Alarm Panel
As part of this project, we are updating the alarm control panel or keypad next to the front door.
This is now a separate lock project.
Audio Announcements & Notifications
Our house currently makes voice announcements using Java TTS (text to speech) library and some pre-recorded announcements (better quality). These are for very important events only, so as not to become annoying. An example of this is announcing mains power failure and restoration.
With a speaker above the front door, it would be quite easy to add audio notifications when the front door is opened. A useful one we can think of is to announce when there are answer machine messages for the PSTN and VOIP phone lines (another project under way).
As part of our home security system, we also have a panic button by the front door. This activates the alarm system and sounders, as well as sending out SMS and other messages.
We can track members of the household coming and going by using a Bluetooth dongle to detect proximity of mobile phones. This is now separate project.
We have ordered an A4 sheet of 2mm thick acrylic plastic on which to mount the LEDs and PIR sensor. Our layout results in the use of 40 warm white LEDs, each driven in groups of 4 in series with a current limiting resistor.
We initially designed a template for the LEDs, using Microsoft Powerpoint.
We cut and drilled the acrylic as shown here.
We have used 28 IR LEDs, also in groups of 4 in series with a current limiting resistor. Initial test show these LEDs to be quite directional, so we have angled them within the light unit. These LED are rated at 60mA continuous but put out a decent amount of light from 25mA up. Because you can't actually see the light IR light output, these are tested with an IP netcam.
The main software is written in Python. It mainly uses GPIO pin edge detection to turn things on and off but there is also a main program loop checking whether the door is open, closed, locked, or unlocked. This is done this way as we want to maintain and report all state changes back to the Home Control System (HCS). The software also sets timers for the courtesy and infra-red lighting and checks to see if the lights should be on or off.
Note: The software will be published here very soon.
In addition to the Smart Front Door software described here, we also use this machine to run our network security monitor project.
Both process generate local logs, which we are using for debugging and analysis.
We downloaded the latest version of the Raspberry Pi operating system from the official download site. For this project we are using the (latest) New Out of Box Software (NOOBS) version 1.3.2, released 2013-11-02.
We are using the standard pi user account but have changed the password.
We are using an I2C analogue input board and to monitor:
- Supply voltage using a potential divider to assess the voltage drop from our +12V dc power supply.
- Outside temperature.
- Outside humidity.
We are also adding air quality functionality like this air quality monitoring project and will be documenting this here in more detail soon.
Our current Home Control System (HCS) is a single logical entity with all the intelligence and decision making done in one central event handler. This project was our first implementation of a slave HCS processor as part of our distributed Home Control System (HCS) architecture. It represents our first attempt at physically distributing the HCS, whilst maintaining a single logical entity. In this respect it has been a great test case of what and what not to do with our smart home automation. So far things are working very well.
We have written all of the code for this project twice. Once in Python and once in Java, so see how the two languages compare in terms of ease of programming and performance.
We have the Raspberry Pi working as a security camera and have also got it capturing high resolution (1920 × 1080 pixel) still images using the Logitech USB camera. This camera is preferrable to the RPi camera module because it has a wider field of view and a much longer lead. Our one worry is the time taken to capture and image though. We will do some more testing to see if this is an issue.
Physically running all the cables down to our front door has proved challenging.
The key to making this a succesful project has been in ensuring the majority of the components used are invisible and hidden. The elements exposed are incredible subtle and can only really be spotted if you are looking for them.
Distributed Home Control system
We are currently undertaking a second project to do something very similar in our conservatory, again using a Raspberry Pi as the processor.