A native Discord bot running on an ESP32 using WebSockets. This project allows you to host a functional Discord bot on a microcontroller without needing a 24/7 PC or a VPS. It also features optional real-time status updates on an SSD1306 OLED display.
Note
This project has been developed and tested specifically on the ESP32 DevKit V1. While it may work on other ESP32 variants, pin layouts and compatibility have not been verified.
- Native WebSockets: Connects directly to the Discord Gateway (v10).
- Command Handling: Supports basic interactive commands.
- OLED Integration: Displays bot status, connectivity, and command logs on a 128x64 I2C screen.
- Low Power: Efficiently handles heartbeats and message parsing via ArduinoJson.
- ESP32
- SSD1306 128x64 I2C OLED (Optional)
- ESP32 DEVKIT V1 (ESP-WROOM-32)
- IIC I2C OLED display 0,96" - White, 128 x 64
>:test- Checks if the bot is responding and see some stats.>:ping- Measures the latency of the ESP32.>:echo <channel_id> <message>- Makes the bot echo a text you say in a chosen channel.>:flip- Flips a coin.>:rng <min> <max>- Generate a random number in a chosen range.
- Discord Developer Portal:
- Create a new application and get your Bot Token.
- Enable Message Content Intent in the "Bot" settings tab.
- Configuration:
- Open the
config.hfile and update the following variables: token: Your Discord Bot Token.wifiName: Your WiFi SSID.wifiPassword: Your WiFi Password.botName: What name do you want displayed on the OLED.
- Wiring:
- VCC -> 3.3V
- GND -> GND
- SCL -> GPIO 22
- SDA -> GPIO 21
- Flash: Select your ESP32 board in Arduino IDE and upload the sketch.
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 (CC BY-NC-SA 4.0)