Build a Wi-Fi SMS Alert System with XIAO ESP32 & Sensor

Learn how to create a real-time Send SMS Alert using Seeed Studio XIAO ESP32, an ultrasonic sensor, and a free cloud API — no GSM module needed!
📲 Intro: Real-Time SMS Alerts with IoT Magic
Have you ever wanted your IoT device to send text alerts instantly without relying on bulky GSM hardware? This project shows how to build a compact SMS alert system using the ultra-small Seeed Studio XIAO ESP32-S3 development board and a simple ultrasonic sensor. The project uses Wi-Fi and a free cloud API to deliver SMS messages, making it perfect for home monitoring, security alerts, or remote systems automation. This setup is beginner-friendly and doesn’t require a GSM shield or SIM card — just Wi-Fi and a bit of Arduino code.
🔧 What You’ll Build
You’ll create a system that:
Continuously measures distance using an HC-SR04 ultrasonic sensor.
Detects motion or proximity within a set threshold.
Sends an SMS notification over Wi-Fi using a cloud API when motion is detected.
Shows real-time status via the Serial Monitor.
🔄 How It Works: System Workflow
Boot & Wi-Fi Setup — The XIAO ESP32 connects to your Wi-Fi network.
Distance Monitoring — The HC-SR04 continuously measures proximity.
Threshold Detection — When an object moves closer than your threshold (e.g., 100 cm), the system flags motion.
SMS Trigger — The ESP32 makes an HTTP POST request to the cloud API with alert details.
SMS Delivery — The cloud API formats & sends your text message to your phone.
💡 All communication happens over Wi-Fi — no GSM module or SIM card required!
🧠 Why Use Seeed XIAO ESP32-S3?
The Seeed XIAO ESP32-S3 stands out because it’s:
Extremely compact, ideal for tight spaces.
Wi-Fi & Bluetooth capable, ready for IoT projects.
Arduino IDE compatible, so it’s perfect for beginners.
Cost-effective compared to larger ESP32 boards.
💻 Core Arduino Logic
🛠 Libraries & Setup
Start with including Wi-Fi support:
#include <WiFi.h>
Define sensor pins and Wi-Fi credentials:
#define TRIG_PIN 5
#define ECHO_PIN 3
const char* ssid = "yourWifiSSID";
const char* password = "yourWifiPass";
☁️ SMS API Configuration
Your API key, mobile number, and optional message variables go here:
const char* apiKey = "YOUR_API_KEY";
const char* templateID = "103";
const char* mobileNumber = "91xxxxxxxxxx";
📡 Sending the SMS
Once motion is detected, the ESP32 connects to the SMS API and sends a JSON payload containing your message.
🔄 Main Loop
In loop(), you continuously measure distance and trigger sendSMS() when the threshold is crossed:
float dist = readDistance();
if (dist < 100 && !alertSent) {
sendSMS();
alertSent = true;
}
This ensures SMS is only sent once per motion event.
✔️ Testing & Expected Results
After uploading your code and opening the Serial Monitor:
You should see Wi-Fi connection updates.
Distance readings update continuously.
When motion is detected, you’ll see SMS sent logs.
If SMS doesn’t arrive, double-check your network credentials and API key.
🌍 Real-World Use Cases
This SMS alert system is perfect for:
Home security alerts
Parking space monitoring
Industrial safety notifications
Tank level alerts
Livestock & farm monitoring
Asset theft prevention
🚀 Wrap-Up
With just a tiny Seeed XIAO ESP32, a simple sensor, and a free SMS API, you can build a real-time alert system that fits in the palm of your hand. Whether you’re new to IoT or building advanced automation, this project is a practical and fun way to dive into wireless alerts without extra hardware. If you're looking for more hands-on tutorials, check out these ESP32 IoT project ideas to build real-world applications.




