Ambition
I wanted a camera mounted by my front door so I could see who is at the door. There are plenty of solutions for this both off-the-shelf and DIY but I couldn’t find anything that fitted my 3 main requirements:
- To be completely wireless, no hard wired power.
- To be viewable at any time, not just when someone rings the doorbell.
- To not cost a fortune (i.e. a Ring doorbell).
I did find the odd cheap off-the-shelf option such as the Digoo SB-XYZ Video Doorbell but based on the reviews I’d seen I wasn’t convinced this would be a good option. I decided to go down the DIY route.
Concept
The big issue to overcome was power. The idea that I had was to only power up the camera when it was needed i.e:
- When someone is at the door.
- When I want to view the feed.
I have no need to record all the time.
I could have gone down the route of the doorbell press enabling the power but this wouldn’t allow for condition 2.
What I settled on eventually was to power and de-power the unit remotely using 433mhz RF.
First Attempt
My first attempt used a Raspberry Pi Zero with a camera plugged in. The issue with this setup is that (for this purpose) the Raspberry Pi takes way too long to boot up. By the time I’d have any access to the camera the person at the door would have gone.
Working Model
After a lot of tinkering I now have a working model. It works like this:
Step 1
Someone presses the doorbell (a Xiaomi Button).
Step 2
The button press is picked up by Home Assistant and an automation is fired.
Firstly the Xiaomi Gateway plays a doorbell tune (lets keep some tradition).
Then the automation script turns a Pilight Switch to on which in turn sends out a 433mhz signal using an RF transmitter (plugged into the RPi running Hass). The automation scripts then waits…
Step 3
The RF signal is picked up by an RF Decoder within the camera setup. At the time the RF signal is sent this is the only device consuming any power and it has a very low standby current.
Step 4
The RF Decoder raises one of it’s data pins to high, this raises the gate of a MOSFET to high which allows power to flow through to the camera setup.
Note: In the images I am using a Pololu Power Control Board instead of a MOSFET, this is a bit overkill but at the time I didn’t have a MOSFET to hand.
Step 5
The camera setup consists of a Wemos D1 Mini and an ArduCAM Mini.
Using a modified version of this sketch the Wemos boots up, connects to the WiFi and then to my MQTT server.
As soon as it’s connected it sends an MQTT message to Hass which in turn triggers an MQTT Binary Sensor to turn on, this indicates that the camera is powered up and ready to go. The whole process so far only takes around 2-3 seconds (this is fastest if a static IP is used as DHCP slows things down).
Step 6
Now that the binary sensor is on, Hass knows the camera is ready and the automation script continues.
The next step is to capture a snapshot of what the camera is seeing (who’s at the door). This is done via a Shell Command which performs a wget on the URL that serves up a static image from the camera. The saved image is stored on the Hass server.
Step 7
We have what we want now so we power down the camera.
This is achieved by switching the pilight switch to off which in turn sends out an RF signal to the RF decoder. The RF decoders data pin is sent low which triggers the MOSFET to cut power to the Wemos and ArduCAM.
The last step in the power down sequence is that when the Wemos originally connected to the MQTT server it set a LWT / Last Will and Testament Message, this is essentially a message that the MQTT server holds on to until the client disconnects (for whatever reason). The powering down of the Wemos causes this LWT to be sent and the binary sensor that indicates the camera is operational is set to off.
Step 8
The image that is saved is “connected” to Hass using the Local File Camera Component. This is a simple way to serve the image over the internet using the Camera Proxy method of Home Assistants RESTful API.
Allowing the image to be viewed over the internet is a requirement of the next step.
Step 9
Finally the automation script sends out an iOS notification. This notification contains the URL for the camera proxy serving the image we just took. This allows the image to be displayed in the notification.
Notes
All in all the whole process from doorbell press to photo notification being delieverd takes around 10 seconds (not too shabby).
I can also trigger the camera to turn on simply by toggling the pilight switch. The camera also provides streaming MJPEG video which can be viewed in Hass.
In my setup the camera is mounted inside the front door pointing out through the doors window. It’s fixed with sticky pads until I find a better solution.
The lens that comes with the ArduCAM is more telephoto than wide-angle. Luckily you can pick up alternative wide angle lenses pretty cheaply.
Currently I have 3 AAA batteries powering the setup. In theory these should last a long time but I’ve only had the setup running for a week now so time will tell. I have ordered a Lipo battery which will be a better fit for this project.
I could save on more space by taking out the mini breadboards and soldering everything together.
I’m also hoping to re-case the project as the box I am using at the moment isn’t the prettiest thing.
Wiring Diagram: