Project tutorial

WIZnet S2E Deadbolts © GPL3+

Unlocking the deadbolt via Ethernet using WIZ750SR S2E, your WiFi network is now the key to your lock.

  • 3,002 views
  • 0 comments
  • 9 respects

Components and supplies

Apps and online services

About this project

S2E Unlock Demo

Keyless Entry and Smart Locks

The idea of smart locks has been out for a while, but at the end of the day, people still end up carrying either RFID or just use the lock itself. We pretty much carry our phone all the time now, and by the time we are at the door we are automatically connected to our own WiFi network. By using Serial to Ethernet (S2E), we can actually implement a true keyless experience, using our phone as the key and S2E to unlock the deadbolts.

Step 1: Connect the WIZ750SR

With developer edition, we first can power up the WIZ750SR through micro-usb port. when everything is connected, we should see green LED on for connected to the ethernet, blue LED on for EtherNet add on working and red led on for device being powered on as figure below.

After powering on we can download the configuration tool from https://github.com/Wiznet/WIZnet-S2E-Tool-GUI to check whether the device is working. Easiest way here is to go through IP allocation via DHCP, then go back to static to auto fill out the Network configuration

The USB to UART driver can be downloaded if you are using the usb port. The Micro usb port that powers up the board will be the CP210x USB to UART Bridge used for debugging.

https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers

We can use debug port to test out termite to test out the serial port, which can be downloaded from https://www.compuphase.com/software_termite.htm we should receive all the messages sending to COM port via debug usb

As for the ethernet side we used ioninja's tcp server listening http://ioninja.com/plugins/tcp-listener.html Once that's successful we can test out whether these are in Sync, this allows to communicate from Serial to Ethernet

Step 2: Install All the IDE

We first need to install all the drivers for WIZ750SR, in this case we only have Windows IDE available and they are being instructed through https://github.com/Ricky-Kwon/WIZ750SR_Boot/wiki/Develop-environment-for-windows

For the most part, we need the following in our IDE, and this guide specifically used 64 bit windows.

From Ricky-Kwon's installation guide it seems that GNU Arm Eclipse Plugin web might not work, you can easily download, unzip and set that up to install as Eclipse's plugin as image below. Successful install would ask you to restart Eclipse.

After wards, we can copy the project and change accordingly

git clone https://github.com/Ricky-Kwon/WIZ750SR_App.git

New firmware update can be seen from https://wizwiki.net/wiki/doku.php?id=products:wiz750sr:developers:start#building_a_wiz750sr_development_environment

Step 3: Getting Lock to Work with Arduino

The deadbolts usually require 12V, while normal Arduino would only output 5V max, so in order to get the lock to work we can tap into the power source by soldering two wires at the power source like image below. We will use red wire as 12V and black wire as ground.

After that, We can insert the knob at A0 and Relay at D6 and use following code to test out the lock

#define ROTARY_ANGLE_SENSOR A0
#define LED 3  //the Grove - LED is connected to PWM pin D3 of Arduino
#define ADC_REF 5 //reference voltage of ADC is 5v.If the Vcc switch on the seeeduino
                   //board switches to 3V3, the ADC_REF should be 3.3
#define GROVE_VCC 5 //VCC of the grove interface is normally 5v
#define FULL_ANGLE 300 //full value of the rotary angle is 300 degrees
const int relayPin =  6;      // the number of the Relay
int incomingByte = 0;   // for incoming serial data
void setup() {
 // initialize the LED pin as an output:
 pinMode(relayPin, OUTPUT);
 Serial.begin(9600);     // opens serial port, sets data rate to 9600 bps
 pinMode(ROTARY_ANGLE_SENSOR, INPUT);
 pinMode(LED,OUTPUT);   
}
void loop() {
   float voltage;
   int sensor_value = analogRead(ROTARY_ANGLE_SENSOR);
   voltage = (float)sensor_value*ADC_REF/1023;
   float degrees = (voltage*FULL_ANGLE)/GROVE_VCC;
   //Serial.println("The angle between the mark and the starting position:");
   //Serial.println(degrees);
   if(degrees < 100)
   {
     digitalWrite(relayPin, HIGH);
     Serial.println("on");
   }
   else
   {
     digitalWrite(relayPin, LOW);
     Serial.println("off");
   }
   delay(100);
}

If everything is successful, we can lock and unlock by using the knob through testing it should show up on the GIF below.

Step 4: Connect WIZ750SR to Arduino

Since we've gotten the lock to work, we are now ready to setup the WIZ750SR, we can connect the WIZ750SR to Arduino UNO with relay like the image below. Arduino UNO only have Serial port that's basically pin 0 and 1 for RX and TX

We can use following code to make sure the lock works via receiver. At this point we can also remove the rotary knob as it is no longer needed.

