Introduction: Control Access to Your LOCK Remotely Using Arduino, SensorMonkey and RF Module

Picture of Control Access to Your LOCK Remotely Using Arduino, SensorMonkey and RF Module

Control access to your Door from anywhere on the planet using your Phone, Tab or PC.

This Setup has two main segments, One has the GUI using jQuery, SensorMonkey, Freeduino(Arduino compatible development Board) and a Transmitter.
The other segment has the Receiver and the circuit to send the required signal to the Lock ( Electric Strike) for locking and unlocking.

I learnt the initial setup of jQuery, SensorMonkey and Bloom from the tutorial that has been explained here - https://www.instructables.com/id/Remote-controlled-webcam-using-Arduino-SensorMonk/
This whole project was inspired from the project detailed by the user amccoy6.

Step 1: Materials Required

Hardware:
Freeduino with ATMEGA128 (Cheaper version of Arduino)
HT12E - 4bit Encoder
HT12D – 4bit Decoder
Resistors – 750K, 33k, 180ohm (2)
RF Trasmitter and receiver (433Mhz)
LEDs (2)
TIP 122 transistor
Diode 1N4148
Electric strike
Heat Sink for TIP122
9v battery (1)
Power supply (12 Vdc, 1A) – This drives the Electric strike
Prototype boards
Connecting wires

Software:
Arduino IDE
SensorMonkey free account
Bloom
Jquery UI

Step 2: Setup Arduino/Freeduino and Bloom

Connect Freeduino to the System using USB and note the serial port it would be using. Here I am using port COM20 for communicating with Freeduino. Open the IDE for developing the code for freeduino to read serial data from Bloom and write the Output to one of the Analog pin A0.

Code:
/*
  Analog input, analog output, serial output

*/
const int LockOutSignalPin = A0; // Analog output pin
int outputValue = 0;        // value output to the PWM (analog out)

void setup() {
  // initialize serial communications at 9600 bps:
  Serial.begin(9600);
}

void loop() {
 
  if( Serial.available() ) {
    byte b = Serial.read();
     
  // read the analog in value:
  //sensorValue = analogRead(analogInPin);           
  // map it to the range of the analog out:
 
  outputValue = map(b, 0, 15, 0, 255); 
 
  // change the analog out value:
  analogWrite(LockOutSignalPin, outputValue);          

  delay(15);                    
  }
}

Upload this to the Arduino from the IDE.

Next, Install Bloom. I have used the following settings:
Below settings are used here:

    TCP/IP port: 8000
    Polling frequency: 50
    Serial port: COM20
    Baud rate: 9600
    Data bits: 8
    Parity bit: None
    Stop bits: 1
    Flow control: None

Now this is ready to listen to the inputs from SensorMonkey on port 8000.

Step 3: Setup JQuery and SensorMonkey

Picture of Setup JQuery and SensorMonkey


Since I am not a JavaScript developer, I made use of the code from this link.
https://www.instructables.com/id/Remote-controlled-webcam-using-Arduino-SensorMonk/

I modified the code to fulfill the basic need here to allow the user to select between the options - LOCK and UNLOCK.
It has a slider which when slid to the right UNLOCKs the Electric strike and to the left it LOCKs it.

This is the final code:

<!DOCTYPE html>
<html>
<head>
    <title>Remote controlled Electric Strike using Arduino, SensorMonkey, jQuery </title>
    <link rel="stylesheet" type="text/css" href="jquery-ui-1.10.4.custom.css" />
    <style type="text/css">
       
       
        #pan-slider {
            margin-bottom: 10px;
            width: 320px;
        }
        #pan-display {
            text-align: center;
            width: 320px;
        }
        .rotation {
            color: #F6931F;
            font-weight: bold;
        }
    </style>
    <script type="text/javascript" src="jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="jquery-ui-1.10.4.custom.min.js"></script>
    <script type="text/javascript" src="https://sensormonkey.eeng.nuim.ie/socket.io/socket.io.js"></script>
    <script type="text/javascript" src="https://sensormonkey.eeng.nuim.ie/js/client.min.js"></script>
</head>
<body>
   
        <h1>Remote Home security system</h1>
   
    <div id="pan-slider"></div>
    <div id="pan-display">Slide Right to UNLOCK and Left to LOCK <span class="rotation"></span></div>
    <script type="text/javascript">
        // Converts an integer (or a string representation of one) to a hexadecimal character (0-9A-F).
        function toHex( i ) {
            return parseInt( i ).toString( 16 ).toUpperCase();
        }
      
        $( function() {
           
            // Create pan slider.
            $( "#pan-slider" ).slider( {
                range : "min",
                value : 0,
                min : 0,
                max : 15,
                step : 15,
                slide : function( event, ui ) {
                    // Update UI.
                    $( "#pan-display .rotation" ).html( 180 * ui.value / 15 );
                  
                    // Calculate combined pan/tilt rotation angles and send to the stream publisher
                    // as a hexadecimal character pair. Pan is high 4 bits; tilt is low 4 bits. By
                    // prefixing with '#', we tell SensorMonkey to interpret as binary data.
                    var pan = toHex( ui.value );
                   
                    client.deliverToStreamPublisher( "/private/Homelock", "#" + pan + pan );


                }
    } );



         

            // 1. Connect to SensorMonkey
            // 2. Join namespace
            // 3. Subscribe to stream
          
            var client = new SensorMonkey.Client( "https://sensormonkey.eeng.nuim.ie" );
            client.on( "connect", function() {
                client.joinNamespace( "Your_Namespace", "Your_private_key", function( e ) {
                    if( e ) {
                        alert( "Failed to join namespace: " + e );
                        return;
                    }
                  
                    client.subscribeToStream( "/private/Sensor_name", function( e ) {        //Sensor_name to be given in SensorMonkey when you create a sensor there
                        if( e ) {
                           alert( "Failed to subscribe to stream: " + e );
                            return;
                        }
                    } );
                } );
              
                client.on( "disconnect", function() {
                    alert( "Client has been disconnected!" );
                } );
            } );
        } );
    </script>
</body>
</html>


I would again suggest to check on the STEP 6 of https://www.instructables.com/id/Remote-controlled-webcam-using-Arduino-SensorMonk/ in order to get a better insight into jQuery code and information regarding jQuery libraries, CSS and image files and html files.

Once the jQuery UI is setup, get a free account on SensorMonkey and create a Sensor called "Homelock". You can give it any name but make sure the same is used in the html code.

client.subscribeToStream( "/private/Sensor_name", function( e ) {        //Sensor_name to be given in SensorMonkey when you create a sensor there

I use the port - 8000 for the sensor.

In this setup I am using a single PC to serve as the system that runs SensorMonkey, Bloom and also connected to Freeduino.
So the IP would remain as 127.0.0.1 for the Sensor.

Step 4: Build the Transmitter Circuit

Picture of Build the Transmitter Circuit

The Transmitter used here is the RF Transmitter 433 Mhz (ASK) which is widely available online.
Signal to the transmitter is given by a 4-bit encoder - HT12E which is connected to the Freeduino's analog signal output pin, A0.

The circuit as shown.
The power to this transmitter circuit is provided by the 5v constant output from the Freeduino.

Step 5: The Receiver and the Lock Circuit

Picture of The Receiver and the Lock Circuit

The receiver side consists of the RF receiver 433 MHz and the decoder HT12D. It is driven by a 9v DC battery.
The signal from the Decoder is the switching signal for the Lock. If the signal at pin18 of decoder is high the Electric strike is Unlocked and if low its Locked.

Electric strike details:
Fail secure
Voltage - 12Vdc
Current - 850ma

I am using an adaptor to convert 230V ac to 12V dc, 1A .

The Circuit is as shown. The signal from decoder goes to the Base of TIP122 transistor, the high input is from Adaptor is connected to the Collector, Negative of adaptor is connected to the ground of the decoder. The emitter is connected to one pin of Electric strike and the other again hits the common ground.
Information about TIP122 can be found here - http://www.alldatasheet.com/datasheet-pdf/pdf/2770/MOSPEC/TIP122.html

Two LEDs have been used here. The yellow one is connected to the pin2 on the right side. It switches ON when a connection is established with the transmitter. The green LED denotes glows when the Lock is OPEN. Its connected between the emitter pin of TIP122 and ground. (with a resistor in-between)

So the idea is whenever there is a signal given to the Base, the transistor opens up and allows the Current to flow to the emitter which in turn supplies power to the electric strike and Unlocks it.

This completes the whole setup.

Step 6: Running the Whole Setup

On the jquery code, make sure YOUR_NAMESPACE", "YOUR_PRIVATE_KEY" and the "sensor's_name" are correctly setup.
Upload the Arduino code, Configure Bloom with the serial port and TCP port and click on start.

Open SensorMonkey, Goto sensors tab, Launch SensorMonkey control panel.
Create the Sensor (note the sensor_name here) and add it. Configure the port to 8000. Click on connect button below.
Click on stream tab, select the unsigned 8-bit variable and click on Publish. Now both the connected button and streaming button should have a green tick for your sensor.
Click on Control tab, Under the "history of the commands and data sent to sensor" there is a Box. Keep a watch on that, the data from the jQuery gets published there.

Open the html file on a browser from your Phone/Tab/PC etc. Slide the control to right to unlock the sensor and left to Lock it.
The "Command history box" on sensor monkey should have an "FF" for unlocking and "00" for locking.

This setup can be improved in many possible ways. It can be made to control multiple Electric Strikes quite easily.

The whole setup cost is around Rs.2500 ( Thats around $50).


Comments

akhil.panmana (author)2014-07-29

suprb.

ankappa (author)akhil.panmana2014-09-15

Thanks!!

rgehan (author)2014-03-12

You made a mistake, you're not actually using Java, but JavaScript.

However, it´s still a good project :)

ankappa (author)rgehan2014-03-12

I actually have no idea about java, javascript, html, jquery etc. Did a lot of trial and error to modify the code. Now I know a little bit of how it all connects, but yes I have corrected my statement to javascript. So much to learn, Thanks for letting me know.

akinich (author)2014-03-12

where did you get the electronic lock from?

ankappa (author)akinich2014-03-12

I got it from ebay.in

http://www.ebay.in/itm/Heavy-Duty-Stainless-Steel-...

Should be available on ebay at your location. Its called the "Electric Strike".

About This Instructable

8,287views

51favorites

License:

More by ankappa:Home Plant-watering system Control access to your LOCK remotely using Arduino, SensorMonkey and RF module
Add instructable to: