Doorbells are the 20th century version of today's perpetually-interrupting cell phone. There you are, cooking a delicious dinner or reading a nice book when the doorbell rudely goes off in your ear. Sure, you're glad to see whoever is at the door, but interruptions that chime can be so obnoxious. Needless to say, I do not have a doorbell.
The problem with the knocking system is that I usually can't hear when someone knocks from my lab. I depend on Penny the Dog to alert me when someone is at the door. Except Penny sleeps most of the day. And then there are the delivery people (UPS/FEDEX) who can't be bothered to knock, even if it is a next-day-early-AM shipment of parts from element14 that I am eagerly waiting for.
I decided that I'd create a project that solves all of my problems: a silent LED that flashes whenever someone approaches my door. It is based on a laser tripwire and will be able to run day or night, even in the bright Denver sun. And if the blinking LED is annoying, a simple button press disables the alert and resets the trigger.
The laser tripwire is set up to be as simple as possible. A laser is reflected off of a mirror and back to a photoresistor which is one leg of a voltage divider. The complete schematic is attached below. The varying light intensity changes the output of the voltage divider, which can be read by an A/D. To make the 'target' for the laser easier to hit, a Fresnel lens is used in front of the light sensor like one would see with a PIR sensor.
With the sensor defined, the rest of the wireless link must be considered. The XBee series 1 by Digi is a great solution to this problem, and there is a wonderful starter kit to get going. It is a wireless communication system that has an integrated A/D that can transmit the detected light level digitally. It is also a commonly used device and is one of the easiest ways to create a wireless link. Unfortunately, in order to use the standard XBee interface, the digital value is only presented on the receiving end by a PWM signal. This PWM signal is filtered which produces a DC amplitude level that can be read by an Arduino's A/D. While having to do an A/D conversion at the transmitter and again at the receiver is not ideal, it was a sacrifice made to prevent a custom implementation on the XBee.
To setup the XBee radios, I used their bloated-yet-functional (113MB) XCTU XBee setup utility and the XBee USB Adapter board that was included in the starter kit. Note that you may need to install some FTDI Virtual Com Port (VCP) drivers.
I followed two of Digi's examples in order to get the settings correct:
The transmitter settings that I used were:
The receiver settings that I used were:
Shields are possibly the biggest time saver that exists in the Arduino ecosystem. The XBee board is on 2mm pitch headers, and having some extra perf board to put the low pass filter and button on is super helpful. Arduino's wireless shield worked great for both challenges.
The filtered output from the receiving XBee is fed into an Arduino Leonardo for processing. The code is attached below, but the basic pseudo-code operation is:
Save the last sensor value
Read a new sensor value
If the new sensor value is greater than the past value by at least a threshold, detect a trip
Blink the LED and wait for a timer to expire or a button press
Loop back to the start
In order to make the tripwire system work at any light level, a simple comparator action wouldn't work. The threshold at night would need to be different from a daytime threshold. It would be possible to take an ambient light reading with a separate sensor and base the threshold on that, but a more elegant solution for this application would be to pay attention to the rate of light change. If the light changes by X amount within a very short period of time, a trip is registered. However if the light changes over a few seconds or minutes, it will not register a trip. Testing has shown this to work in pitch black as well as on a sunny day (although in the shade).
With the electronics designed and code written, I had to put the transmitter in a project box to shield it from the elements. I found a simple enclosure, although I needed to remove the included metal plate. According to Digi's layout suggestions on page 9 of their manual, there are limitations on where metal can surround the area near the antenna. A hole for the lens, the laser, and the power supply were the only mechanical modifications required.
Problems that I encountered:
No project goes exactly to plan, so here are a few snags that I hope you'll be able to avoid:
- The XBee software was more obnoxious than I expected for an entry level wireless protocol setup.
- The power supply that I bought was so crappy and noisy that is was causing bad data to be sent. I had to add a 470uF electrolytic cap at the power input. A higher quality supply should be used.
- I tried a getting started guide from parallax to try and verify that the hardware at least worked, but I found that the Arduino sketch didn't compile. I could have been missing something silly, but I don't have much patience for getting started guides that require dissection. So I decided to go to the source and follow Digi's getting started guide which isn't too far from what I needed for this project anyway. That worked great.
- When uploading new firmware to the Arduino, the switch on the wireless XBee shield MUST be in 'USB' mode for it to work. Otherwise you'll get the following error: avrdude: stk500_getsync(): not in sync: resp=0x00
- The unit only works in the shade, since direct sunlight washes out whatever the laser can produce.
And that's it! I now have a silent method of knowing when someone approaches my door. The next step will be to connect it to the cloud so I can set alerts to my phone when I'm away. Stay tuned!
Documentation Attached In .Zip File:
Laser Doorbell.sch: Schematic in EAGLE format
Laser Doorbell Schematic.pdf: Schematic in .pdf
Laser Doorbell BOM.xks: Bill of Materials
DY_Doorbell_Code.ino: Source code for use with Arduino IDE