ESP32 - Secure Your Belongings: Detect Theft and Send Email Alerts
In this tutorial, we are going to learn how to secure your valuables by using an ESP32 and a force sensor to detect when someone takes your stuff. This detailed guide walks you through setting up a theft detection system that sends instant email notifications via Gmail. Our tutorial covers everything from configuring the ESP32, integrating the force sensor, and coding the email alert system. Discover the benefits, step-by-step instructions, and practical applications of using an ESP32 and force sensor for theft detection and email alerts.
Hardware Used In This Tutorial
Or you can buy the following sensor kits:
1 | × | DIYables Sensor Kit (30 sensors/displays) | |
1 | × | DIYables Sensor Kit (18 sensors/displays) |
Introduction to Force Sensor and Gmail
We have specific tutorials about Force Sensor and Gmail. Each tutorial contains detailed information and step-by-step instructions about hardware pinout, working principle, wiring connection to ESP32, ESP32 code... Learn more about them at the following links:
- ESP32 - Force Sensor tutorial
- ESP32 - Gmail tutorial
How the theft detection system work
The force sensor can measure how much something weighs when you put it on the sensor. When you place your item on the force sensor, the ESP32 reads and records this weight. If someone takes your item, the weight on the sensor will change. The ESP32 detects this change and sends you an email notification to let you know that your item has been moved.
Wiring Diagram between Force Sensor and ESP32
- How to connect ESP32 and force sensor using breadboard
This image is created using Fritzing. Click to enlarge image
- How to connect ESP32 and force sensor using screw terminal block breakout board (powered via USB cable)
If you're unfamiliar with how to supply power to the ESP32 and other components, you can find guidance in the following tutorial: How to Power ESP32.
ESP32 Code
Quick Instructions
- If this is the first time you use ESP32, see how to setup environment for ESP32 on Arduino IDE.
- Connect the ESP32 board to the force sensor
- Put your stuff cover the force sensor
- Connect the ESP32 board to your PC via a USB cable
- Open Arduino IDE on your PC.
- Select the right ESP32 board (e.g. ESP32 Dev Module) and COM port.
- Open the Library Manager by clicking on the Library Manager icon on the left navigation bar of Arduino IDE.
- Search ESP Mail Client, then find the ESP Mail Client created by Mobizt.
- Click Install button to install ESP Mail Client library.
- Copy the above code and open with Arduino IDE
- Change the WiFi information (SSID and password) in the code to yours by changing two contanst WIFI_SSID and WIFI_PASSWORD
- Change the sender email and password in the code to yours by changing two contanst SENDER_EMAIL and SENDER_PASSWORD
- Change the recipient email in the code to yours by changing two contanst RECIPIENT_EMAIL. recipient email can be the same as sender
※ NOTE THAT:
- Sender email MUST be Gmail
- Sender password is the App passwords you got from previous step
- Recipient email can be any type of email
- Click Upload button on Arduino IDE to upload code to ESP32
- Open the Serial Monitor
- Take your stuff out of the force sensor
- Check out the result on Serial Monitor.
- Check your recipient email box. You will get an email as below:
Video Tutorial
Making video is a time-consuming work. If the video tutorial is necessary for your learning, please let us know by subscribing to our YouTube channel , If the demand for video is high, we will make the video tutorial.