Building A Voice Controlled Sos System With Telegram Alert

Photo of CETECH11

Made by CETECH11

About the project

Will guide you to build a voice-triggered SOS system with M5stack and DFRobot.

Project info

Difficulty: Easy

Platforms: DFRobotM5Stack

Estimated time: 1 hour

License: GNU General Public License, version 3 or later (GPL3+)

Items used in this project

Hardware components

DFRobot Gravity: Offline Language Learning Voice Recognition Sensor DFRobot Gravity: Offline Language Learning Voice Recognition Sensor x 1
M5Stack M5StickC ESP32-PICO Mini IoT Development Board M5Stack M5StickC ESP32-PICO Mini IoT Development Board x 1

Software apps and online services

Arduino IDE Arduino IDE

Story

As our population ages, ensuring the safety and well-being of seniors becomes increasingly important. A voice-controlled SOS system can provide peace of mind for both elders and their caregivers. In this project, we’ll create a personalized emergency response system that allows seniors to call for help using voice commands. Additionally, we’ll integrate Telegram alerts to notify caregivers or family members instantly.

Project Components⚙️
  • Voice Recognition Module: We’ll use a voice recognition chip or module that responds to specific voice commands. When the user says a predefined phrase (e.g., “Help” or “Emergency”), the system will activate.
  • Microcontroller (M5StickC): The brain of our system, responsible for processing voice commands and triggering alerts.
  • Telegram Bot: We’ll set up a Telegram bot to send alerts to designated contacts. Telegram provides a secure and reliable platform for notifications.

Get PCBs for Your Projects Manufactured

You must check out PCBWAY for ordering PCBs online for cheap!

You get 10 good-quality PCBs manufactured and shipped to your doorstep for cheap. You will also get a discount on shipping on your first order. Upload your Gerber files onto PCBWAY to get them manufactured with good quality and quick turnaround time. PCBWay now could provide a complete product solution, from design to enclosure production. Check out their online Gerber viewer function. With reward points, you can get free stuff from their gift shop. Also, check out this useful blog on PCBWay Plugin for KiCad from here. Using this plugin, you can directly order PCBs in just one click after completing your design in KiCad.

Step 1️⃣:Voice Recognition Module SetupðŸ”Å :

Connect the voice recognition module to the M5StickC via the Grove interface. The Grove interface consists of a standardized 4-pin connector (GND, VCC, SDA, SCL).

Connect the voice recognition module’s pins (VCC, GND, SDA, SCL) to the corresponding Grove pins on the M5StickC.

Train the module with the chosen SOS phrases. In my case, I'm going to use the default wake word as a SOS command.

Step 2️⃣:Microcontroller Configuration⌨️:

First, we need to install the Voice Learning sensor's library to the Arduino IDE.

Here is the library link - GitHub - DFRobot/DFRobot_DF2301Q

Here is the simple Arduino sketch that can read the voice learning sensor's command and print the command ID.

#include "DFRobot_DF2301Q.h"
DFRobot_DF2301Q_I2C DF2301Q;
void setup()
{
Serial.begin(115200);
while( !( DF2301Q.begin() ) ) {
Serial.println("Communication with device failed, please check connection");
delay(3000);
}
Serial.println("Begin ok!");
DF2301Q.setVolume(7);
DF2301Q.setMuteMode(0);
DF2301Q.setWakeTime(15);
uint8_t wakeTime = 0;
wakeTime = DF2301Q.getWakeTime();
Serial.print("wakeTime = ");
Serial.println(wakeTime);
DF2301Q.playByCMDID(23); // Common word ID
}

void loop()
{
uint8_t CMDID = 0;
CMDID = DF2301Q.getCMDID();
if(0 != CMDID) {
Serial.print("CMDID = ");
Serial.println(CMDID);
}
delay(3000);
}

Here is the serial terminal response.

Step 3️⃣:Setting up the Telegram Bot 🤖:

Go to Google Play or App Store, download, and install Telegram. In my case, I'm using telegram web. First, search for “botfather” and click the BotFather as shown below.

Next, start the BotFather, and use /newbot to create a new bot.

Next, name your bot.

Then, mention the username.

Finally, it will show you the API key.

Step 4️⃣: Creating a user for Telegram Bot 👤:

Anyone that knows your bot username can interact with it. To make sure that we ignore messages that are not from our Telegram account (or any authorized users), you can get your Telegram User ID.

In your Telegram account, search for “IDBot”

Start a conversation with that bot and type /getid. You will get a reply with your user ID. Save that user ID, because you’ll need it later in this tutorial.

Step 5️⃣:System Deployment🛜:

Finally, upload the following sketch to the M5StickC and change the credentials as per your Bot setup.

#include <WiFi.h>
#include <WiFiClientSecure.h>
#include <UniversalTelegramBot.h>
#include <ArduinoJson.h>
#include "DFRobot_DF2301Q.h"
#include <M5StickC.h>

DFRobot_DF2301Q_I2C DF2301Q;
// Replace with your network credentials
const char* ssid = "ELDRADO";
const char* password = "amazon123";
// Initialize Telegram BOT
#define BOTtoken "6897873881" // your Bot Token (Get from Botfather)
#define CHAT_ID ""
WiFiClientSecure client;
UniversalTelegramBot bot(BOTtoken, client);

void setup() {
Serial.begin(115200);
M5.begin();
M5.Lcd.setRotation(3);
M5.Lcd.fillScreen(BLACK);
M5.Lcd.setSwapBytes(true);
M5.Lcd.setTextSize(1);
M5.Lcd.setCursor(7, 20, 2);
M5.Lcd.setTextColor(TFT_GREEN, TFT_BLACK);

// Attempt to connect to Wifi network:
Serial.print("Connecting Wifi: ");
Serial.println(ssid);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);

client.setCACert(TELEGRAM_CERTIFICATE_ROOT); // Add root certificate for api.telegram.org

while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println("");
Serial.println("WiFi connected");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
bot.sendMessage(CHAT_ID, "Bot started up", "");
while (!(DF2301Q.begin())) {
Serial.println("Communication with device failed, please check connection");
delay(3000);
}

Serial.println("Begin ok!");
DF2301Q.setVolume(7);
DF2301Q.setMuteMode(0);
DF2301Q.setWakeTime(15);
uint8_t wakeTime = 0;
wakeTime = DF2301Q.getWakeTime();
Serial.print("wakeTime = ");
Serial.println(wakeTime);
DF2301Q.playByCMDID(23); // Common word ID
}

void loop() {
uint8_t CMDID = 0;
CMDID = DF2301Q.getCMDID();
if (0 != CMDID) {
Serial.print("CMDID = ");
Serial.println(CMDID);
bot.sendMessage(CHAT_ID, "Alarm Triggered !!", "");
M5.Lcd.fillScreen(BLACK);
M5.Lcd.setCursor(3, 2);
M5.Lcd.print("Alarm Triggered !!");
}
delay(5000);
M5.Lcd.fillScreen(BLACK);
M5.Lcd.setCursor(1, 3);
M5.Lcd.print("System Online");
}

Once you have uploaded the sketch look for the serial terminal response.

Now let's test the system, just say the command word and look for the response.

Here is the Telegram response.

Conclusion✅

By combining voice control, Telegram alerts, and a user-friendly interface, our Voice-Controlled SOS System provides a simple yet effective solution for seniors. Whether they’re at home or outdoors, they can call for help with ease. Caregivers and family members can rest assured knowing that they’ll receive immediate notifications in case of an emergency. Let’s build a safer and more connected environment for our elders! 🗣️ðŸâ€ Ã‹Å“📲

Credits

Leave your feedback...