ESP8266 - Secure Your Belongings: Detect Theft and Send Email Alerts
This guide will teach you how to use an ESP8266 and a force sensor to keep your items safe. We will show you how to create a system that sends you an email alert if someone tries to steal your possessions. You will learn how to prepare the ESP8266, connect the force sensor, and set it up to send emails through Gmail. We will provide step-by-step instructions and explain how this system can be useful in real-life scenarios.
![ESP8266 NodeMCU Theft detection Email Notification](https://newbiely.com/images/cover/esp8266-theft-detection-email-notification.jpg)
Hardware Preparation
1 | × | ESP8266 NodeMCU | |
1 | × | Micro USB Cable | |
1 | × | Force Sensor | |
1 | × | 10 kΩ resistor | |
1 | × | Breadboard | |
1 | × | Jumper Wires | |
1 | × | (Optional) DC Power Jack | |
1 | × | (Optional) Screw Terminal Expansion Board for ESP8266 |
Or you can buy the following sensor kits:
1 | × | DIYables Sensor Kit (30 sensors/displays) | |
1 | × | DIYables Sensor Kit (18 sensors/displays) |
Overview of Force Sensor and Gmail
We provide clear guides on Force Sensors and Gmail. Each tutorial includes complete instructions on setting up the hardware, how it functions, and connecting wires to ESP8266, with coding steps. For further details, follow these links.
- ESP8266 - Force Sensor tutorial
- ESP8266 - Gmail tutorial
How the theft detection system work
When you put an item on the force sensor, it measures the weight. The ESP8266 device records this weight. If the item is taken away, the weight is different. The ESP8266 detects this different weight and sends you an email to let you know that your item has been moved.
Wiring Diagram between Force Sensor and ESP8266
![The wiring diagram between ESP8266 NodeMCU and Force Sensor](https://newbiely.com/images/tutorial/esp8266-force-sensor-wiring-diagram.jpg)
This image is created using Fritzing. Click to enlarge image
See more in ESP8266's pinout and how to supply power to the ESP8266 and other components.
ESP8266 Code
Detailed Instructions
To get started with ESP8266 on Arduino IDE, follow these steps:
- Check out the how to setup environment for ESP8266 on Arduino IDE tutorial if this is your first time using ESP8266.
- Connect your ESP8266 board to the force sensor as shown in the diagram.
- Connect the ESP8266 board to your computer using a USB cable.
- Place the items you want to secure on the force sensor.
- Open Arduino IDE on your computer.
- Choose the correct ESP8266 board, such as (e.g. NodeMCU 1.0 (ESP-12E Module)), and its respective COM port.
- Click on the Library Manager icon on the left side of the Arduino IDE to open the Library Manager.
- Search for ESP Mail Client and choose the library created by Mobizt.
- Click the Install button to install the ESP Mail Client library.
![ESP8266 NodeMCU ESP Mail Client library](https://newbiely.com/images/tutorial/esp8266-ESP-Mail-Client-library.jpg)
- Copy the code and open it in the Arduino IDE software.
- Enter your WiFi name and password in the code by changing WIFI_SSID and WIFI_PASSWORD.
- Enter the email and password of the sender in the code by changing SENDER_EMAIL and SENDER_PASSWORD.
- Replace the recipient's email in the code by changing RECIPIENT_EMAIL. The recipient's email may be the same as the sender's email.
※ NOTE THAT:
- The email address of the person sending the email should be from Gmail.
- The password for the sender should be the App password you got before.
- The email address of the person receiving the email can be from any email service.
- Press the Upload button in the Arduino IDE to transfer code to the ESP8266.
- Open the Serial Monitor.
- Take off your item from the force sensor.
- Check the results on the Serial Monitor.
- Check your email inbox. You will find an email like this:
![ESP8266 NodeMCU theft detection email](https://newbiely.com/images/tutorial/esp8266-theft-detection-email.jpg)