Arun Suthar
Published

IR remote password locker

It is a basic locker open and close with solenoid and servo. For open the locker you want a password of 4 digit and enter on IR remote.

IntermediateWork in progress1 hour698
IR remote password locker

Things used in this project

Hardware components

SG90 Micro-servo motor
SG90 Micro-servo motor
×1
IR receiver (generic)
×1
Li-Ion Battery 1000mAh
Li-Ion Battery 1000mAh
×1
Wemos D1 Mini
Espressif Wemos D1 Mini
×1

Software apps and online services

Arduino IDE
Arduino IDE
MIT App Inventor 2
MIT App Inventor 2
opyion is kodular app invertor

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Bantam Tools Desktop PCB Milling Machine
Bantam Tools Desktop PCB Milling Machine

Story

Read more

Custom parts and enclosures

smart_safe_scmetic

smart_safe_borad

Schematics

Ir

kodular app

Code

smart safe

Arduino
#include <ESP8266WiFi.h>
#include <Servo.h>
Servo myservo;

const char* ssid = "edmi 4";//type your ssid
const char* password = "12345678";//type your password

int relayPin = 2; // GPIO2 of ESP8266
WiFiServer ESPserver(80);//Service Port

void setup()
{
  Serial.begin(115200);
  pinMode(relayPin, OUTPUT);
  digitalWrite(relayPin, HIGH);
  myservo.attach(D4);

  Serial.println();
  Serial.println();
  Serial.print("Connecting to: ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);
  delay(5000);

  /*
    The following four line of the
    code will assign a Static IP Address to
    the ESP Module. If you do not want this,
    comment out the following four lines.
  */

  IPAddress ip(192, 168, 1, 254);
  IPAddress gateway(192, 168, 1, 1);
  IPAddress subnet(255, 255, 255, 0);
  WiFi.config(ip, gateway, subnet);
  delay(5000);

  while (WiFi.status() != WL_CONNECTED)
  {
    delay(100);
    Serial.print("*");
  }
  Serial.println("");
  Serial.println("WiFi connected");

  // Start the server
  ESPserver.begin();
  Serial.println("Server started");

  // Print the IP address
  Serial.print("The URL to control ESP8266: ");
  Serial.print("http://");
  Serial.print(WiFi.localIP());
}
int pos = 0;

int close() {
  for (pos = 0; pos <= 125; pos += 1) {
    myservo.write(pos);
    delay(10);
  }
}

int open() {
  for (pos = 125; pos >= 0; pos -= 1) {
    myservo.write(pos);
    delay(10);
  }
}


void loop()
{
  // Check if a client has connected
  WiFiClient client = ESPserver.available();
  if (!client)
  {
    return;
  }

  // Wait until the client sends some data
  Serial.println("New Client");
  while (!client.available())
  {
    delay(1);
  }

  // Read the first line of the request
  String request = client.readStringUntil('\r');
  Serial.println(request);
  client.flush();

  // Match the request

  int value = LOW;
  if (request.indexOf("/open") != -1)
  {
    Serial.println("safe is on");
    open();
    value = LOW;
  }
  if (request.indexOf("/close") != -1)
  {
    Serial.println("safe open ");
    close();
    value = HIGH;
  }

  // Return the response
  client.println("HTTP/1.1 200 OK");
  client.println("Content-Type: text/html");
  client.println(""); //  IMPORTANT
  client.println("<!DOCTYPE HTML>");
  client.println("<html>");

  client.print("Status of the Lamp: ");

  if (value == LOW)
  {
    client.print("ON");
  }
  else
  {
    client.print("OFF");
  }

  delay(1);
  //client.stop();
  Serial.println("Client disconnected");
  Serial.println("");
}

Credits

Arun Suthar
4 projects • 2 followers
EC engineer Hardware lover

Comments