An Arduino-based smart trash bin system with automatic lid operation, fill-level monitoring, and IoT capabilities using ESP32.
This project automates waste disposal and monitoring by combining sensor technology and IoT connectivity. The system detects user proximity to open and close the lid automatically using a servo motor, ensuring hands-free operation for improved hygiene. Dual ultrasonic sensors measure both external proximity and internal bin fill levels, providing accurate and real-time monitoring.
The ESP32 microcontroller enables WiFi connectivity, allowing the system to send instant email notifications when the bin reaches a predefined fill threshold. An OLED display presents live status updates, including fill percentage and connection status, directly on the device.
With modular, configurable code, the system can be adapted for various bin sizes and environments. It’s suitable for smart homes, offices, or public spaces seeking automated, contactless waste management and remote monitoring.
- 👥 Proximity detection using HC-SR04 ultrasonic sensor
- 🚪 Servo-controlled automatic lid opening/closing
- 📊 Real-time fill level monitoring
- 📺 OLED display for system status
- 📧 Email alerts via Gmail integration
- 📶 WiFi connectivity using ESP32
| Component | Quantity |
|---|---|
| ESP32 Development Board | 1 |
| HC-SR04 Ultrasonic Sensor | 2 |
| SG90 Micro Servo Motor | 1 |
| 0.96" OLED Display | 1 |
| 330Ω Resistor | 2 |
| Jumper Wires | - |
| 5V Power Supply | 1 |
Coming Soon
Pin Connections:
| Component | ESP32 GPIO |
|---|---|
| External Trig | GPIO5 |
| External Echo | GPIO18 |
| Internal Trig | GPIO19 |
| Internal Echo | GPIO21 |
| Servo Control | GPIO13 |
| OLED SDA | GPIO4 |
| OLED SCL | GPIO15 |
- Clone repository:
git clone https://github.com/Customize5773/SmartTrashBin-Arduino.git
- Install Arduino IDE (1.8.x or newer)
- Add ESP32 board support:
- Add URL to Preferences:
https://dl.espressif.com/dl/package_esp32_index.json - Install ESP32 package via Boards Manager
- Add URL to Preferences:
- Install required libraries:
- ESP32Servo
- NewPing
- Adafruit SSD1306
- ESP Mail Client
- Update WiFi credentials in
TrashBin-Code.ino:#define WIFI_SSID "your_wifi_ssid" #define WIFI_PASSWORD "your_wifi_password"
- Configure email settings:
#define AUTHOR_EMAIL "your_email@gmail.com" #define AUTHOR_PASSWORD "your_app_password" // Use Gmail App Password #define RECIPIENT_EMAIL "recipient@email.com"
- Adjust system parameters as needed:
#define BIN_HEIGHT_CM 40 // Actual bin height #define FILL_THRESHOLD_PERCENT 80 #define PROXIMITY_THRESHOLD_CM 30
- Measure actual bin height from internal sensor to bottom
- Update
BIN_HEIGHT_CMwith measured value - Test proximity detection range with
PROXIMITY_THRESHOLD_CM - Generate Gmail App Password if using 2FA:
- Power on the system
- Approaching within 30cm triggers lid opening
- OLED displays real-time fill percentage
- Email alert sent when fill level ≥80%
- Lid automatically closes after 5 seconds
| Issue | Solution |
|---|---|
| WiFi connection failed | Verify credentials, check router |
| Email not sending | Use App Password, check SMTP |
| Sensor inaccuracies | Calibrate bin height, clean sensors |
| Servo jitter | Ensure stable power supply |
- Fork the repository
- Create feature branch:
git checkout -b feature/new-feature - Commit changes:
git commit -am 'Add new feature' - Push to branch:
git push origin feature/new-feature - Submit pull request
- NewPing library by Tim Eckel
- Adafruit for SSD1306 library
- ESP Mail Client library