We’re a small team building LiveAPI, a super-convenient tool that streamlines engineering workflows by generating API docs from your code in just minutes.
With our fast-paced approach of rolling out new features daily, ensuring our services stay online has always been a top priority.
To monitor downtime, we Initially integrated Gatus with Discord webhooks.
It worked for a while, but we had an incident after deploying changes to the login system. The sign-in service went down. Even with three backups running in parallel, we missed the alert as it went down in the middle of the night.
That’s when it became clear to us only Discord Notification is not enough.
We upgraded by adding ntfy for push notifications. It is working. We wanted to experiment to see if we could do it with any speaker that is always on and cannot be ignored. That’s when I thought, "Why not use IoT for service alerts?"
In this article, I’ll walk you through how I made this work, from concept to implementation.
How The IoT Alert System Should Work
My Goal is to ensure that I receive a sound notification whenever one of my services goes down. Even during the night or when I’m not actively checking notifications.
To achieve this, I needed a way to bridge my existing monitoring tool, Gatus, with an IoT device capable of producing a sound alert.
We had already integrated with Gatus Discord notification I just need to use this webhook functionality to inform an IoT device, which will then produce an audible alert to catch attention immediately.
This means I needed a microcontroller with built-in Wi-Fi is essential. With the ability to connect to a network and interact with the webhook, the microcontroller serves as the perfect bridge between Gatus and the sound alert system.
Now that the logic is clear, the next step is selecting the perfect microcontroller and designing the system to meet these requirements.
To bring the idea to life, selecting the right microcontroller and designing an efficient connection setup is crucial.
The microcontroller must meet the requirements of being cost-effective, reliable, and capable of connecting to the internet.
Hardware Selection: Choosing the ESP32 Microcontroller
After exploring various options, I chose the ESP32 CP210x microcontroller for this project. This microcontroller is a popular choice for IoT applications because of its built-in Wi-Fi module, low power consumption, and versatility.
It supports multiple protocols, making it ideal for receiving webhook notifications. Additionally, its ease of programming and compatibility with various development tools make it beginner-friendly and highly customizable.
The ESP32 also features enough GPIO pins to connect external components, such as a buzzer or speaker, which will be used to produce the sound notification.
hence made it the perfect candidate for creating a reliable alert system.
Key Components and Connections
The connection design involves integrating the ESP32 with the required components to ensure the system can function as intended.
- Wi-Fi Connectivity: The ESP32 connects to the internet via Wi-Fi.
- Sound Output: A buzzer or small speaker is connected to one of the GPIO pins. This component is used to produce a loud sound when the ESP32 processes the webhook notification.
- Power Source: The ESP32 is powered via a USB cable or battery, depending on whether the system is stationary or portable.
- Programming Interface: The microcontroller is programmed through its CP210x USB-to-Serial interface, which simplifies flashing firmware and debugging.
With the microcontroller and connections in place, the next step is to set up the development environment and configure the system logic.
With the hardware chosen and the design outlined, the next step is to set up the development environment.
Setting Up the Development Environment
To program and configure the microcontroller efficiently, I chose VS Code as the development environment. VS Code offers a powerful, lightweight platform with excellent support for IoT projects, thanks to its rich ecosystem of extensions and plugins.
How I set up the environment:
- Install VS Code: Download and install VS Code from the official website.
- Add the PlatformIO Extension: I used the PlatformIO IDE extension because of its robust features for embedded development. Alternatively, the Arduino IDE is also a good choice for beginners. Both IDEs provide tools for writing, compiling, and uploading code to the microcontroller.
- Configure the ESP32 Development Environment:
Configure the USB-to-Serial drivers to ensure seamless communication with the microcontroller.
For the CP210x interface, the drivers can be downloaded from the manufacturer's website. - Set Up the Project: Create a new project folder in VS Code, initialize it with the selected extension, and select the appropriate board settings for the ESP32.
This setup ensures that the development process is smooth and efficient, enabling quick iterations and debugging.
I recommend going through this video where he has explained the full setup briefly.
With the IDE ready, the next step is to dive into programming the logic that connects the IoT device to the monitoring system.
Testing With Normal Blinking Light Program
Before implementing the full logic for the IoT notification system, it’s a good idea to test the setup with a basic program. A blinking light program is a perfect starting point to verify that the microcontroller, IDE, and connections are working correctly.
Continue Reading on Original Post
Author Of article : Ganesh Kumar Read full article