It seems to be a May Spring Bank Holiday tradition that I decide to pick up Arduino projects. When I looked back at my WhatsApp history with my flatmate to find the photo that I’d sent to him showing what I’d started it was the 28th May 2018. At the time, I had an Arduino Uno microcontroller board (based on the Microchip ATmega328P) that I’d had since my University days, along with a relay, which I decided to put to use to make a tool to allow us to unlock our front door from our smartphones.
Whilst this was just for fun, there were a few very small practical benefits;
- It would allow our partners who do not have keys to open the front door themselves
- It would allow me to get into the building without having to dig around in my bag for keys in the cold.
Of course, this was only the building entrance. This was relatively straightforward as our building has an Entryphone to each flat with a 5901 handset, which uses a simple push-button to release the latch on the door, which then stays open once pressed. So all I had to do was emulate a quick (250ms) button press using a relay.
There was still the matter of our flat door, but that’s another project.
- Entryphone Of London 5901 Legacy
- Arduino Uno and Ethernet Shield
- Relay Module
My flatmate helped out with the Entryphone modification. In order to maximise the chances of us getting our deposit back and limit the damage we did to the pre-installed Entryphone, instead of making too many holes in the case and adding a jack connector, we ran an Ethernet cable through the same hole as the handset cord so it can be disconnected relatively easily and without leaving a trace. As we wanted to be able to remove the Arduino, I left the RJ45 connector on the other end and used a keystone jack to connect to the relay. As I was unsure of the power coming through the Entryphone, I chose to use a relay instead of a transistor to limit any damage.
Here’s the wiring, once the casing was back on the phone,
I needed the Arduino to be able to accept a request and then turn on a digital pin, wait 250 milliseconds and turn the pin back off. I chose to use I chose to go with HTTP and the Ethernet shield to get the device connected. The relay would be connected to that pin, and the two terminals of the relay connected to the wiring behind the button.
I wrote a very basic web page with an image of a door that sent a GET request to /relay1on and hosted this on the Arduino itself. I could then access it when connected to the internal network from the IP address.
Updating the Hardware
In order to make the hardware more acceptable, and not require an ethernet cable running across my flat, I swapped out the Arduino Ui for a Wemos D1 (R2), with the ESP8266 Wi-Fi module built in, removed the breadboard, added a USB power bar and mounted in the most project-box like container I had to hand: a Chinese takeaway box.
I thought this would be a quick fix, and the code would run more or less instantly, but I ended up rewriting all of the Arduino code. For starters, the original code included the Ethernet and SPI libraries, which were no longer needed (instead using ESP8266WiFiMulti and ESP8266WebServer). I then discovered, after much playing around and failing to even get a Blink sketch to run, that the visible pin numbers written on the Wemos D1 do not relate to the internal pin numbering.
The Wemos D1 was something I’d ordered from eBay the last time I was using my Arduino and then lost interest in by the time it arrived. I’ve now ordered a D1 Mini, which will hopefully be here before the next bank holiday.
Updating the Software
Interface design is something I’ve not yet focussed on: I just wanted to get something functional up and running. As part of the hardware switch, I did change the web server script to ESP8266 First Web Server from A Beginner’s Guide to the ESP8266 to handle a POST request (instead of GET) and move the rest of the interface over to be hosted elsewhere.
I’ll cover the web interface design in the next post!