See the ESP Discord Client in action:
- β¨ Cross-Platform: Works on both ESP8266 and ESP32
- π‘ WiFi Management: Automatic WiFi connection handling
- π Discord Integration: Send messages via Discord webhooks
- β° Optional Timestamps: Automatic timestamp generation with timezone support (can be enabled/disabled per message)
- π Secure: HTTPS communication with Discord
- π¨ Custom Branding: Messages appear with ESP logo avatar and custom username
- π Simple API: Easy to use with minimal setup
- π οΈ Lightweight: Minimal memory footprint
- Open Arduino IDE
- Go to Sketch β Include Library β Manage Libraries
- Search for "ESP Discord Client"
- Click Install
- Download this repository as ZIP
- Extract to your Arduino libraries folder:
- Windows:
Documents/Arduino/libraries/ - macOS:
Documents/Arduino/libraries/ - Linux:
~/Arduino/libraries/
- Windows:
- Restart Arduino IDE
This library requires:
- NTPClient (install via Library Manager)
Use the provided example to get started quickly. Open Arduino IDE and navigate to: File β Examples β ESPDiscordClient β BasicUsage.
Compatible Boards:
- ESP8266: NodeMCU, Wemos D1 Mini, ESP-01, etc.
- ESP32: ESP32 DevKit, ESP32-WROOM, ESP32-S2, ESP32-C3, etc.
Additional Requirements:
- USB cable for programming
- Stable 2.4GHz WiFi connection (both platforms support 2.4GHz only)
- Arduino IDE with board support for your chosen platform:
- ESP8266 board support (for ESP8266 boards)
- ESP32 board support (for ESP32 boards)
Required Libraries:
NTPClientby Fabrice Weinberg (install via Library Manager)
Platform-Specific Libraries (Auto-included):
For ESP8266:
ESP8266WiFiESP8266HTTPClientWiFiClientSecure
For ESP32:
WiFiHTTPClientWiFiClientSecure
π‘ Note: The code automatically includes the correct libraries based on your selected board!
- Open Arduino IDE
- Go to File β Preferences
- Add this URL to "Additional Board Manager URLs":
http://arduino.esp8266.com/stable/package_esp8266com_index.json
- Go to Tools β Board β Boards Manager
- Search for "ESP8266" and install the package
- Open Arduino IDE
- Go to File β Preferences
- Add this URL to "Additional Board Manager URLs":
https://dl.espressif.com/dl/package_esp32_index.json
- Go to Tools β Board β Boards Manager
- Search for "ESP32" and install the package by Espressif Systems
π‘ Tip: You can add both URLs separated by commas to support both platforms!
- Go to Sketch β Include Library β Manage Libraries
- Search and install:
NTPClientby Fabrice Weinberg
- Go to your Discord server
- Right-click on the channel where you want to receive messages
- Select "Edit Channel" β "Integrations" β "Webhooks"
- Click "New Webhook"
- Copy the webhook URL
Edit Config.hpp with your information:
#define SECRET_SSID "Your_WiFi_Name"
#define SECRET_PASS "Your_WiFi_Password"
#define SECRET_WEBHOOK "https://discord.com/api/webhooks/YOUR_WEBHOOK_URL"
#define TIME_ZONE 0 // Your timezone offset in hours (e.g., 1 for GMT+1, -5 for EST)Config.hpp in .gitignore for testing.
Set your timezone in Config.hpp using hours offset from UTC:
#define TIME_ZONE 1 // GMT+1 (1 hour ahead of UTC)Common timezone offsets (in hours):
- GMT+0:
0 - GMT+1:
1 - GMT+8:
8 - GMT-5:
-5
The timezone value is passed to the DiscordClient constructor and automatically converted to seconds internally.
The code automatically detects whether you're using ESP8266 or ESP32 and adapts accordingly. When your board boots up, you'll see a message indicating which platform is running:
Running on ESP8266
or
Running on ESP32
This is handled automatically through preprocessor directives - no manual configuration needed!
#include <ESPDiscordClient.h>
#include "Config.hpp"
DiscordClient discord(SECRET_SSID, SECRET_PASS, SECRET_WEBHOOK, TIME_ZONE);
void setup() {
Serial.begin(9600);
// Connect to WiFi
discord.connectWiFi();
// Send a message
discord.sendMessage("Hello from ESP42!", false);
}
void loop() {
// Your main code here
}// Send sensor data with timestamp (default behavior)
float temperature = 25.6;
String message = "π‘οΈ Temperature: " + String(temperature) + "Β°C";
discord.sendMessage(message); // Includes timestamp
// Send alerts with timestamp
if (temperature > 30) {
discord.sendMessage("π¨β οΈ HIGH TEMPERATURE ALERT β οΈπ¨", true);
}
// Explicit timestamp control
discord.sendMessage("π System initialized", false); // without timestampThe library now supports optional timestamps, giving you full control over when to include them:
// Without including timestamp
discord.sendMessage("Hello World!", false);
// Result: "Hello World!"
// With timestamp - Default behavior
discord.sendMessage("β οΈβ οΈβ οΈ ALERT β οΈβ οΈβ οΈ");
// Result: "β οΈβ οΈβ οΈ ALERT β οΈβ οΈβ οΈ Sun 28 Sept 2025 14:30:20"Use Cases:
- With Timestamp: Sensor readings, system events, logs, Alerts
- Without Timestamp: Status indicators, emoji-only or welcoming messages
The library automatically sends messages with:
- Custom Username: "ESP Discord Client"
- ESP Logo Avatar: Uses the ESP logo from the project as the webhook avatar or set your own preferred one
This gives your ESP device messages a professional, recognizable appearance in Discord channels.
This project uses preprocessor directives to automatically include the correct libraries and handle platform differences:
#if defined(ESP8266)
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#elif defined(ESP32)
#include <WiFi.h>
#include <HTTPClient.h>
#endifKey Benefits:
- Single Codebase: One project works on both platforms
- Automatic Detection: No manual configuration required
- Platform-Specific Optimizations: Uses the best libraries for each platform
- Future-Proof: Easy to add support for new ESP variants
| Feature | ESP8266 Library | ESP32 Library |
|---|---|---|
| WiFi Management | ESP8266WiFi |
WiFi |
| HTTP Client | ESP8266HTTPClient |
HTTPClient |
| Secure Client | WiFiClientSecure |
WiFiClientSecure |
| NTP Time | NTPClient |
NTPClient |
DiscordClient(const char *ssid, const char *password, const char *webhookUrl, int timezone = 0)ssid: WiFi network namepassword: WiFi network passwordwebhookUrl: Discord webhook URLtimezone: Timezone offset in hours from UTC (optional, defaults to 0)
void connectWiFi()
- Connects to the specified WiFi network
- Blocks until connection is established
- Prints connection status to Serial
bool sendMessage(const String &content, bool includeTimestamp = true)
- Sends a message to Discord
content: The message text to sendincludeTimestamp: Optional parameter to control timestamp inclusion (defaults totrue)- Returns
trueif successful,falseotherwise - New in v1.1.0: Optional timestamp control for flexible messaging
void begin(int timeOffset = 0)
- Initializes NTP client with timezone offset
- Offset in seconds from UTC
String getTime()
- Returns formatted timestamp string
- Format: "Day, Month Date Year HH:MM:SS"
WiFi Connection Failed
- Check SSID and password in
Config.hpp - Ensure your ESP board is in range of WiFi
- Verify WiFi network is 2.4GHz (both ESP8266 and ESP32 require 2.4GHz)
Message Not Sent
- Verify webhook URL is correct
- Check internet connection
- Monitor Serial output for error codes
Compilation Errors
- Ensure all required libraries are installed
- Check correct board (ESP8266/ESP32) is selected in Tools β Board
- Verify correct port is selected
- Ensure you have the right board support package installed
Enable detailed debugging by monitoring Serial output at 9600 baud:
- WiFi connection status
- HTTP response codes
- Success/failure messages
200/204: Success400: Bad Request (check webhook URL/format)401: Unauthorized (webhook may be invalid)429: Rate Limited (too many requests)
- β¨ New Feature: Optional timestamp control with
includeTimestampparameter - π§ Improvement: Better Arduino Library Manager compliance (removed spaces from library name)
- π Enhancement: Updated examples to demonstrate new timestamp feature
- ποΈ Refactor: Optimized time client initialization (only when needed)
- π Documentation: Updated README with comprehensive timestamp usage examples
- π Initial release
- β¨ Cross-platform support for ESP8266 and ESP32
- π‘ WiFi management with connection handling
- π Discord webhook integration
- β° Automatic timestamp generation with timezone support
- π Secure HTTPS communication
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is open source and available under the MIT LICENSE.
- ESP8266 & ESP32 Communities
- Espressif Systems for the amazing ESP platforms
- Arduino IDE Team
- NTPClient library by Fabrice Weinberg
- Contributors to ESP8266/ESP32 Arduino Core projects

