[go: up one dir, main page]

0% found this document useful (0 votes)
75 views15 pages

DIY IoT Based Smart Key Finder Using ESP8266

Uploaded by

Sai Pranav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
75 views15 pages

DIY IoT Based Smart Key Finder Using ESP8266

Uploaded by

Sai Pranav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

7/9/22, 8:14 PM DIY IoT Based Smart Key Finder using ESP8266

Never Loose your keys again with this IoT Based Smart Key Finder

Published June 10, 2021 2

Ashish Choudhary (/users/ashish-choudhary)


A
Author

IoT Based Smart Key Finder

Agree it!!! It has happened to all of us. Many times we misplace our keys and go searching for them everywhere in the house,
and after a long search, we end up finding them with much distress. Now, the obvious solution here is to place your keys in
their right place, but as engineers, what’s the fun in doing that. So, in this tutorial, we are going to build a simple IoT-based
Smart Key Chain just using ESP8266-01, Buzzer, and Battery. Now in case if you can’t find your keys and you remember that
you have attached an IoT keychain to your keys, so you take out your phone and open Chrome and open your Keychain
Webpage. Then you click on the toggle button, and in moments, you hear a beep sound coming from your keychain and with
this, you can easily track your keys.

As you can see from the image, we have built this circuit on PCB and we have used PCBONLINE (https://www.pcbonline.com/)
to fabricate the PCB boards for this project. PCBONLINE is a PCB manufacturing and assembly service provider who has
been in the industry since 1999. They can handle advanced PCBs with upto 24 layers adhering to ISO standards. The

https://circuitdigest.com/microcontroller-projects/diy-iot-based-key-chain-finder-using-esp8266 1/15
7/9/22, 8:14 PM DIY IoT Based Smart Key Finder using ESP8266

best part is that we can get high-quality industrial standard PCBs even for low volume orders and can also use their free PCB
assembly and functional test services when ordering in bulk. We will explain more on how to use pcbonline later in this article ,
but for now, lets discuss about the design and working of our IoT based Key chain.

Components Required
ESP8266-01
AMS1117 3.3V Voltage Regulator
Buzzer
Lithium Polymer battery
2× 10µf Capacitor

Smart key Finder Circuit Diagram


The complete circuit diagram for the Esp8266 smart key chain is shown below. The schematic was drawn using EasyEDA.

(/fullimage?i=circuitdiagram_mic/Smart-key-Finder-Circuit-Diagram.png)

This complete setup will be powered by the Lithium polymer Battery and AMS117-3.3V is used to regulate 3.3V for the
ESP8266-01 board. VCC and CH_PD pins of ESP8266-01 are connected to the output pin of AMS1117 while we connect the
GND pin to the –ve rail of the battery. The positive terminal of Buzzer is connected to the GPIO2 pin of ESP8266 while the
negative terminal of the buzzer is connected to the GND of ESP8266-01. Ok, so we are done with the connections. Now let’s
have a look at the PCB Design.

Fabricating our Smart KeyChain using PCB Online


Now that we understand how the schematic works, we can proceed with building the PCB for our project. You can design the
PCB using any PCB software of your choice. If you are a beginner who is just getting started in the world of PCB, we would
recommend to try getting started with eagle for PCB Designing (https://pcbdesignworld.com/article/eagle-pcb-design-
software-getting-started). If you want to skip the design processes, you can also download the Gerber file of this smart key
finder project using the below link.

Gerber File Link (https://circuitdigest.com/sites/default/files/ESP8266%20Key-Chain_Gerber_File.zip)

https://circuitdigest.com/microcontroller-projects/diy-iot-based-key-chain-finder-using-esp8266 2/15
7/9/22, 8:14 PM DIY IoT Based Smart Key Finder using ESP8266

You can also check out our other PCB projects (https://circuitdigest.com/diy-pcb-projects) that we have previously built on
circuit digest if you are interested. Now that our Design is ready, it is time to get them fabricated using the Gerber file. Getting
your PCB fabricated from PCBONLINE (https://www.pcbonline.com/) is easy; simply follow the steps given below.

Go to https://www.pcbonline.com/ (https://www.pcbonline.com/) sign up if this is your first time. Then, go to the Active
Orders tab and then click on ‘Quote Online’.

Now in the next window, enter the Gerber file, dimensions of your PCB, the number of layers, and the number of PCB you
require.

https://circuitdigest.com/microcontroller-projects/diy-iot-based-key-chain-finder-using-esp8266 3/15
7/9/22, 8:14 PM DIY IoT Based Smart Key Finder using ESP8266

After entering the Gerber file, you can set a few additional parameters if required, like the material used track spacing, etc. but
usually, the default values work fine. In the next step, you have to select the Build time, Shipping country.

The final step is Checkout. To make sure the process is smooth; PCBONLINE first verifies all the details and Gerber file before
proceeding with the payment. This way, you can be sure that your PCB is fabrication-friendly and will reach you as committed.

https://circuitdigest.com/microcontroller-projects/diy-iot-based-key-chain-finder-using-esp8266 4/15
7/9/22, 8:14 PM DIY IoT Based Smart Key Finder using ESP8266

You can check your order status from the ‘Active Orders’ tab.

Assembling the Smart KeyChain Board


After a few days, we received our PCB from PCBONLINE in a neat package and as you can see below, the PCB quality was
good as always. The top layer and bottom layer were seamlessly done with proper visa and track spacing. The top layer and
the bottom layer of the board are shown below.

https://circuitdigest.com/microcontroller-projects/diy-iot-based-key-chain-finder-using-esp8266 5/15
7/9/22, 8:14 PM DIY IoT Based Smart Key Finder using ESP8266

After making sure that the tracks and footprints were correct, I proceeded with assembling the PCB. The completely soldered
board looked like as shown in the image below:

Smart Key Chain Code Explanation


Complete code for IoT-based Smart Keychain can be found at the end of the page. Here we are explaining the complete code
line by line.

So as usual, let's start the code by importing all the required libraries. All the libraries that we are going to use in this code
come pre-installed with ESP8266 board files. ESP8266WiFi library is used to connect NodeMCU to a Wi-Fi network.

https://circuitdigest.com/microcontroller-projects/diy-iot-based-key-chain-finder-using-esp8266 6/15
7/9/22, 8:14 PM DIY IoT Based Smart Key Finder using ESP8266

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>

Then create a webserver object that listens for HTTP request on port 80

ESP8266WebServer server(80);

Define the ESP8266 pin where Buzzer is connected

const int buz_pin = 2;

In the next stage, enter Wi-Fi credentials like the user name and password for the Wi-Fi router to which your NodeMCU
should connect with.

char ssid[] = "Wi-Fi Name";


char pass[] = "Wi-Fi Password";

The string variable ‘html_code’ contains a simple HTML code for creating a NodeMCU webpage.

String html_code =
"<!DOCTYPE html><html><head><style>.button {border: none;padding: 12px 40px;text-align: center;text-decoration: none;display: in

The handleRoot() function is executed when we open the Webpage in the browser using the NodeMCU IP address. It sends
the current buzzer state and a web page with a toggle button to webserver.

void handleRoot() {
server.send(200, "text/html", html_code + "Current state: <b>" + buzzing_state);
}

handleBUZ() is used to change the buzzer state if the button is pressed on the webpage. It adds a header to respond with a
new location for the browser to go to the home page again.

void handleBUZ() {
buzzing_state = !buzzing_state;
server.sendHeader("Location","/");
server.send(303);
}

Inside the setup() function, we initialized the baud rate, defined the buzzer pin as an output, and then connect the module with
the Wi-Fi using the Wi-Fi name and password.

Serial.begin(115200);
delay(10);
pinMode(buz_pin, OUTPUT);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
}
Serial.println("OK!");

The first function is used to call the 'handleRoot' function when a client requests URI (Uniform Resource Identifier) "/" while
the second function is used to call the ' handleBUZ ' function when a POST request is made to URI "/ handleBUZ "

server.on("/", HTTP_GET, handleRoot);


server.on("/BUZ", HTTP_POST, handleBUZ);

https://circuitdigest.com/microcontroller-projects/diy-iot-based-key-chain-finder-using-esp8266 7/15
7/9/22, 8:14 PM DIY IoT Based Smart Key Finder using ESP8266

Now in the next stage, we will read the buzzer state from the webpage and then change the GPIO pin state to turn on/off the
buzzer.

void loop(void){
server.handleClient();
if (buzzing_state == true) {
digitalWrite(buz_pin, HIGH);
delay(400);
yield();
digitalWrite(buz_pin, LOW);
}

Programming ESP8266-01 for Smart Key Chain


Instead of using the FTDI board here, I am using Arduino Uno to program the ESP8266-01. The circuit diagram for
programming ESP8266-01 using Arduino is given below:

Connections for programming ESP8266 are as follows:

ESP8266-01 Arduino Uno

VCC 3.3V

GND GND

CH-PD 3.3V

RX RX

TX TX

https://circuitdigest.com/microcontroller-projects/diy-iot-based-key-chain-finder-using-esp8266 8/15
7/9/22, 8:14 PM DIY IoT Based Smart Key Finder using ESP8266

GPIO-0 GND

GPIO-2 Not Connected

Initially Not Connected. Before


hitting upload connect RST to
RST
ground and remove after half a
second

Apart from these connections, connect the Reset pin of Arduino to GND to bypass the Arduino. It will disable Arduino and
upload code directly to the ESP8266 board. Now power up the Arduino Uno and open the Arduino IDE. Select the “Generic
ESP8266 Module” in Board. Now before clicking on Upload, we have to boot ESP-01 into programming mode. Ground the RST
pin for a second. Now click on Upload in your Arduino IDE.

Testing our Smart Key Chain Finder


Now that we have assembled the PCB and uploaded the code on ESP8266-01, we are ready to test the keychain. For that
power, the setup and wait until ESP connects to Wi-Fi, then get the ESP IP address. Now open your favorite browser and type
in the IP address and search. It should open a page as shown below:

https://circuitdigest.com/microcontroller-projects/diy-iot-based-key-chain-finder-using-esp8266 9/15
7/9/22, 8:14 PM DIY IoT Based Smart Key Finder using ESP8266

Click on ‘Click Me’ and the Buzzer we will make a sound until you click on the button again. The current state of the buzzer is
shown below the toggle button. The complete working video and code for this project are given below. I hope you enjoyed
building this project. If you have any questions, please leave them in the comment section.

Code

https://circuitdigest.com/microcontroller-projects/diy-iot-based-key-chain-finder-using-esp8266 10/15
7/9/22, 8:14 PM DIY IoT Based Smart Key Finder using ESP8266

#include <ESP8266WiFi.h>

#include <WiFiClient.h>
#include <ESP8266WebServer.h>

ESP8266WebServer server(80);

const int buz_pin = D2;


char ssid[] = "Galaxy-M20";

char pass[] = "ac312124";

String html_code = "<!DOCTYPE html><html><head><style>.button {border: none;padding: 12px 40px;text-align: center;text-decorat


boolean buzzing_state = false;

void handleRoot() {

server.send(200, "text/html", html_code + "Current state: <b>" + buzzing_state);

void handleBUZ() {
buzzing_state = !buzzing_state;

server.sendHeader("Location","/");

server.send(303);

void handleNotFound(){

server.send(404, "text/plain", "404: Not found");

void setup(void){

Serial.begin(115200);

delay(10);

pinMode(buz_pin, OUTPUT);

Serial.print("\n\nConnecting Wifi... ");

WiFi.begin(ssid, pass);

Video

DIY IoT Based Smart Keychain Finder using ESP8266

Tags

IoT (/tags/iot) ESP8266 (/tags/esp8266) PCB (/tags/pcb)

Comments
Submitted by Charles Malloch (/users/charles-malloch) on Mon, 06/14/2021 - 22:13

Permalink (/comment/34083#comment-34083)

I would have thought that the (/comment/34083#comment-34083)


I would have thought that the ESP8266, especially when constantly connected to WiFi, would take a lot of power, and would
run down a coin cell quickly. I'd love to hear that I was wrong!
How much battery life do you get with this setup?

Submitted by Visvesh kumar (/users/visveshyallamelli89787) on Sat, 01/22/2022 - 10:33

Permalink (/comment/34844#comment-34844)

https://circuitdigest.com/microcontroller-projects/diy-iot-based-key-chain-finder-using-esp8266 11/15
7/9/22, 8:14 PM DIY IoT Based Smart Key Finder using ESP8266

can you upload BOM and CPL (/comment/34844#comment-34844)


can you upload BOM and CPL files along with the Gerber file, please?

Log in (/user/login?destination=/microcontroller-projects/diy-iot-based-key-chain-finder-using-esp8266%23comment-form)
or register (/user/register?destination=/microcontroller-projects/diy-iot-based-key-chain-finder-using-
esp8266%23comment-form) to post comments

Type 04 Enclosures (https://bit.ly/3HVhrfO )


With 15 different sizes, aluform enclosures provide customers a wide range of potential uses

(https://bit.ly/3HVhrfO )

AMF Series 18/24/36 W Medical AC-DC Adaptors (https://bit.ly/3y0kZbZ )


IP22 rated medical & home-healthcare 18/24/36W AC-DC adaptors with interchangeable AC plugs.

(https://bit.ly/3y0kZbZ )

1590Z Series Enclosures (https://bit.ly/3y3waAy )


Hammond's rugged enclosures available in twenty sizes, three colors, and with accessory inner panels

(https://bit.ly/3y3waAy )

Predictive Maintenance (https://bit.ly/3sULWfr )


Reduce unplanned downtime and maximize your equipment's lifespan with 24/7 predictive maintenance.

(https://bit.ly/3sULWfr )

Enabling IoT Applications (https://bit.ly/3sV6xQZ )


Solutions for 5G, smart home, industrial, automotive, healthcare, and agricultural IoT applications

(https://bit.ly/3sV6xQZ )

https://circuitdigest.com/microcontroller-projects/diy-iot-based-key-chain-finder-using-esp8266 12/15
7/9/22, 8:14 PM DIY IoT Based Smart Key Finder using ESP8266

TPP 180 and TPI 180 Medical and Industrial AC/DC Power Supplies (https://bit.ly/3nsbddG )
TRACO Power's 180 W power supplies are offered in ultra-compact open-frame and enclosed packages

(https://bit.ly/3nsbddG )

NTS/NTU Series Reliable, Safe, and Durable DC-AC Pure Sine Wave Inverters
(https://bit.ly/3yqmEJm )
MEAN WELL's sine wave inverters offer industrial-grade high reliability, safety, and quality

(https://bit.ly/3yqmEJm )

IsoMOV™ Series Hybrid Protection Component (https://bit.ly/3ynLtWq )


Bourns' hybrid protection component combines both MOV and GDT technologies into a single component

(https://bit.ly/3ynLtWq )

Ad removed. Details

Join 100K+ Subscribers


Your email is safe with us, we don’t spam.
https://circuitdigest.com/microcontroller-projects/diy-iot-based-key-chain-finder-using-esp8266 13/15
7/9/22, 8:14 PM DIY IoT Based Smart Key Finder using ESP8266

Type your email address Subscribe

Be a part of our ever growing community.

Semicon Media is a unique collection of online media, focused purely on the Electronics Community across the
globe. With a perfectly blended team of Engineers and Journalists, we demystify electronics and its related
technologies by providing high value content to our readers.

(https://www.facebook.com/circuitdigest/) (https://twitter.com/CircuitDigest)
(https://www.youtube.com/channel/UCy3CUAIYgZdAOG9k3IPdLmw) (https://www.linkedin.com/company/circuit-
digest/)

COMPANY

Privacy Policy (/privacy-policy) Cookie Policy (/cookie-policy) Terms of Use (/terms-of-use) Contact

Us (/contact) Advertise (/advertise)

PROJECT

555 Timer Circuits (/555-timer-circuits) Op-amp Circuits (/op-amp-circuits) Audio Circuits (/audio-

circuits) Power Supply Circuits (/smps-power-supply-circuits) Arduino Projects (/arduino-projects)

Raspberry Pi Projects (/simple-raspberry-pi-projects-for-beginners) MSP430 Projects (/msp430-

projects) STM32 Projects (/stm32-projects-and-tutorials) ESP8266 Projects (/esp8266-projects)

PIC Projects (/pic-microcontroller-projects) AVR Projects (/avr-microcontroller-projects) 8051 Projects

(/8051-microcontroller-projects) ESP32 Projects (/esp32-projects) IoT Projects (/internet-of-things-

iot-projects) PCB Projects (/diy-pcb-projects) Arduino ESP8266 Projects (/arduino-esp8266-

projects) All Microcontroller Projects (/microcontroller-projects)

OUR NETWORK

https://circuitdigest.com/microcontroller-projects/diy-iot-based-key-chain-finder-using-esp8266 14/15
7/9/22, 8:14 PM DIY IoT Based Smart Key Finder using ESP8266

(https://circuitdigest.com)

(https://components101.com)

(https://iotdesignpro.com)

Copyright © 2022 Circuit Digest (/). All rights reserved.

https://circuitdigest.com/microcontroller-projects/diy-iot-based-key-chain-finder-using-esp8266 15/15

You might also like