Search the Community
Showing results for tags 'telegram'.
-
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 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! 🗣️🆘📲
-
- voice control
- telegram
-
(and 2 more)
Tagged with:
-
Imagine having a device that can measure the intensity of sunlight and send you alerts on Telegram whenever the sunlight reaches a certain level. This project will guide you through building such a device using the Beetle ESP32 C6 and the Grove Sunlight Intensity Sensor. Let’s get started! 🚀 Materials Needed 🛠️ Beetle ESP32 C6: A compact and powerful microcontroller. Grove Sunlight Intensity Sensor: A sensor capable of detecting UV, visible, and infrared light. Jumper wires: For connections. USB Type-C cable: To power and program the Beetle ESP32 C6. 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: Hardware Setup 🔧 Connect the Sunlight Sensor: Plug the Grove Sunlight Intensity Sensor into one of the Beetle. The I2C ports are usually labeled and color-coded for convenience. Power the Board: Connect the Beetle ESP32 C6 to a power source using the USB Type-C cable. You can use a battery or a USB power bank if you want to make your setup portable. Step 2: Software Setup 💻 Install Arduino IDE: If you haven’t already, download and install the Arduino IDE from the official website. Add ESP32 Board to Arduino IDE: Open Arduino IDE and go to File > Preferences. In the “Additional Board Manager URLs” field, add: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json. Go to Tools > Board > Board Manager, search for “ESP32”, and install the ESP32 board package. Select the Beetle ESP32 C6 Board: Go to Tools > Board and select Beetle ESP32 C6. Choose the correct port from Tools > Port. Step 3: Coding 👨💻 Install Required Libraries: Open Arduino IDE and go to Sketch > Include Library > Manage Libraries. Search for and install the following libraries: Grove_Sunlight_Sensor WiFi UniversalTelegramBot Write the Sunlight Intensity Detection Code: #include "Si115X.h" Si115X si1151; void setup() { Serial.begin(115200); if (!si1151.Begin()) { Serial.println("Si1151 is not ready!"); while (1) { delay(1000); Serial.print("."); }; } else { Serial.println("Si1151 is ready!"); } } void loop() { Serial.print("IR: "); Serial.println(si1151.ReadIR()); Serial.print("Visible: "); Serial.println(si1151.ReadVisible()); delay(500); } Step 4: Upload and Test 🚀 Upload the Code: Connect your Beetle ESP32 C6 to your computer and upload the code using the Arduino IDE. Test the Sensor: Once the code is uploaded, the sensor will start measuring sunlight intensity. Step 5: Setting Up Telegram Bot 📲 Create a Telegram Bot: Open Telegram and search for BotFather. Start a chat with BotFather and use the command /newbot to create a new bot. Follow the instructions to get your bot token. Get Your Chat ID: Start a chat with your bot and send any message. Look for the chat object in the response to find your chat ID. Final Sketch #include <WiFi.h> #include <WiFiClientSecure.h> #include <UniversalTelegramBot.h> // Universal Telegram Bot Library written by Brian Lough: https://github.com/witnessmenow/Universal-Arduino-Telegram-Bot #include <ArduinoJson.h> #include "Si115X.h" // Replace with your network credentials const char* ssid = "ELDRADO"; const char* password = "amazon123"; // Use @myidbot to find out the chat ID of an individual or a group // Also note that you need to click "start" on a bot before it can #define CHAT_ID "XXXXXXXXXXXXX" // Initialize Telegram BOT #define BOTtoken "XXXXXXXXXXXXX" // your Bot Token (Get from Botfather) float uv; float light; Si115X si1151; WiFiClientSecure client; UniversalTelegramBot bot(BOTtoken, client); //Checks for new messages every 1 second. int botRequestDelay = 1000; unsigned long lastTimeBotRan; // Get BME280 sensor readings and return them as a String variable String getReadings(){ uv = si1151.ReadIR(); light = si1151.ReadVisible(); String message = "UV Intencity: " + String(uv) + " \n"; message += "Visible Light: " + String (light) + " \n"; return message; } //Handle what happens when you receive new messages void handleNewMessages(int numNewMessages) { Serial.println("handleNewMessages"); Serial.println(String(numNewMessages)); for (int i=0; i<numNewMessages; i++) { // Chat id of the requester String chat_id = String(bot.messages[i].chat_id); if (chat_id != CHAT_ID){ bot.sendMessage(chat_id, "Unauthorized user", ""); continue; } // Print the received message String text = bot.messages[i].text; Serial.println(text); String from_name = bot.messages[i].from_name; if (text == "/start") { String welcome = "Welcome, " + from_name + ".\n"; welcome += "Use the following command to get current readings.\n\n"; welcome += "/readings \n"; bot.sendMessage(chat_id, welcome, ""); } if (text == "/readings") { String readings = getReadings(); bot.sendMessage(chat_id, readings, ""); } } } void setup() { Serial.begin(115200); if (!si1151.Begin()) { Serial.println("Si1151 is not ready!"); while (1) { delay(1000); Serial.print("."); }; } else { Serial.println("Si1151 is ready!"); } // Connect to Wi-Fi WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); #ifdef ESP32 client.setCACert(TELEGRAM_CERTIFICATE_ROOT); // Add root certificate for api.telegram.org #endif while (WiFi.status() != WL_CONNECTED) { delay(1000); Serial.println("Connecting to WiFi.."); } // Print ESP32 Local IP Address Serial.println(WiFi.localIP()); } void loop() { if (millis() > lastTimeBotRan + botRequestDelay) { int numNewMessages = bot.getUpdates(bot.last_message_received + 1); while(numNewMessages) { Serial.println("got response"); handleNewMessages(numNewMessages); numNewMessages = bot.getUpdates(bot.last_message_received + 1); } lastTimeBotRan = millis(); } } Detailed Explanation of the Code 📝 Libraries and Credentials: The code includes the necessary sensor, Wi-Fi, and Telegram bot libraries. Replace the placeholders with your Wi-Fi credentials and Telegram bot token. #include <WiFi.h> #include <WiFiClientSecure.h> #include <UniversalTelegramBot.h> // Universal Telegram Bot Library written by Brian Lough: https://github.com/witnessmenow/Universal-Arduino-Telegram-Bot #include <ArduinoJson.h> #include "Si115X.h" // Replace with your network credentials const char* ssid = "ELDRADO"; const char* password = "amazon123"; // Use @myidbot to find out the chat ID of an individual or a group // Also note that you need to click "start" on a bot before it can #define CHAT_ID "77777777" // Initialize Telegram BOT #define BOTtoken "jkjkklkkllkl:ffghhyjjkkjkkkl" // your Bot Token (Get from Botfather) Sensor Initialization: The setup() function initializes the serial communication, connects to Wi-Fi, and sets up the sunlight sensor. void setup() { Serial.begin(115200); if (!si1151.Begin()) { Serial.println("Si1151 is not ready!"); while (1) { delay(1000); Serial.print("."); }; } else { Serial.println("Si1151 is ready!"); } // Connect to Wi-Fi WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); #ifdef ESP32 client.setCACert(TELEGRAM_CERTIFICATE_ROOT); // Add root certificate for api.telegram.org #endif while (WiFi.status() != WL_CONNECTED) { delay(1000); Serial.println("Connecting to WiFi.."); } // Print ESP32 Local IP Address Serial.println(WiFi.localIP()); } Reading Sensor Data: In the loop() function, the sensor readings for UV, visible, and IR light are obtained and printed to the serial monitor. String getReadings(){ uv = si1151.ReadIR(); light = si1151.ReadVisible(); String message = "UV Intencity: " + String(uv) + " \n"; message += "Visible Light: " + String (light) + " \n"; return message; } Sending Telegram Alerts: If the UV index exceeds a specified threshold (e.g., 5.0), a message is sent to your Telegram bot with the current UV index. } void handleNewMessages(int numNewMessages) { Serial.println("handleNewMessages"); Serial.println(String(numNewMessages)); for (int i=0; i<numNewMessages; i++) { // Chat id of the requester String chat_id = String(bot.messages[i].chat_id); if (chat_id != CHAT_ID){ bot.sendMessage(chat_id, "Unauthorized user", ""); continue; } // Print the received message String text = bot.messages[i].text; Serial.println(text); String from_name = bot.messages[i].from_name; if (text == "/start") { String welcome = "Welcome, " + from_name + ".\n"; welcome += "Use the following command to get current readings.\n\n"; welcome += "/readings \n"; bot.sendMessage(chat_id, welcome, ""); } if (text == "/readings") { String readings = getReadings(); bot.sendMessage(chat_id, readings, ""); } } Delay: The delay(10000) function ensures that the sensor readings and alerts are checked every minute. Conclusion 🎉 Congratulations! You’ve successfully built a sunlight intensity detector with the Beetle ESP32 C6 and the Grove Sunlight Intensity Sensor, complete with Telegram alerts. This project can be expanded further by adding sensors or integrating with other IoT platforms. Feel free to share your project and any modifications you make. Happy building! 🛠️
-
Telegram is a popular messaging app that offers end-to-end encryption, cloud-based storage, and a variety of features for communication. One of these features is the ability to create and interact with bots, which are automated programs that can perform tasks or provide information. In this blog post, I will show you how to use Telegram bots to control your home automation system with Node-RED, a visual programming tool that allows you to connect and orchestrate devices, services, and APIs. 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. 1. What You Need: To follow this tutorial, you will need: A Telegram account and a smartphone with the Telegram app installed. A Node-RED instance running on a device that can access your home automation system. You can use a Raspberry Pi, a computer, or a cloud service. For more information on how to install and run Node-RED, see here. The node-red-contrib-telegrambot node provides Telegram bot nodes for Node-RED. You can install it from the Node-RED palette manager or by running the following command in your Node-RED directory: npm install node-red-contrib-telegrambot A Telegram bot token is a unique identifier for your bot. You can create a bot and get its token by talking to the @BotFather bot on Telegram. For more details. A chat ID is a unique identifier for the chat between you and your bot. You can get your chat ID by sending a message to your bot. 2. How It Works: The basic idea is to use Node-RED to create a flow that receives messages from your Telegram bot, parses them to extract commands or queries, and then sends commands or responses back to your bot. The node-red-contrib-telegrambot node provides two main nodes for this purpose: the receiver node and the sender node. The receiver node listens for messages from your bot and outputs a message object with the following properties: msg.payload.chatId: The chat ID of the sender. msg.payload.type: The type of the message, such as “message”, “photo”, “location”, etc. msg.payload.content: The content of the message, such as a text string, a file ID, or an object with additional data. The sender node takes a message object as input and sends it to your bot. The message object should have the following properties: msg.payload.chatId: The chat ID of the recipient. msg.payload.type: The type of the message, such as “message”, “photo”, “location”, etc. msg.payload.content: The content of the message, such as a text string, a file ID, or an object with additional data. You can use other nodes in between the receiver and sender nodes to process the messages and perform actions on your home automation system. For example, you can use a switch node to route messages based on their type or content, a function node to write custom logic in JavaScript, or an HTTP request node to call external APIs. 3. A little recap of the previous blog: In the previous blog, we have seen how to use the telegram bot with node-red to trigger the temperature data. In this blog, we are going to see how to automate and trigger the Telegram bot to control the GPIO. 4. Telegram to Node-Red: In the last article, we have seen how to trigger the sensor readings from Node-Red to Telegram, now let's see how to trigger and get the sensor data from Telegram Bot. First, we need to use the telegram receiver node. And configure the node with your bot credentials. Then add a debug block. Next, just try to send some messages to your bot and look at the response in the debug console. Now, you can see your texts are coming under payload.content. So, we are going to filter the content then based on the content we are going to trigger the actions. Here are my complete blocks. In this, I have tried to filter the contents as Green, Red, Blue, Off, and Env. Based on the contents we are going to trigger the neo pixels with certain colors. Finally, just deploy the flow, open the telegram bot, and test out the connections. Let's try out the neo pixels. [ { "id": "eb8f9c0d054be30c", "type": "tab", "label": "Flow 2", "disabled": false, "info": "", "env": [] }, { "id": "ea63aa67.c972f", "type": "template", "z": "eb8f9c0d054be30c", "name": "", "field": "payload", "fieldType": "msg", "format": "handlebars", "syntax": "mustache", "template": "{\"chatId\": 5379039379,\n\"type\":\"message\",\n\"content\":\"Temperature : {{payload}}, Humidity : {{humidity}}\"}", "output": "json", "x": 660, "y": 360, "wires": [ [ "9e00d0a7.d5ccf", "600063bd96d765e6" ] ] }, { "id": "9e00d0a7.d5ccf", "type": "debug", "z": "eb8f9c0d054be30c", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 830, "y": 300, "wires": [] }, { "id": "600063bd96d765e6", "type": "telegram sender", "z": "eb8f9c0d054be30c", "name": "roboerto_bot", "bot": "ae1a60539b8e5308", "haserroroutput": true, "outputs": 2, "x": 830, "y": 380, "wires": [ [], [] ] }, { "id": "f2f9819ae972ae60", "type": "rpi-dht22", "z": "eb8f9c0d054be30c", "name": "", "topic": "rpi-dht22", "dht": "11", "pintype": 1, "pin": "7", "x": 500, "y": 380, "wires": [ [ "ea63aa67.c972f" ] ] }, { "id": "e4b8f2dd860a7973", "type": "telegram receiver", "z": "eb8f9c0d054be30c", "name": "", "bot": "ae1a60539b8e5308", "saveDataDir": "", "filterCommands": false, "x": 290, "y": 200, "wires": [ [ "ea58984a24ea493e" ], [] ] }, { "id": "ea58984a24ea493e", "type": "switch", "z": "eb8f9c0d054be30c", "name": "", "property": "payload.content", "propertyType": "msg", "rules": [ { "t": "eq", "v": "Green", "vt": "str" }, { "t": "eq", "v": "Red", "vt": "str" }, { "t": "eq", "v": "Off", "vt": "str" }, { "t": "eq", "v": "Blue", "vt": "str" }, { "t": "eq", "v": "Env", "vt": "str" }, { "t": "eq", "v": "Rainbow", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 6, "x": 450, "y": 140, "wires": [ [ "b410ed94340bb528" ], [ "13aa73e421c429c7" ], [ "4ed36e19be451327" ], [ "db816a1f10392614" ], [ "f2f9819ae972ae60" ], [] ] }, { "id": "b0edb6e1c2807920", "type": "rpi-neopixels", "z": "eb8f9c0d054be30c", "name": "Neo Pixel", "gpio": "18", "pixels": "8", "bgnd": "", "fgnd": "", "wipe": "60", "mode": "pixels", "rgb": "rgb", "brightness": "100", "gamma": true, "x": 660, "y": 100, "wires": [] }, { "id": "13aa73e421c429c7", "type": "function", "z": "eb8f9c0d054be30c", "name": "Red Led", "func": "\nmsg.payload = \"255,0,0\"\nreturn msg;\n\n\n", "outputs": 1, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 660, "y": 200, "wires": [ [ "b0edb6e1c2807920", "0d73aa1efdf96848" ] ] }, { "id": "b410ed94340bb528", "type": "function", "z": "eb8f9c0d054be30c", "name": "Green Led", "func": "\nmsg.payload = \"0,255,0\"\nreturn msg;\n\n\n", "outputs": 1, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 670, "y": 160, "wires": [ [ "b0edb6e1c2807920", "c173db3cc3868fe8" ] ] }, { "id": "4ed36e19be451327", "type": "function", "z": "eb8f9c0d054be30c", "name": "Off", "func": "\nmsg.payload = \"0,0,0\"\nreturn msg;\n\n\n", "outputs": 1, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 650, "y": 240, "wires": [ [ "b0edb6e1c2807920", "02e43d4dd4523371" ] ] }, { "id": "db816a1f10392614", "type": "function", "z": "eb8f9c0d054be30c", "name": "Blue Led", "func": "\nmsg.payload = \"0,0,255\"\nreturn msg;\n\n\n", "outputs": 1, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 660, "y": 280, "wires": [ [ "b0edb6e1c2807920", "15dcd2ff9b951c47" ] ] }, { "id": "c173db3cc3868fe8", "type": "template", "z": "eb8f9c0d054be30c", "name": "", "field": "payload", "fieldType": "msg", "format": "handlebars", "syntax": "mustache", "template": "{\"chatId\": 5379039379,\n\"type\":\"message\",\n\"content\":\"Green LED Triggered\"}", "output": "json", "x": 860, "y": 80, "wires": [ [ "62f3360544d9ca11", "4abe16519bcdcaca" ] ] }, { "id": "62f3360544d9ca11", "type": "debug", "z": "eb8f9c0d054be30c", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 1030, "y": 80, "wires": [] }, { "id": "4abe16519bcdcaca", "type": "telegram sender", "z": "eb8f9c0d054be30c", "name": "roboerto_bot", "bot": "ae1a60539b8e5308", "haserroroutput": true, "outputs": 2, "x": 1030, "y": 120, "wires": [ [], [] ] }, { "id": "0d73aa1efdf96848", "type": "template", "z": "eb8f9c0d054be30c", "name": "", "field": "payload", "fieldType": "msg", "format": "handlebars", "syntax": "mustache", "template": "{\"chatId\": 5379039379,\n\"type\":\"message\",\n\"content\":\"Red LED Triggered\"}", "output": "json", "x": 860, "y": 120, "wires": [ [ "4795fb81ce5c47a6", "12c1a78b02583d94" ] ] }, { "id": "4795fb81ce5c47a6", "type": "debug", "z": "eb8f9c0d054be30c", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 1030, "y": 180, "wires": [] }, { "id": "12c1a78b02583d94", "type": "telegram sender", "z": "eb8f9c0d054be30c", "name": "roboerto_bot", "bot": "ae1a60539b8e5308", "haserroroutput": true, "outputs": 2, "x": 1030, "y": 220, "wires": [ [], [] ] }, { "id": "15dcd2ff9b951c47", "type": "template", "z": "eb8f9c0d054be30c", "name": "", "field": "payload", "fieldType": "msg", "format": "handlebars", "syntax": "mustache", "template": "{\"chatId\": 5379039379,\n\"type\":\"message\",\n\"content\":\"Blue LED Triggered\"}", "output": "json", "x": 860, "y": 160, "wires": [ [ "751fda5416547778", "46ea1f39f11d1b65" ] ] }, { "id": "751fda5416547778", "type": "debug", "z": "eb8f9c0d054be30c", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 1030, "y": 280, "wires": [] }, { "id": "46ea1f39f11d1b65", "type": "telegram sender", "z": "eb8f9c0d054be30c", "name": "roboerto_bot", "bot": "ae1a60539b8e5308", "haserroroutput": true, "outputs": 2, "x": 1030, "y": 320, "wires": [ [], [] ] }, { "id": "02e43d4dd4523371", "type": "template", "z": "eb8f9c0d054be30c", "name": "", "field": "payload", "fieldType": "msg", "format": "handlebars", "syntax": "mustache", "template": "{\"chatId\": 5379039379,\n\"type\":\"message\",\n\"content\":\"LED Off\"}", "output": "json", "x": 860, "y": 220, "wires": [ [ "e9aaa495e9c42799", "0730f1a37c585783" ] ] }, { "id": "e9aaa495e9c42799", "type": "debug", "z": "eb8f9c0d054be30c", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 1030, "y": 380, "wires": [] }, { "id": "0730f1a37c585783", "type": "telegram sender", "z": "eb8f9c0d054be30c", "name": "roboerto_bot", "bot": "ae1a60539b8e5308", "haserroroutput": true, "outputs": 2, "x": 1030, "y": 420, "wires": [ [], [] ] }, { "id": "e30abb1d7e9afcb0", "type": "inject", "z": "eb8f9c0d054be30c", "name": "Green", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 290, "y": 280, "wires": [ [ "b410ed94340bb528" ] ] }, { "id": "4a2a01d9556ad50f", "type": "inject", "z": "eb8f9c0d054be30c", "name": "Blue", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 290, "y": 360, "wires": [ [ "db816a1f10392614" ] ] }, { "id": "3f3ce5ea96251201", "type": "inject", "z": "eb8f9c0d054be30c", "name": "Red", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 290, "y": 320, "wires": [ [ "13aa73e421c429c7" ] ] }, { "id": "3f2c1cebdde09f03", "type": "inject", "z": "eb8f9c0d054be30c", "name": "Off", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 290, "y": 400, "wires": [ [ "4ed36e19be451327" ] ] }, { "id": "26b87a7af5f875cc", "type": "inject", "z": "eb8f9c0d054be30c", "name": "Env", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 290, "y": 440, "wires": [ [ "f2f9819ae972ae60" ] ] }, { "id": "ae1a60539b8e5308", "type": "telegram bot", "botname": "roboerto_bot", "usernames": "", "chatids": "", "baseapiurl": "", "updatemode": "polling", "pollinterval": "300", "usesocks": false, "sockshost": "", "socksprotocol": "socks5", "socksport": "6667", "socksusername": "anonymous", "sockspassword": "", "bothost": "", "botpath": "", "localbotport": "8443", "publicbotport": "8443", "privatekey": "", "certificate": "", "useselfsignedcertificate": false, "sslterminated": false, "verboselogging": false } ] 5. Conclusion: In this blog post, I showed you how to use Telegram bots to control your home automation system with Node-RED. You can use this method to create your own custom interface for your smart home devices and services. You can also extend the functionality of your bot by adding more nodes and logic to your flow. For example, you can use the command node to create custom commands with parameters, the callback query node to handle inline buttons, or the answer inline query node to provide suggestions. You can also use other nodes from the node-red-contrib-telegrambot package or other Node-RED packages to integrate with more Telegram features or other platforms. I hope you enjoyed this tutorial and learned something new. If you have any questions or feedback, please leave a comment below. Happy coding!
-
Communication is great when it's easy and free. Here is the way to setup the popular messenger Telegram on Raspberry Pi
-
- raspbian
- raspberry pi project
-
(and 2 more)
Tagged with: