| |||||||
Going WirelessTransmitter and Receiver sketches were written that proved the mechanism worked. Now came the task of building the hardware. Wireless ReceiverThe receiver was built in another small plastic enclosure. This consisted of an Arduino Uno and HC-05 (master mode). The output of the Arduino (pin 13 in this case) was fed into the main controller box built previously, replacing the reed switch. Here is the box being constructed and a picture showing it connected to the main controller. Power is passed through the boxes using 2.5mm plugs and sockets.
Here is the simple receiver sketch: // This is the Client that receives an 'ON' command. // WHen we receive it, we want to turn the output on #include The Wireless TransmitterThe core of the transmitter was an Arduino Mini Pro and an HC-05 bluetooth device. This worked nicely with the receiver once the devices were paired. I soon found I had to consider power consumption as it was desirable to make the transmitter battery powered. Here is the transmitter sketch: // This is the transmitter used on the garage door that communicates // via buetooth. See bluetooth module for pairing setup. // Programming: Use 3v sparkfun serial board. // serial port: /dev/tty.usbserial-AK05C887 // board: Arduino Pro Mini 3.3v 8MHz W ATmega328 #include Power consumptionIdeally, the transmitter should be battery powered. I measured the current consumption of the Arduino and Bluetooth transmitter. It was in the order of 35mA. Putting the Arduino to sleep helps but unless you start knobbling the LED and voltage regulator, it will still draw a few milliamperes even in deep sleep. I believe the Bluetooth module draws most of the current and even if I take drastic action and modify the Arduino board, the best I can hope for from two AA batteries is about a week. I need another plan. Turning on the transmitter from cold means it needs to pair with the receiver in the garage. This takes about 2 to 3 seconds using the current settings. 3 seconds is about how long it takes to get from the front door to the garage so I am just about in the right ballpark to start the transmitter from cold and auto-send and unlock command. The Bluetooth modules communicate at 9600 bit/sec. I can always increase this data rate to see if the pairing can be speeded up. With these thoughts, it may be possible for the 'unlock' button to prove a 5 second burst of power to the transmitter circuit and then switch off again. This would mean that most of the time, no current would be drawn at all and the batteries would last for years. The transmitter sketch would then not need any sleeps, it just needs to wait for the Bluetooth to pair and then send an 'unlock' command. The receiver could send an 'OK' back to the transmitter that would be used as a shutdown command (I.e. drain the capacitor). The outline of the design is shown in the diagram. I decided in the end turn power on and off to the arduino/Bluetooth module using a reed relay. This ensures the electronic modules are fully powered up and switch off abruptly rather than gradually turned off as the FET shuts down. The circuit will behave more predictably this way.
In the end I settled on switching on the transmitter for up to 30 seconds. I changed the transmitter code so that it would send an 'unlock' command every second or so until the timer switched off. This gives time for the bluetooth devices to pair and the receiver can ignore extra unlock commands. Reed Relay Delay Circuit
Assembled Transmitter Circuit
Boxing the Transmitter
And it works! The door is unlocked within 3 seconds. Once in the garage, the lock will open and close again on the second transmit but if the door is shut, it stays shut. I could put a two way send/acknowledgement mechanism in here but this simple solution seems to work well and achieve the goal so I will leave things as they are for now. The transmitter was built into a large ring box. This contains the two AA batteries, the arduino pro and the Bluetooth module. It has a small switch on the top and this sits just inside the house near the door.
So here ends a totally over-engineered door lock. Averaging 4 trips to the garage a day, this means the transmitter will be turned on for no more than 2 minutes and be drawing 35mA from the batteries. At this rate, the batteries will last for years and it may even be possible to use a button cell to power things. I suppose it is time to focus on more practical things to pass the time, but this was an interesting diversion and allowed me to learn a few things along the way which is always a good thing :-). | |||||||
| |||||||