DIY IoT Based Smart Key Finder Using ESP8266
DIY IoT Based Smart Key Finder Using ESP8266
Never Loose your keys again with this 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
(/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.
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.
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:
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);
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.
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 "
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);
}
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
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.
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);
void handleRoot() {
void handleBUZ() {
buzzing_state = !buzzing_state;
server.sendHeader("Location","/");
server.send(303);
void handleNotFound(){
void setup(void){
Serial.begin(115200);
delay(10);
pinMode(buz_pin, OUTPUT);
WiFi.begin(ssid, pass);
Video
Tags
Comments
Submitted by Charles Malloch (/users/charles-malloch) on Mon, 06/14/2021 - 22:13
Permalink (/comment/34083#comment-34083)
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
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
(https://bit.ly/3HVhrfO )
(https://bit.ly/3y0kZbZ )
(https://bit.ly/3y3waAy )
(https://bit.ly/3sULWfr )
(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 )
(https://bit.ly/3ynLtWq )
Ad removed. Details
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
PROJECT
555 Timer Circuits (/555-timer-circuits) Op-amp Circuits (/op-amp-circuits) Audio Circuits (/audio-
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)
https://circuitdigest.com/microcontroller-projects/diy-iot-based-key-chain-finder-using-esp8266 15/15