Introduction: Smart Door Opener

This project is done by a group of students from Singapore Polytechnic, School of Electrical and Electronic Engineering. We have a total of 3 members in our group, Takuma Kabeta, Jun Qian, Yong Hua. Our supervisor is Mr Teo Shin Jen.

The purpose of our project is to create a smart, door opener to unlock the office door with Wall Mount Push Release Button Switch using the servo from inside the office using a smartphone.

Step 1: Items Required

  1. What is required for this project
    • Smartphone with Evothings Viewer application installed [download from Google playstore] (free)
    • Evothings application software (free)
    • 3D printer (optional)
    • Sketchup2017 software (optional)
    • Arduino IDE(free)
    • NodeMCU 8266
    • SG90 Servo motor
    • Jump wire and circuit board
    • 5v output socket and USB to USB type B cable
    • USB type B Socket

    Step 2: Hardware Setup for the Smart Door

    • First solder the USB B socket and header pin to the circuit board.
    • Second solder the header pins.
    • Use the jump wire and connect USB type B VCC and from GND to header pins.

    *Make sure not to mistake D+, D-, VCC, GND pin on USB B socket. (We do not need to use D+ D- pin) We need this because nodeMCU only provide 3.3v which is unable to power servo motor.*

    • After Soldering the socket make sure to drilling/cut connection between VCC, GND, D- and D+ connection.(image above show the cutting between each connection)

    Step 3: Wire Connection

    Next, connect devices with jump wires.

    • Connect your VCC(White wire)and GND(Grey wire) from header pin to Nodemcu VCC and G pin
    • Connect VCC (RED wire) and GND (BROWN wire) from header pin to Servo pin.
    • Connect your servo signal pin (Orange wire) from to Nodemcu D1 to Servo data

    *The servo data and VCC power must send a signal by same voltage. If you make servo VCC = 5v and data send to Servo by 3.3v the servo will not operate*


    Step 4: Software Setup for the Smart Door

    Please download the following software

    Now you must download the software to the computer. (This software allows you to create 3D structure.)

    Use to establish communication with Evothings viewer application and Nodemcu to control servo.

    The software is used to program NodeMCU.

    This application allow user to remotely send signal to Nodemcu

    • Evothings Viewer from Google play store

    Step 5: Installing File to Operate NodeMCU on Arduino IDE

    After completing all the software installation, open up the Arduino IDE program.

    Now go to "files" section on headline and click on the "preference" in the Arduino IDE

    Copy this Url "http://arduino.esp8266.com/stable/package_esp8266com_index.json" and paste it to "Additional board manager URLs:"

    Step 6:

    Next, go to "Tools" section in the headline and choose "board". select "Board Manager".

    In the board management enter "8266" in search section on board manager. Install the file name"esp8266 by ESP8266 Community software version 2.3.0"

    Step 7:

    After installation go to tools and board, and select "NodeMCU 1.0(ESP-12E module)"

    Now you are able to upload code to NodeMCU

    Step 8: Downloading the Program Code for Nodemcu to Communicate With Evothings Viwer App

    After completing the previous step, download ZIP file contains source code files from following URLs.

    • This source file allows Nodemcu communicating with Evothings program. After downloading the file open the file name "esp8266" using Arduino IDE. This code will be the main code running in Nodemcu8266 receiving an order from Evothings viewer app from a smartphone.

    https://github.com/evothings/evothings-examples/tree/master/examples/esp8266

    • This source file is required in the Arduino library to control the Servo movement.

    https://github.com/esp8266/Arduino/blob/master/libraries/Servo/src/Servo.h

    • This source file is required in Arduino library for NodeMCU communication with Access Point

    https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WiFi/src/ESP8266WiFi.h

    Step 9: Modified Code

    I have edited some part of code from file "esp8266" to run the servo motor when signal sent from Evothings app,

    You can replace the code below with the esp8266 code file or arrange it yourself.

    This will be the code I have edited on esp8266 file to control servo motor on Nodemcu with evothings viewer application

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////

    #include <ESP8266WiFi.h>
    #include <Servo.h>

    Servo myservo;

    const char* ssid = "Singtel_Project-TK"; //Enter your AP SSID

    const char* password = "Projectsch888"; //Enter your AP Password

    const int ledPin = 2; //This will flash the nodemcu internal led once network communication is success

    WiFiServer server(1337);

    void printWiFiStatus();

    void setup(void) {

    Serial.begin(115200); //serial monitor is displayed(please set to 115200 to see message displayed by nodemcu)

    WiFi.begin(ssid, password);

    // Configure GPIO2 as OUTPUT.
    pinMode(ledPin, OUTPUT);

    myservo.attach(5); //The pin 5 will be D1 pin in Nodemcu

    // Start TCP server.

    server.begin();

    }

    void loop(void) {
    int pos;

    // Check if module is still connected to WiFi. if (WiFi.status() != WL_CONNECTED) {

    while (WiFi.status() != WL_CONNECTED) {

    delay(500);

    }

    // Print the new IP to Serial.
    printWiFiStatus();

    }

    WiFiClient client = server.available();

    if (client) {

    Serial.println("Client connected.");

    while (client.connected()) {

    if (client.available()) {

    char command = client.read();

    if (command == 'H') { //when the singnal from mobile app is high means servo return to 0 degree position

    myservo.write(0);

    Serial.println("door is now close."); //send message door close

    }

    else if (command == 'L') { //when the singnal from mobile app is low means servo return to 180 degree position

    myservo.write(180);

    Serial.println("door is now open."); //send message door open

    }

    }

    }

    Serial.println("Client disconnected.");
    client.stop();

    }

    }

    void printWiFiStatus() {
    Serial.println("");

    Serial.print("Connected to ");

    Serial.println(ssid);

    Serial.print("IP address: ");
    Serial.println(WiFi.localIP());

    }

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    Now upload the Program code to NodeMCU

    *Make sure to open the serial monitor with correct output "115200" so you could see the IP address your NodeMCU connected *

    Step 10: Setting Up Evothing Software

    Now open the Evothing Program on PC. In the main console of program, select Examples section. Search for "ESP8266" example file. Now go and Press Copy on ESP8266. This will create a new file tab. Name the new file and save it. The new file is now saved on My Apps console.

    Step 11: Setting Up Evothing Software (Establishing Smartphone to NodeMCU Connection)

    Now start up the mobile Evothings viewer app on your phone.

    On the Evothings application on computer select "Connect" headline and select "GET KEY". Enter the key displayed in Evothings application on your phone.

    Step 12:

    Go back to your EVOthings application on PC one more time and select my app headline. Select the Nodemcu program connection file you just created. Press" run " button.

    Your mobile phone will now display "Loading" logo and lead you to page where you can enter Nodemcu IP address.

    Step 13:

    Once done, they will ask for IP address of your nodeMCU. Look at the serial monitor on Arduino IDE to check the IP address of NodeMCU connected to AP(Access point). Enter the IP Address displayed. This will establish communication with Evothings and NodeMCU.

    *It is more convenient to provide NodeMCU with static IP Address using Access point. This prevent IP address changes cause by dynamic setting of AP*

    Step 14:

    If connected the LED button will be displayed on the mobile application. Now you are able to control the servo using your smartphone with just one button.

    You can now see the "open" and "close" are displayed in the Arduino IDE monitor when you press the button on the application.

    To adjust the appearance of the Evothings application software please go to this site for more detail.

    https://sites.google.com/view/smartclubhouseproject/side-projects/project-smart-door

    Step 15: This Is a Door Opening Holder Drawn in Sketchup. (Optional)

    This files contain the 3D model box to hold the servo and Nodemcu Circuits.

    Step 16: Reference

    Reference

    GitHub. (2017). esp8266/Arduino. [online] Available at: https://github.com/esp8266/Arduino/blob/master/li... [Accessed 25 April. 2017].

    GitHub. (2017). esp8266/Arduino. [online] Available at: https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WiFi/src/ESP8266WiFi.h [Accessed 25 April. 2017].

    GitHub. (2017). evothings/evothings-examples. [online] Available at: https://github.com/evothings/evothings-examples/tree/master/examples/esp8266 [Accessed 25 April. 2017].