Building A Voice Controlled Sos System With Telegram Alert
About the project
Will guide you to build a voice-triggered SOS system with M5stack and DFRobot.
Project info
Difficulty: Easy
Estimated time: 1 hour
License: GNU General Public License, version 3 or later (GPL3+)
Items used in this project
Hardware components
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.
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! Ã°à ¸ââ¬âãïøÃÂÃ°à ¸â⬠ÃÅÃ°à ¸ââ¬Åò
Leave your feedback...