Have keys become archaic to you in this technological age? Follow me as I unlock my apartment door with my smartphone.
This is an ESP8266 based project that utilizes a local network connection and a smartphone widget that drives a servo to press a button. This isn't limited to only intercom buttons; any buttons can be pressed as long as the device is within the network range.
I was lucky enough to be in my network range from outside the apartment.
ComponentsBoM:
- ESP8266
- SPST Slide Switch (optional)
- Perf Board
- USB Cable
- Magnet 8mm x 2mm [x2]
- M2 6mm bolts [x2]
Tools:
- 3D Printer
- Soldering Iron
- Hot Glue Gun (optional)
- Allen Key
Software:
- Arduino IDE
- HTTP Widget App (Android)
- Fusion 360
All that's needed is an ESP8266 and a servo. My design doesn't include any optoisolators or flyback diodes, so there's risk of damaging the ESP8266.
Wiring diagram:
Wired up:
Follow these instructions to begin using the ESP8266 with the Arduino IDE.
Serial Communication
I had to use software serial because I couldn't get the standard hardware to cooperate.
#include <SoftwareSerial.h>
SoftwareSerial ESPserial(2, 3);
ESPserial.begin(115200);
ESPserial.println("AT+IPR=9600");
delay(1000);
ESPserial.begin(9600);
Network Setup
I added my network credentials, and connected my ESP to my network. Once my router assigned it an IP address, I made it static in my router settings. Then I created a server object via port 80 to use http pages.
Customize Page
Arguments in client.println appear when accessing the ESP's IP.
client.println("Click <a href=\"/open\">here</a> to open door<br>");
Clicking on the "open" hyperlink redirects the user to 10.0.0.X/open. Accessing 10.0.0.X/open begins the servo control.
if(request.indexOf("/open") != -1){
MoveServo();
}
Servo Actuation
I remove the servo from its pin after each use in order to eliminate jittering during idle.
void MoveServo(){
myservo.attach(servo_pin);
for(uint8_t i = released_position; i > pressed_position; i--){
myservo.write(i);
delay(arm_speed);
}
delay(pressed_time);
myservo.write(released_position);
delay(500);
myservo.detach();
//Serial.println("Button Released");
}
The servo arm presses the button slowly; too fast runs the risk of delaminating the magnets from the faceplate. The amount of time that the servo arm keeps the button pressed can be altered in the global variables, and I had mine set to 3 seconds. I had to calibrate the bounds of the servo arm through trial and error.
OTA Updates
I wanted to add the ability to upload new sketches remotely without the need to detach the device, but didn't get this to work and had to move on to other projects. G6EJD's Tech Note 025 is a great guide, and he provides all the source code.
Remote AccessIn case you want to access the ESP from outside the network, you can use a VPN for secure tunneling or use free alternatives such as activate port forwarding on your router with a Dynamic DNS to track your public IP, which can change. Popular ones include: No-IP, Duck DNS, DynDNS. The latter can be a security threat as it opens port 80 to the public.
Mobile AppInstead of typing 10.0.0.X/open into my browser, I used HTTP Widget to make a button on my home screen that does this.
These were my settings:
Add the widget to your home page just as you would do with any other widget, and that takes care of the "front end" for this project.
EnclosureCAD time!
Parts were printed in Makergeek's PETG.
The strange shaped magnet is a broken neodymium magnet from a hard drive.
The servo was secured to the print using M2 bolts.
Sticks to the intercom just fine.
Comments
Please log in or sign up to comment.