icon

Build a Voice Controlled SOS System with Telegram Alert

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.

Ā 

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.

Ā 

Project Componentsāš™ļø

Ā 

1.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.2. Microcontroller (M5StickC): The brain of our system, responsible for processing voice commands and triggering alerts.3.Telegram Bot: We’ll set up a Telegram bot to send alerts to designated contacts. Telegram provides a secure and reliable platform for notifications.

Ā 

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 will 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

Ā 

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

Ā 

CODE
#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.

Ā 

CODE
#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! šŸ—£ļøšŸ†˜šŸ“²

License
All Rights
Reserved
licensBg
0