#include <SoftwareSerial.h>
const int relayPin =  6;      // the number of the Relay
SoftwareSerial mySerial(0, 1); // RX, TX
void setup() {
 // initialize the LED pin as an output:
 pinMode(relayPin, OUTPUT);
 Serial.begin(9600);     // opens serial port, sets data rate to 9600 bps
 while (!Serial) {
   ; // wait for serial port to connect. Needed for native USB port only
 }
 //S2E is using 115200 from previous steps
 mySerial.begin(115200);
}
void loop() {
 if (mySerial.available()) {
   if(mySerial.read() == 49)
   {
     digitalWrite(relayPin, HIGH);
     Serial.println("on");
     delay(5000);
     digitalWrite(relayPin, LOW);
     Serial.println("off");
   }
 }
 delay(100);
}

At this point if you enter "1" into tcp it should unlock the lock. We can also get rid of the knob at this point. the enter unit now looks like the photo below.

Step 5: Building Android App to Unlock

Now that we can already unlock the door using TCP, the next step is building an android app so that user no longer need to carry the keys around. Below are a very simple app that we've built to unlock the deadbolt. Now that WiFi network becomes your key to the house as you'd be able to unlock deadbolts using WIZ750SR.

The code for Android is following, and you can download the full from GitHub.

 package com.demo.s2elock;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import cheekiat.slideview.SlideView;
public class MainActivity extends AppCompatActivity {
   TcpClient mTcpClient;
   SlideView mSlideView;
   @Override
   protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_main);
       mSlideView = (SlideView) findViewById(R.id.slide_view);
       mSlideView.setOnFinishListener(new SlideView.OnFinishListener() {
           @Override
           public void onFinish() {
               //someting to do
               if(mTcpClient != null)
               {
                   mTcpClient.sendMessage("1");
                   mSlideView.reset();
               }
           }
       });
   }
   protected void onResume() {
       super.onResume();
       if(mTcpClient == null)
       {
           new ConnectTask().execute("");
       }
   }
   protected void onPause() {
       super.onPause();
       if (mTcpClient != null) {
           mTcpClient.stopClient();
           mTcpClient = null;
       }
   }
   public class ConnectTask extends AsyncTask<String, String, TcpClient> {
       @Override
       protected TcpClient doInBackground(String... message) {
           //we create a TCPClient object
           mTcpClient = new TcpClient(new TcpClient.OnMessageReceived() {
               @Override
               //here the messageReceived method is implemented
               public void messageReceived(String message) {
                   //this method calls the onProgressUpdate
                   //publishProgress(message);
               }
           });
           mTcpClient.run();
           return null;
       }
       @Override
       protected void onProgressUpdate(String... values) {
           super.onProgressUpdate(values);
           //response received from server
           Log.d("test", "response " + values[0]);
           //process server response here....
       }
   }
}

Code

Arduino S2E receiver codeArduino
Arduino S2E receiver code
#include <SoftwareSerial.h>
const int relayPin =  6;      // the number of the Relay
SoftwareSerial mySerial(0, 1); // RX, TX
void setup() {
 // initialize the LED pin as an output:
 pinMode(relayPin, OUTPUT);
 Serial.begin(9600);     // opens serial port, sets data rate to 9600 bps
 while (!Serial) {
   ; // wait for serial port to connect. Needed for native USB port only
 }
 //S2E is using 115200 from previous steps
 mySerial.begin(115200);
}
void loop() {
 if (mySerial.available()) {
   if(mySerial.read() == 49)
   {
     digitalWrite(relayPin, HIGH);
     Serial.println("on");
     delay(5000);
     digitalWrite(relayPin, LOW);
     Serial.println("off");
   }
 }
 delay(100);
}
S2E Deadbolt Repo
Entire repo for Android and Arduino code for S2E Deadbolt
Ricky Kwon's installation guide
Ricky Kwon's installation guide

Schematics

Arduino UNO to WIZ750SR
Arduino UNO to WIZ750SR
Screen shot 2018 07 05 at 2 32 18 am szkgbs36mt

Comments

Similar projects you might like

WIZnet S2E Light Control

Project tutorial by Team S2ELighting

  • 1,449 views
  • 0 comments
  • 7 respects

Robo Hazel using Arduino and WIZnet S2E

Project tutorial by Hamza Khalid

  • 460 views
  • 0 comments
  • 4 respects

Smart Plant IoT

Project tutorial by Shin Ae Hong and Peter Ma

  • 8,103 views
  • 3 comments
  • 30 respects

WIZnet Controlled Robotic Arm

Project tutorial by Md. Khairul Alam

  • 1,615 views
  • 0 comments
  • 11 respects

WIZnet Interior Sensor Board

Project tutorial by Jade Perreault

  • 551 views
  • 0 comments
  • 0 respects

Home Smart Home

Project tutorial by Syed Sanoor

  • 68,539 views
  • 10 comments
  • 193 respects
Add projectSign up / Login