iPhone + Blynk = Keyless house entry

Somehow I missed hearing about Blynk when it was a thing on Kickstarter in early 2015.
Fast forward 6 months and it's in the field and while it's still early days, Blynk looks like a load of fun.
I've been working on a keyless entry system for my house, because I've always wanted to be able to just push a button and come in, like modern cars. A friend gave me some leftover parts when he moved house, including a solenoid striker plate. I replaced my front door recently during a renovation, and decided to install the lock hardware at that time.
As someone who remembers how difficult and expensive electronics was in the 80s, the age of Smart Objects is exciting. You can basically plug together a selection of off-the-shelf modules without having to pick up a soldering iron. Now Blynk brings the same convenience to the software side.
While I learned to code in Assembler, and I learned electronics at the transistor level, I don't miss either.
Blynk is an app for iPhone and Android which connects Things to the Internet. It uses a cloud service to make your device accessible, or you can run your own server. The intended devices are ethernet or wifi connected microcontrollers such as the Arduino. In my case I'm using a board based on Arduino nano, tethered to a Raspberry Pi over USB. I find the combination of a Pi for brains and an Arduino for 5 volt-io-and-replaceable-if-you-smoke-it brawn is the sweet spot in robotics and automation projects.
The hardware



Raspberry Pi single-board PC: This computer is my home automation hub, it connects to cameras sensors and actuators around my house.
Arduino Nano: while the Pi has its own IO pins, they're unbuffered 3v and a little too easy to blow up. I prefer to use microcontrollers of various kinds as a "hind brain" for my Pi projects.
Relay board: an inexpensive module that holds several 5 volt relays, which are controlled by outputs pin of the Arduino.
Solenoid door strikeplate when the 12v solenoid is energized via one of the relays, the door opens with a light push
Passive Infra-Red (PIR) Sensors two sensors will detect movement near the door, for automatic lighting.
LED light strips: Another relay energizes constant-current LED driver circuits that power two 8-watt LED strips.
Arduino Pin assignments
- D2 (output) Relay A, the door solenoid
- D3 (output) Relay B, the LED lighting array
- D4 (input) PIR Sensor A, internal movement sensor
- D5 (input) PIR Sensor B, external movement sensor
- D6 (input) Reed Switch, for open door detection
Prototyping the software - Arduino plus Bitlash

I've been using Bitlash for quick prototypes, it's an interpreted language resembling C that runs on the Arduino platform. The following bitlash functions allowed me to test and tune a working model of the system on a breadboard.
function startup {iosetup; run getpir; run lights; run lockdog }; function iosetup {pinmode(2,1); pinmode(3,1); pinmode(13,1); d2=d3=p=d=0 }; function getpir {p=d4|d5; d13=p; snooze(100) }; function lights {if (p) {d3=1; snooze(30000)} else {d3=0; snooze(250)} }; function lockdog {d2=d; if (d) d=d-1;d2=d;snooze(1000) }; function unlock {d=10 }; function lock {d=0 };
The system polls the PIR sensors every 100ms, and if the sensors detect movement the LED lights are turned on for 30 seconds, then off again. (By which time you have opened the door and turned on the house lights). If the 'unlock' command is given, the solenoid is activated for 10 seconds. (It turns out 5 is plenty).
Installed version - Arduino plus Blynk


The installed version of the application uses a timer to inspect the sensors 4 times per second. When a motion event is detected, the lights are activated. Every sensor is pushed to Blynk, and there are "Virtual Pins" configured for Blynk to activate the relays.
Blynk uses Virtual pins for pushing events to the cloud and also for sending actions to the Thing.
In this case the sensors, light and lock status are pushed on pins V0,V1 and V2, while the lights and lock can be actuated by writing to pins V3 and V4.
Virtual pin v5 is the "whoops, did I leave the front door open" sensor, for those moments when you get to the end of the street and think "I don't remember if I locked the door!".
Code is at github.
5 comments:
nice bLog! its interesting. thank you for sharing.... http://saddlebacklighting.com/
This one is good. keep up the good work!.. LightsOnClub.com
Nice post! This is a very nice blog that I will definitively come back to more times this year! Thanks for informative post. This is free site webstagram about instagram.
Nice blog, it is very good hardware. I am impressed with this feature of the phone. wonderful product for working hard. whatsapp mod
Post a Comment