Automatic Door Opener

by Cedric0de in Circuits > Microcontrollers

143 Views, 1 Favorites, 0 Comments

Automatic Door Opener

door.jpg

I will attach a motor to my door so that it will automatically open when my dog gets close to it. I chose this project because I have a problem in my house where my dog locks himself in my room when he enters it and then he can’t get back out. Then he barks at the door disturbing my upstairs neighbors, so I want it to open automatically so I don’t have to open it every time or leave my door open. My door is very easy to open because the mechanism in the door is broken so it cannot lock allowing for it to be pushed or pulled open without having to turn the knob.

Supplies

IMG_7036 (1).jpg
  • ESP32
  • Breadboard
  • Rope/String(I used fishing wire)
  • DC motor
  • Motion sensor
  • 3v coil relay dpdt
  • Jumper wires
  • 10kohm
  • tape
  • MOSFET

Motion Sensor

IMG_7042.jpg
download.jpg

Get a motion detector to detect movement and run a function that will later spin the motor for a certain amount of time. The motion detector needs 5 volts to work which is why I used an ESP32. I turned the left orange knob all the way to the left and the right knob all the way to the right. I also put the orange jumper over the top 2 pins to activate single trigger mode. I plugged the voltage wire into the 5 volts the ground to the ground and the digital input to d4 on the ESP32.

DC Motor

IMG_7037.jpg
Hobby motor.png
IMG_7040 (1).jpg
RELAY.png

The next thing that needs to be set up is the motor. I used a hobby motor because that was just enough to open my door and have enough voltage. The motor needs a very specific setup that will let the motor go from motionless to moving in one direction stopping then moving in the other direction.


The voltage will go on the bottom right row that is connected with a jumper wire to the right com. Ground is connected to the bottom pin of the mosfet and to the coil and the other side of the coil is connected to D2. The middle pin of the mosfet is connected to the other com. A resistor connects the two end mosfet pins. The top pin of the mosfet is connected to the D16. Both pins of the dc motor should be connected to a NO and NC taking one NO from one side and taking the NC from the opposite side.

Coding

The code to this is very simple. All that is necessary is to read the data of the motion detector that will either return a 1 if it senses motion or a 0 if it doesn't. Then use that data to activate a fixed time based function. It will activate and the door will only be open for a certain amount of time.

The way the motor moves is with 2 digital pins that turn it on or off and swap the polarity.

int MOT = 4;
int POL = 2;
int ON = 16;
int val = 0;
void setup() {
    pinMode(POL, OUTPUT);
    pinMode(ON, OUTPUT);
    pinMode(MOT, INPUT);
}


void loop() {
    val = digitalRead(MOT);
    if (val == HIGH && STATE == LOW)
    {
        Rotate();
    }
}
void Rotate()
{
    digitalWrite(ON, HIGH);
    delay(10000);
digitalWrite(ON, LOW);
delay(5000);
digitalWrite(POL,HIGH);
digitalWrite(ON, HIGH);
    delay(10000);
    digitalWrite(ON,LOW);
    delay(10000);
    digitalWrite(POL,LOW);
    STATE=LOW;
}

Attaching

Working auto door opener

As I said in the intro to this project my door is very easy to open so by attaching a rope to the knob I can pull it open with a little force. I taped the motor to the ground and now it is able to pull my door open. For the video I hold it in my hand so it is easier to see how it works.


This project took several attempts and I am proud of the finished product. It was very physical oriented because my biggest problem with this project was not having enough voltage because I was using a argon at the start. I had a finished one with the argon, but it was really inefficient because it took 2 extra batteries and an extra mosfet. Using a stronger microcontroller was definitely better, but it can still be done with an argon, but it would be a lot worse.