The WeMos D1 Mini is a fantastic little development board based on the ESP8266 microcontroller with WiFi. It’s super cheap, and there’s even support for it now in the Arduino IDE so you can program it easily. If you haven’t seen it before, check it out on the WeMos site.
One limitation is that it needs 5V USB power to run, which is a pain if you want to build it into a project that doesn’t have USB power easily available. I designed this shield to give the D1 Mini the ability to accept power from 7 to 14Vdc (up to 20Vdc in a pinch) via a 2.1mm DC jack or screw terminals.
I hope to turn this into a product soon: I just need some more parts to arrive. There’s a page for it now at www.superhouse.tv/d1mpower.
Most cat doors are a simple flap that can be pushed open from either side, and allow any cat to pass through. The SureFlap Microchip Cat Flap is physically quite similar to a traditional cat flap, but it includes an RFID reader that allows it to scan the RFID microchip implanted in your cat and only unlock if it detects a recognised ID. All other cats (and other unwanted intruders such as squirrels and possums) are prevented from entering.
There are two models available: the basic Microchip Cat Flap featured in this review, and the more advanced DualScan Microchip Cat Flap. The difference is that the standard model only includes an RFID reader on the outside while the DualScan has separate readers on both the outside and the inside, which allows it to provide more advanced features such as allowing one cat to exit while keeping another cat locked inside.
Physical installation of the Microchip Cat Flap requires some DIY skills, depending on the material in which it’s mounted. Fitting it in a wooden door or plain wall is a simple matter of tracing the shape, cutting it out with a jigsaw or similar, sliding the flap into place, and screwing it on. If you want to mount it in a glass door you’ll probably need to use the services of a glazier to make the cut for you, or replace one of the glass panels in the door with timber.
Once the flap has been mounted, programming it to recognise your cat is incredibly simple. Just put in the batteries, press the “program” button, and either hold your cat near the entrance of the door or just wait for it to come and investigate by itself. As soon as the flap reads a valid implanted RFID chip it will store the ID and enter normal operation mode, which will cause it to unlock whenever it sees that ID. Its memory can store up to 32 IDs, and you can also erase its memory and start again if you accidentally program the neighbour’s cat in by mistake!
Setup really is ridiculously easy. There’s no app to install, no Bluetooth or WiFi configuration, nothing confusing at all. Just power it up, press that button, and you’re done. I can’t overstate how smooth and easy the setup process is.
The only reason the MicroChip Cat Flap doesn’t receive a perfect 5/5 score for setup is because of the effort involved in physically installing it. This isn’t something you can take out of the box and use: you’ll need an hour or two of messing around with tools to get it installed, but once you’re past that stage it’s totally foolproof.
Setup score: 4 out of 5
One of the reasons the SureFlap Microchip Cat Flap is so easy to set up (hooray!) is because it doesn’t have many features (boo!). Once you’ve programmed in your cat IDs, the only control you have is a manual rotary dial that lets you select one of four operating modes: bidirectional; in-only; out-only; and locked. Most of the time you can just leave it in bidirectional mode, which means it will scan RFID tags to only let recognised cats enter but let any cat exit. If you want to trap your cats inside at night you can set it to enter-only, and they’ll be able to come inside but not get out again.
There’s no way to set the mode electronically, or to set acceptable time periods for different modes. Twisting the knob is the only way to change it.
Feature score: 2 out of 5
If you don’t care about different operation modes at different times of day, there’s nothing to do once the flap is set up so there’s not really any “usability” from that point of view. However, I had some major problems with it: including one problem so bad that it lead to one of our cats having part of its tail amputated. But we’ll get to that in a moment.
The flap requires significant force to open so our cats have had trouble pushing it open. As a result they couldn’t work out whether it was in “locked” mode or if they just needed to push harder to open it.
The solenoid triggered by the RFID reader makes a significant “clunk” noise when activating which may scare timid cats. As our cats sniffed around it out of curiosity about the new thing, it clunked and made them jump. It took a while for them to learn to ignore the sudden noise each time they came near it. To get them accustomed to it we took the batteries out and taped the door permanently open for a while, so they could get used to going through it without the noise.
Changing the mode requires crouching down to twist the knob while peering at the small symbols printed on it. Because it’s mounted down near the floor, you need good eyesight to see the symbols from a distance. Just checking what mode it’s in requires bending down close to it. Being able to tell at a glance from across the room would be very handy, and could be achieved by something like a coloured dot that changes with the mode.
Now for the really bad part. I’m sure the vast majority of SureFlap customers don’t have this problem, but one of our cats suffered a serious injury trying to use the door. Because she couldn’t figure out how to get the door open to go outside, she got in the habit of bashing at the bottom of the flap with one paw. The plastic locking tab that keeps the door closed is exposed on the bottom edge, so if she was desperate and persistent she found she could get the door to pop open slightly inwards, by bouncing the door as the locking tab was pushed down by her paw. She’d then pull the flap fully open and wriggle underneath to get outside, with the door opening inwards towards her – the opposite of the direction it’s meant to go!
But of course the flap is spring-loaded so it pushes down and tries to close, and because her tail is the last part to go through the door it gets pinched between the frame and the flap. The result was that one time she got her tail caught badly enough that she pulled apart two of the bones in it, and afterwards the end of her tail had a right-angle bend in it. That was bad enough, but then the tail began to die. Our vet said the only thing to do was to amputate it just short of the break, so now her tail is about 1/3rd shorter than it used to be.
Usability score: 1 out of 5
The build quality seems excellent. I pulled it apart to look inside and found that it’s very well made, and the coil design (looping right around the entrance instead of being merely placed above it) gives great read range. It recognises our cats as soon as they walk near it, before they even put their head into the entrance.
Quality score: 5 out of 5
Unfortunately this is where the SureFlap Microchip Cat Flap really loses points. It’s designed to be totally self contained: it stores all IDs internally, and provides absolutely no way to connect it to anything else. As high-tech as it is, this is not an Internet-of-Things device because it has zero connectivity. No Bluetooth, no WiFi, no Zigbee, no serial port, not even a set of dumb dry-contact terminals for activity reporting or mode control. Out of the box there is no way at all to integrate it with a home automation system.
Of course I’d never be satisfied with that, so my plan is to retrofit a DIY interface of some kind to report activity.
Extensibility score: 0 out of 5
If you have a problem with feline intruders, this may well be the solution you’re looking for. But to use it as part of a larger home automation system will take some significant work and ingenuity. You also need to pay close attention to how your cats start using it, so that they push on it the right way and don’t develop the bad habit of trying to pull the door open.
Overall score: 12 out of 25, and (in our case) a large vet bill and distressed cat.
Just wiring up some lights so you can control them from your phone isn’t real home automation: that’s just turning your house into a really big remote controlled toy, even if you can do it from the other side of the world. For real automation your house needs to change its behaviour based on sensor input, and security sensors are a great way to add simple inputs that allow your house to make decisions about things like turning lights on and off automatically.
In this episode I show a clever way to connect security sensors up so that intruders can’t tamper with the cables undetected.
Control physical devices using an Arduino based home automation controller that connects to your network and lets you switch things on and off using a web browser. This episode shows the construction sequence of a controller that combines an Arduino-compatible board, Power-over-Ethernet, and relay driver shields to create a self-contained controller that can serve up its own web interface so you can click buttons in your browser to turn devices on and off.
As shown in the video, decide how your device will be mounted and where you want external connections such as the Ethernet cable to be located. Drill suitable holes in the case and mount your Arduino in place. It can be a good idea to use plastic screws as shown in the video to prevent any possibility of short circuits to the outside of the case.
There are many options for software to control the device. For example, you could have it subscribe to an MQTT broker (server) and update its outputs based on publications from other devices. Or you could provide a menu via the serial console to control it manually from a computer connected via USB.
For this example I’ve provided a sketch that runs as a web server via Ethernet, and serves up a web page that includes “on” and “off” buttons for each of 16 outputs. By loading the web page in your browser you can simply click the appropriate buttons to activate and deactivate devices connected to those outputs. This example uses two Relay 8 shields, but it works just fine with a single shield as well. There’s no harm having the extra buttons visible and nothing will be damaged if the Arduino tries to address outputs that don’t exist, but you can trim it down to only 8 outputs if you prefer. It can also be scaled up to 24, 32, etc outputs if required.
Commonly available IP cameras are great if you just want something that lets you quickly view a live stream from your laptop or smartphone, but if you want to keep footage more permanently (such as for a security recording) you can do that too without too much trouble. In this episode I show you how to use an Ubuntu Linux machine on your network to run as an FTP server to accept snapshots from your cameras, process those snapshots to add timestamp watermarks on the images, and then periodically convert them into a time-lapse video to quickly see what happened over a period of time.
IP camera with FTP upload capability (eg: Foscam FS8918W)
Computer running Linux (I use Ubuntu in this demonstration)
ProFTPd (FTP server software)
Imagemagick (image processing software)
Mencoder (movie encoder software)
Setting Up An FTP Server
If you already have access to an FTP server you can skip this step, and go straight on to “Configuring Your IP Camera”. You can even use a third-party FTP server located off-site if you like, but my preference is to run a local server. This has a few advantages, including limiting use of the very insecure FTP to your local network, and giving you the opportunity to do some processing of the images on the server.
On Ubuntu, installing ProFTPd is as simple as opening a terminal and typing:
sudo apt-get install proftpd-basic
Ubuntu will install the FTP server and even start it for you automatically.
However, there’s one extra step you can take to increase security just a little. By default, ProFTPd does not jail users within a specific directory: that means anyone logging into your FTP server can see the whole filesystem. Let’s lock that down a bit.
Using a text editor, open the following file:
Around line 34 you’ll find the following entry:
Remove the leading crosshatch to enable that option, so the line shows:
Save the file, then restart ProFTPd so it will see the changes:
sudo /etc/init.d/proftpd restart
Now users who connect by FTP will be jailed inside their home directories.
I prefer to create separate users for each camera so they all end up compartmentalised, but that’s totally up to you. If you want to create a new user for a camera, you can enter the following:
sudo adduser camera41
Of course you can substitute your own username convention to suit your requirements. In the example shown in the video I set up a user for camera 41, so I just made that the username for convenience.
Configuring Your IP Camera
Configuration options may vary depending on your particular model of camera and firmware version, but look for a section titled “FTP Service Settings” or similar.
You’ll need to enter the address of your FTP server: usually the IP address of the Linux machine if you’re running your own server, otherwise it may be the hostname if it’s set up in DNS.
You’ll also need to enter the FTP username and password you just configured a moment ago, and optionally specify a target directory name if you want uploaded images to be put into a specific location. Some cameras create the target directory automatically if they find it there, otherwise you may need to create it yourself on the server.
In the case of Foscam cameras, you can’t test the setup or configure an upload rate until you save the settings. Click the submit button, tick the “Upload image now” checkbox, and enter a sensible value for the upload interval. In my example I set the upload interval to 1 second.
Watermarking Images With Timestamp
Most cameras upload snapshot images with the filename set to something useful such as the timestamp. In the case of Foscam cameras, the filename is the camera identifier, then the timestamp, then a sequence number. That’s useful information so I like to place the filename as a watermark in the image itself.
You can process a collection of images using ImageMagick. If you don’t have it installed on your Ubuntu Linux box already, open a terminal and enter:
sudo apt-get install imagemagick
This will give you the “convert” program which can be used to place text on images.
In a terminal, go to the directory containing uploaded images and enter:
for name in *.jpg; do convert "$name" -font courier -pointsize 20 -draw "gravity south fill black text 0,12 '$name' fill white text 1,11 '$name'" "$name"; echo $name; done
That command can all be entered as one line, although it’s wrapped here in the browser.
This is a “for” loop that will step through all the files with names matching “*.jpg”, and write the filename into them near the bottom center first in black and then in white. This helps the text stand out whether the background is light or dark.
If you open the images after running that command you should see text added to the bottom that shows the filename. Here’s one from the example shown in the video:
Converting Images To A Time-Lapse Movie
Now that you have a collection of watermarked images taken at whatever interval you configured in your camera, you can process them periodically into a time-lapse movie so you can quickly scan through what happened while the camera was recording.
There are a variety of tools for doing this, but one that’s easy to use is mencoder. If you don’t have it installed, open a terminal on your Ubuntu Linux machine and type:
sudo apt-get install mencoder
Now you can go into the directory containing the watermarked images are run the following command:
This tells mencoder to operate on multi-file (mf) input, that it’s processing images of type JPG at 640×480, setting the output video codec (ovc) to libavcodec, setting mpeg4 compression, and writing the output file to “output.avi”.
Here’s the example video I created for the demo:
Wrapping It All Up
Of course you probably don’t want to run those commands manually all the time, so you could combine them into a shell script and execute it periodically using cron. You’ll probably also want to include a sequence number or (better still) timestamp in the name of the output file, so that you can come back later and easily see what period is covered by each movie.
In 2007 there was a lot of argument about putting RFID tags into Australian passports, and many people were saying we were destined for a future where everyone was implanted with RFID so they could be tracked by the government and large corporations. I wanted to understand the technology and the risks involved, so I did the only logical thing: I implanted an RFID chip in myself!
I’ve shown use of my implanted RFID chip in previous SuperHouseTV episodes, but this is the first time I’ve shown the footage of me actually implanting the chip in myself.
Now that I’ve modified the Lockwood Nexion door lock on my workshop for Arduino control, the next step is to add an RFID reader near the door so that I can scan the RFID chip implanted in my arm to unlock the door.
Note that I deliberately did not go into any detail of the RFID implantation in this episode, so it’s safe to watch even if you don’t want to see me doing home surgery on myself! I’ll cover that in a separate episode so anyone who doesn’t want to see it can avoid it.
Door locks are one of the most useful things to control from your home automation system. Using electronic locks you can give your house central locking just like your car, control them from your phone or via the Internet, or even control them using an RFID tag or implant.
I modified a Lockwood Nexion keyless lock to allow it to be controlled by an Arduino, and linked it to my home automation system.