Revolutionizing IoT: A Library for Discord Bots on ESP Devices


In my journey as an open-source contributor, this recent project holds a special place. It draws upon my experience in web development and my understanding of the intriguing IoT electronics world. Moreover, what makes this project so thrilling is its intended audience: fellow developers, who can leverage this library to bring their innovative ideas to life. Crafted meticulously in pure C language, the library employs modern programming mechanisms such as WebSockets and HTTP requests, adding an extra layer of excitement and challenge to the project’s realization.

For those who are more into visuals, I’ve created a YouTube video detailing the project. It serves as a comprehensive guide on how to utilize this library and showcases a basic demo application.

Unfolding Discord

If you’re unfamiliar with Discord, it is a VoIP, instant messaging, and digital distribution platform primarily designed to cultivate communities. Users can connect through voice calls, video calls, text messaging, media and files either privately or as part of “servers” – essentially a collection of enduring chat rooms and voice chat channels. With compatibility across a wide range of platforms – Windows, macOS, Android, iOS, iPadOS, Linux, and even web browsers – Discord has managed to accumulate over 250 million users as of July 21, 2019.

The World of Discord Bots

Think of Discord bots as AI-powered facilitators that can perform a multitude of automated tasks and Discord commands on your server. From welcoming new members, moderating content, and enforcing rules to adding music, memes, games, and other content – Discord bots offer a wide array of possibilities. To put it simply, they are special user accounts that can automate responses and actions, like muting or removing users who spam a channel.

Merging Discord Bots with IoT

How about tailoring a bot to an IoT device? This means, using messages from Discord channels, we can control home devices or even collect sensor data and relay it to the Discord channel. Essentially, Discord can act as a free communication layer. What makes this even more powerful is Discord’s ability to maintain a permanent WebSocket channel for real-time, low-latency, bidirectional communication with bots, or in this case, IoT devices. Intriguing, right?

The Library

The library, crafted in C, is tailored to function with the ESP-IDF framework – a popular development framework for ESP devices. Developed primarily by Espressif (the maker of ESP devices), the ESP-IDF framework has been adopted by a vast community on GitHub and is at the heart of platforms like Arduino and PlatformIO.

Designed as an extension (component) to the ESP-IDF, this library, named ‘esp-discord‘ provides an abundance of bot features but is ripe for further expansion and enhancement. Some of the current features include sending and receiving messages, acquiring roles or channels, checking user permissions, reacting to messages, downloading attachments, and more.

The full source code of the library, open to contributions and available under the MIT license, can be found on GitHub:

For those eager to contribute, pull requests on the GitHub repository are more than welcome. So go ahead, clone the repository, and inject some of your innovative features.

Leveraging the Library

For a detailed tutorial on how to use the library and craft a basic Discord bot, refer to the embedded video in the Introduction.

Exemplary Projects

Let’s take a look at some demo projects I’ve built using ‘esp-discord.’ They illustrate the potential of this library and serve as inspiration for those with unique ideas:

Discord-driven RFID attendance system

Over-The-Air firmware live updates

Discord voice status monitoring ESP32 bot

More examples of using esp-discord library, as well as this demonstrated projects, are open sourced and available in the next GitHub repository:

Wrapping Up

Indeed, the library is already brimming with features, and it is poised for further enhancements and improvements. The positive feedback and interest expressed by the community, along with their enthusiasm to incorporate this library into their projects, have been immensely gratifying. As we continue to evolve, I am looking forward to seeing how this tool can be leveraged to unlock even more innovative solutions in the world of IoT and beyond.