ESP32 Trash Day Reminder: Build Your Own
In this article
Yes, you can build an ESP32-based trash day reminder that alerts you the evening before pickup, and it’s a practical weekend project that costs under $20 in parts. The ESP32’s built-in Wi-Fi lets it fetch the current date and time from the internet, so you can program it to know your pickup schedule without any manual clock setting.
Why Use an ESP32 for a Trash Reminder?
The ESP32 is a low-cost microcontroller with built-in Wi-Fi and Bluetooth, making it ideal for a connected reminder device. Unlike a simple timer or a phone alarm, an ESP32 can:
- Automatically sync its clock over the internet (NTP), so it never drifts or needs resetting after a power outage.
- Know the day of the week and date, so it can handle weekly, bi-weekly, or even holiday-adjusted schedules.
- Trigger multiple outputs—an LED, a buzzer, a display, or a notification to your phone via services like IFTTT or Pushover.
- Be reprogrammed easily if your pickup day changes.
For comparison, a standard wall timer can only run on a fixed 24-hour cycle; it cannot know that Tuesday is trash day unless you reset it weekly. The ESP32’s internet connection removes that limitation.
What You Need to Build It
Here is a typical parts list for a basic reminder unit:
- ESP32 development board (any common variant like the DevKitC or NodeMCU-32S)
- Breadboard and jumper wires
- An LED and a resistor (around 220Ω) for a visual alert
- A small buzzer (optional, for an audible alert)
- A micro-USB cable and a 5V power adapter (most boards accept 5V via USB)
- An enclosure (optional, but recommended for a permanent install)
If you want a display, a 0.96-inch OLED or a 16x2 LCD with I2C is a nice addition, but not required. The total cost is usually between $10 and $25, depending on what you already have.
How the Code Works
The core logic is simple: connect to Wi-Fi, fetch the current time from an NTP server, then compare the current day and time against your scheduled pickup. Here is a high-level breakdown of the code structure:
- Connect to Wi-Fi using your network credentials.
- Initialize NTP with a server like pool.ntp.org and set your timezone offset.
- Read the current time using the
time()function and convert it to a struct with day, month, year, and weekday. - Check the schedule—for example, if weekday is Monday and hour is 18:00, turn on the alert.
- Trigger the output—blink an LED, sound a buzzer, or send a notification.
- Sleep or loop—you can put the ESP32 into deep sleep between checks to save power, or simply loop with a delay.
Here is a minimal Arduino sketch snippet that shows the essential logic:
#include <WiFi.h>
#include <time.h>
const char* ssid = "YOUR_WIFI";
const char* password = "YOUR_PASS";
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
configTime(-5*3600, 3600, "pool.ntp.org"); // EST with DST
}
void loop() {
struct tm timeinfo;
if (getLocalTime(&timeinfo)) {
int weekday = timeinfo.tm_wday; // 0=Sunday, 1=Monday...
int hour = timeinfo.tm_hour;
if (weekday == 1 && hour == 18) { // Monday at 6 PM
digitalWrite(LED_BUILTIN, HIGH);
delay(60000); // stay on for 1 minute
digitalWrite(LED_BUILTIN, LOW);
}
}
delay(3600000); // check every hour
}This example checks once per hour, but you can adjust the delay or use deep sleep to save power. For a production reminder, you would also handle the case where the ESP32 loses Wi-Fi and needs to reconnect.
Choosing the Right ESP32 Board
All ESP32 boards have the same core chip, but they differ in flash size, antenna, and form factor. For this project, any board with Wi-Fi works. Consider these factors:
- Flash size: 4MB is standard and more than enough for this project.
- Antenna: A PCB antenna is fine if your Wi-Fi signal is strong; an external antenna connector helps if the device is in a metal enclosure or far from the router.
- USB connector: Micro-USB is common, but USB-C is more convenient if you have newer cables.
- Extra features: Some boards have built-in batteries, displays, or relays—choose based on your needs.
Popular choices include the ESP32 DevKitC, the ESP32-WROOM-32, and the ESP32-S2/S3 variants. All are compatible with the Arduino IDE and PlatformIO.
Common Problems and How to Fix Them
Here are the most frequent issues beginners run into:
- Wi-Fi won’t connect: Double-check SSID and password, and make sure the board is powered properly. Try a different power source if the LED flickers.
- Wrong time: The timezone offset in
configTime()must be correct. For example, US Eastern is -5 hours (or -4 in daylight saving). You can also use a library liketimezoneto handle DST automatically. - Time resets after reboot: The ESP32 does not have a real-time clock battery; it relies on NTP. As long as it can reach the internet after boot, it will sync again.
- Buzzer too loud or too quiet: Use a transistor or a MOSFET to drive a larger buzzer, or add a resistor to reduce volume.
- LED stays on forever: Make sure you turn it off after a delay, or use a timer to reset it.
If you’re using deep sleep, remember that the ESP32 wakes up, runs the code, and goes back to sleep. The time is preserved during sleep, but you must re-sync NTP after each wake if you want accurate time.
Alternatives to a Physical Device
If you do not want to build hardware, there are simpler software-only options:
- Phone reminders: Set a recurring weekly alarm on your phone. It works but requires you to remember to charge your phone and keep it on.
- Smart home routines: Use a smart speaker or hub (like Alexa or Google Home) to announce trash day at a set time. This requires a compatible smart speaker and a reliable internet connection.
- Calendar apps: Create a recurring event in Google Calendar or Outlook and set a notification. This is the simplest and most reliable, but it does not give you a physical indicator.
- Raspberry Pi: A more powerful single-board computer can do the same job, but it uses more power and is overkill for a reminder.
The main advantage of the ESP32 is that it is a dedicated, always-on device that can be placed near the door or on the trash bin itself, and it can be customized with sensors (e.g., a lid sensor) to confirm the bin is out.
Cost and Power Considerations
The ESP32 board itself costs around $5–$10. Add an LED, buzzer, and a few components, and the total is under $15. Power consumption is modest: while active with Wi-Fi, the ESP32 draws about 100–150 mA at 3.3V, which is roughly 0.5W. If you run it 24/7, that’s about 0.5 kWh per month, which is negligible on your electricity bill. Using deep sleep (waking once an hour) can cut that to a few milliwatts, allowing battery operation for months.
For a battery-powered version, use a 18650 lithium cell with a TP4056 charging module and a low-dropout regulator. The ESP32’s deep sleep current is around 10 µA, so a 2000 mAh battery could last over a year with hourly wake-ups.
Safety and Best Practices
When working with electronics, follow these safety tips:
- Always disconnect power before changing connections.
- Use a resistor in series with LEDs to limit current (220Ω to 1kΩ is typical for 3.3V).
- If using a battery, ensure the polarity is correct and use a protection circuit.
- Do not expose the board to water or extreme heat; use an enclosure if it will be outdoors.
- If you use a mains-powered adapter, make sure it is rated for your region and provides 5V DC.
Also, be mindful of your Wi-Fi network’s security. Do not hardcode credentials in a public repository; use environment variables or a configuration file.
Frequently Asked Questions
Can I use an ESP8266 instead of an ESP32?
Yes, the ESP8266 is cheaper and has the same Wi-Fi capabilities, but it has fewer GPIO pins and less RAM. For a simple reminder, it works fine. The code is almost identical, but you need to adjust the pin numbers and possibly the board selection in the IDE.
How do I handle holidays when trash pickup is delayed?
You can hardcode a list of holidays in your code, but that becomes tedious to update. A better approach is to use a web API that provides holiday dates for your region, or simply check your local waste management website and manually update the schedule once a year.
Can the ESP32 send me a notification to my phone?
Yes. You can use services like IFTTT with a webhook, or push notifications via Pushover, Telegram, or Blynk. The ESP32 makes an HTTPS request to the service’s API, which then sends the notification to your phone. This is a popular feature for reminders.
What if my Wi-Fi is down?
If the ESP32 cannot connect to Wi-Fi at boot, it will not have the correct time. You can add a fallback: store the last known time in RTC memory (which survives deep sleep) and use that, but it will drift. For a critical reminder, a phone alarm is a more reliable backup.
Do I need to know programming to build this?
Basic familiarity with the Arduino IDE helps, but there are many tutorials and pre-written code snippets available. You can copy and modify the code without fully understanding every line. The learning curve is moderate; expect to spend a few hours on your first build.
Can I make the reminder speak the trash type?
Yes, if you add a small audio module like a DFPlayer MP3 player, you can play a pre-recorded message. Alternatively, use a text-to-speech service on the cloud, but that requires a more complex setup. For a simple solution, use a buzzer with different tones for different trash types.