A modern, scalable IoT platform for monitoring and controlling ESP32-based devices through a beautiful web dashboard.
SmartSense Home is a complete, production-ready IoT platform that enables users to:
- π Monitor real-time sensor data from ESP32 devices
- ποΈ Control IoT devices remotely via intuitive web interface
- π₯ Manage multiple devices from a single dashboard
- π Secure multi-user authentication system
- π‘ Communicate via REST API (no MQTT broker required)
Perfect for home automation, environmental monitoring, smart sensors, and IoT prototyping!
- β‘ Fast PHP 8+ REST API
- π Secure authentication (bcrypt password hashing)
- ποΈ MySQL database with optimized schema
- π‘οΈ SQL injection protection (prepared statements)
- π Input validation and sanitization
- π Token-based device authentication
- π¨ Clean, modern UI/UX
- π± Fully responsive design
- β‘ Real-time data updates
- π Data visualization (tables + graphs)
- ποΈ Device control interface
- π No frameworks - pure vanilla JavaScript
- π‘ WiFi connectivity
- π Automatic reconnection
- π€ Batch data transmission
- π₯ Command polling & execution
- π‘ Built-in LED control example
- π‘οΈ DHT22 sensor support (optional)
- XAMPP (Apache + PHP 8.0+ + MySQL)
- Arduino IDE with ESP32 support
- ESP32-C3 Super Mini (or compatible board)
-
Clone the repository
git clone https://github.com/scrozza2007/smartsense-home.git cd smartsense-home -
Setup database
- Copy project to
xampp/htdocs/ - Open phpMyAdmin:
http://localhost/phpmyadmin - Create database:
smartsense_home - Import:
database/schema.sql
- Copy project to
-
Configure backend
- Verify settings in
backend/config/database.php - Default:
rootuser, no password (XAMPP default)
- Verify settings in
-
Access web app
- Open:
http://localhost/smartsense-home/frontend/ - Create account and login
- Add your first device
- Open:
-
Setup ESP32
- Install libraries:
ArduinoJson - Configure WiFi in
esp32/smartsense_device/smartsense_device.ino - Set server IP and device token
- Upload to ESP32
- Install libraries:
π Detailed guide: docs/INSTALLATION.md
smartsense-home/
βββ backend/ # PHP backend
β βββ api/
β β βββ auth/ # Authentication endpoints
β β βββ devices/ # Device management
β β βββ device/ # ESP32 communication
β βββ config/ # Database configuration
β βββ includes/ # Utility functions
βββ frontend/ # Web dashboard
β βββ assets/
β β βββ css/ # Stylesheets
β β βββ js/ # JavaScript modules
β βββ index.html # Login page
β βββ register.html # Registration page
β βββ dashboard.html # Main dashboard
βββ esp32/ # Arduino sketches
β βββ smartsense_device/ # ESP32-C3 firmware
βββ database/ # SQL schema
β βββ schema.sql
βββ docs/ # Documentation
β βββ API.md # API reference
β βββ ESP32_SETUP.md # ESP32 guide
β βββ INSTALLATION.md # Setup instructions
βββ .gitignore
βββ README.md
-
Register/Login
- Create account with username, email, password
- Login to access dashboard
-
Add Device
- Click "Add Device"
- Enter device name (e.g., "Living Room Sensor")
- Save the device token! (needed for ESP32)
-
View Data
- Click on device card to view sensor data
- Latest values shown at top
- Historical data in table below
- Auto-refreshes every 10 seconds
-
Send Commands
- Select command type (LED, RELAY, etc.)
- Enter value (ON, OFF, TOGGLE)
- Click "Send"
- ESP32 executes command within seconds
Configuration:
const char* WIFI_SSID = "YourWiFiName";
const char* WIFI_PASSWORD = "YourPassword";
const char* API_BASE_URL = "http://192.168.1.100/smartsense-home/backend/api";
const char* DEVICE_TOKEN = "your_device_token_from_dashboard";Features:
- Sends sensor data every 30 seconds (configurable)
- Polls for commands every 5 seconds (configurable)
- Built-in LED control on GPIO8
- Automatic WiFi reconnection
- Detailed serial output for debugging
POST /api/auth/register- Create accountPOST /api/auth/login- LoginPOST /api/auth/logout- Logout
GET /api/devices/list- List user devicesPOST /api/devices/create- Add new deviceGET /api/devices/data- Get device dataPOST /api/devices/command- Send command
POST /api/device/send_data- Submit sensor dataGET /api/device/get_commands- Poll for commandsPOST /api/device/update_command- Update command status
π Full API documentation: docs/API.md
| Component | Technology |
|---|---|
| Backend | PHP 8+, PDO, MySQL |
| Frontend | HTML5, CSS3, JavaScript (ES6+) |
| Database | MySQL 5.7+ / MariaDB 10.3+ |
| Hardware | ESP32-C3 Super Mini |
| Firmware | Arduino (C++), ArduinoJson |
| Server | Apache 2.4+ (XAMPP) |
users
βββ id
βββ username
βββ email
βββ password_hash
βββ created_at
devices
βββ id
βββ user_id (FK β users)
βββ device_name
βββ device_token (unique)
βββ is_online
βββ last_seen
sensor_data
βββ id
βββ device_id (FK β devices)
βββ sensor_type
βββ sensor_value
βββ unit
βββ timestamp
commands
βββ id
βββ device_id (FK β devices)
βββ command_type
βββ command_value
βββ status (pending/executed/failed)
βββ created_at
β Password Security
- Bcrypt hashing (cost factor 10)
- Salted hashes
β Database Security
- Prepared statements (SQL injection protection)
- Input validation and sanitization
- Foreign key constraints
β API Security
- Session-based authentication
- Device token authentication
- Access control (users only see their devices)
β Best Practices
- HTTPS ready (configure SSL certificate)
- CORS headers configured
- XSS protection via
htmlspecialchars()
Clean authentication interface with registration option.
Device cards, real-time data, command controls
Latest values, historical data table, command interface
# Register user
curl -X POST http://localhost/smartsense-home/backend/api/auth/register.php \
-H "Content-Type: application/json" \
-d '{"username":"test","email":"test@example.com","password":"test123"}'
# Login
curl -X POST http://localhost/smartsense-home/backend/api/auth/login.php \
-H "Content-Type: application/json" \
-d '{"username":"test","password":"test123"}' \
-c cookies.txt
# List devices
curl -X GET http://localhost/smartsense-home/backend/api/devices/list.php \
-b cookies.txt- Upload code to ESP32
- Open Serial Monitor (115200 baud)
- Verify:
- WiFi connection β
- Data sending (HTTP 201) β
- Command polling β
- LED control β
- π Installation Guide - Complete setup instructions
- π API Reference - REST API documentation
- π ESP32 Setup - Hardware configuration
// In ESP32 code
JsonObject custom = readings.createNestedObject();
custom["sensor_type"] = "soil_moisture";
custom["sensor_value"] = String(analogRead(A0));
custom["unit"] = "%";// In executeCommand()
} else if (type == "RELAY") {
digitalWrite(RELAY_PIN, value == "ON" ? HIGH : LOW);
Serial.println("β Relay controlled");
}const unsigned long DATA_SEND_INTERVAL = 60000; // 1 minute
const unsigned long COMMAND_CHECK_INTERVAL = 10000; // 10 seconds| Issue | Solution |
|---|---|
| Database connection failed | Check MySQL is running, verify credentials |
| API returns 404 | Ensure files in correct htdocs location |
| ESP32 won't connect | Verify WiFi credentials, use 2.4GHz network |
| Device token invalid | Copy token exactly from dashboard |
| Data not appearing | Check Serial Monitor for HTTP response codes |
π More help: docs/INSTALLATION.md#troubleshooting
- Data export (CSV, JSON)
- Email/SMS alerts on sensor thresholds
- Device groups and automation rules
- Mobile app (React Native)
- MQTT support (optional alternative)
- WebSocket for real-time updates
- Charts and data visualization
- Device firmware OTA updates
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
scrozza2007
- GitHub: @scrozza2007
- Inspired by platforms like Blynk and ThingsBoard
- ESP32 community for amazing support
- ArduinoJson library by Benoit Blanchon
- All contributors and testers
If you find this project useful, please consider giving it a star! β
- π Documentation
- π Issue Tracker
- π¬ Discussions
Made with β€οΈ for the IoT community