{"id":25972045,"url":"https://github.com/homaei/scada-pi-telegram","last_synced_at":"2026-04-19T02:32:46.426Z","repository":{"id":274775816,"uuid":"924009986","full_name":"Homaei/SCADA-Pi-Telegram","owner":"Homaei","description":"This is a remote monitoring system that integrates a Raspberry Pi, SCADA system, and Telegram bot to enable full-duplex communication for real-time status updates and command execution. The system allows data extraction from PLC-connected SCADA systems in a water treatment plant and transmits it securely to an online database or server.","archived":false,"fork":false,"pushed_at":"2025-03-03T07:46:26.000Z","size":1094,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-03T08:31:30.754Z","etag":null,"topics":["arvr","digitaltwins","raspberry-pi","scada"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Homaei.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-29T08:51:24.000Z","updated_at":"2025-03-03T07:46:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"2525f6b7-69dc-4d4b-953a-e8bc8e7d4202","html_url":"https://github.com/Homaei/SCADA-Pi-Telegram","commit_stats":null,"previous_names":["homaei/scada-pi-telegram"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Homaei%2FSCADA-Pi-Telegram","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Homaei%2FSCADA-Pi-Telegram/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Homaei%2FSCADA-Pi-Telegram/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Homaei%2FSCADA-Pi-Telegram/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Homaei","download_url":"https://codeload.github.com/Homaei/SCADA-Pi-Telegram/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241940870,"owners_count":20045950,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arvr","digitaltwins","raspberry-pi","scada"],"created_at":"2025-03-05T00:18:56.937Z","updated_at":"2026-04-19T02:32:46.381Z","avatar_url":"https://github.com/Homaei.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## 📌 Project Overview  \n**SCADA-PiBot** is a full-duplex monitoring and control system that integrates a **SCADA system, Raspberry Pi, and Telegram bot** to **remotely monitor and manage a water treatment plant**.  \n\nThe system extracts **real-time operational data** from **PLCs** connected to the SCADA system and securely transmits it to an **online database**. A **Cloudflare Tunnel** is used to bypass the lack of a public IP and enable secure remote communication. Additionally, operators can send commands via a **Telegram bot** to interact with the system.  \n\nThe system architecture consists of:  \n- **SCADA System \u0026 PLCs** – The primary automation and data acquisition layer.  \n- **Raspberry Pi** – Acts as an intermediary, collecting SCADA data and handling remote communication.  \n- **Router (SIM-based)** – Connects the system to the internet via a **cellular network**, enabling data transfer.  \n- **Cloudflare Tunnel** – Provides a secure way to access the Raspberry Pi remotely.  \n- **VPS + Grafana** – Stores SCADA logs in a database and visualizes them in real time.  \n- **Telegram Bot** – Allows operators to receive alerts and send remote commands.  \n\n---\n\n## ✨ Key Features  \n✅ **SCADA Data Acquisition** – Extracts real-time data from PLCs using **Modbus**.  \n✅ **Two-Way Telegram Bot Communication** – Sends automated alerts and allows remote system control.  \n✅ **Cloudflare Tunnel for Secure Remote Access** – Eliminates the need for a public IP.  \n✅ **Grafana Integration** – Visualizes data on a **VPS-hosted dashboard**.  \n✅ **Automated Status Updates** – Periodic reports on system health and network status via **crontab**.  \n✅ **Secure Communication** – Prevents unauthorized access using **authentication and encryption**.  \n✅ **Data Logging \u0026 Storage** – Sends SCADA readings to a **remote database** for analysis.  \n✅ **Edge Processing with Raspberry Pi** – Reduces latency by processing alerts locally before sending data.  \n✅ **Router-Based Connectivity** – Uses a **SIM card for internet access**, making it ideal for remote locations.  \n✅ **Scalable \u0026 Modular** – Can be extended to support additional IoT sensors or security features.  \n\n\n\n\n```bash\nSCADA-PiBot/\n│── scripts/\n│   ├── record_data.py        # Logs temperature, humidity, and SCADA parameters\n│   ├── pre_reboot.py         # Saves logs before reboot \u0026 notifies Telegram\n│   ├── post_reboot.py        # Sends notification after reboot\n│   ├── data_collector.py     # Collects SCADA data every 2 hours (based on crontab)\n│   ├── pi_status.py          # Monitors system status \u0026 reports every 6 hours\n│   ├── telegram_bot.py       # Manages Telegram bot interactions\n│   ├── modbus_reader.py      # Extracts PLC data via Modbus protocol\n│   ├── cloudflare_tunnel.py  # Handles secure communication via Cloudflare\n│── crontab_config.txt        # Crontab settings for periodic automation\n│── README.md                 # Project documentation \u0026 setup guide\n│── .gitignore                # Ignore unnecessary files (logs, cache, env, etc.)\n│── config.py                 # Configuration settings (API keys, paths, bot tokens)\n│── SCADA-Pi-Telegram.svg     # System architecture diagram (for README display)\n│── requirements.txt          # Python dependencies for easy setup\n│── LICENSE                   # License details for open-source usage\n```\n\n---\n\n## 📡 System Architecture\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/Homaei/SCADA-Pi-Telegram/raw/main/SCADA-Pi-Tel.webp\" alt=\"SCADA-Pi-Telegram Architecture\"\u003e\n\u003c/p\u003e\n\n\n\n\n---\n\n## ⚙️ Installation \u0026 Setup\n\n### **1. Install Required Packages on Raspberry Pi**\n```bash\nsudo apt update \u0026\u0026 sudo apt upgrade -y\nsudo apt install python3 python3-pip\npip3 install requests telebot flask paho-mqtt\n```\n\n2. Clone the Repository\n```bash\ngit clone https://github.com/Homaei/SCADA-Pi-Telegram.git\ncd SCADA-Pi-Telegram\n```\n\n3. Set Up the Telegram Bot\nCreate a Telegram bot using BotFather.\nGet the API Token and update config.py.\n```bash\nTELEGRAM_BOT_TOKEN = \"your_bot_token\"\nAUTHORIZED_USERS = [\"user_id1\", \"user_id2\"]\n```\n\n4. Set Up Cloudflare Tunnel\nInstall Cloudflare Tunnel on Raspberry Pi:\n```bash\ncurl -fsSL https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-arm -o cloudflared\nchmod +x cloudflared\nsudo mv cloudflared /usr/local/bin\n```\n\nAuthenticate and create a tunnel:\n```bash\ncloudflared tunnel login\ncloudflared tunnel create scada-pibot\n```\nConfigure the tunnel for secure communication.\n\n5. Enable Crontab for Periodic Status Updates\n```bash\ncrontab -e\n```\n\nAdd the following line:\n```bash\n*/5 * * * * python3 /path/to/pi_status.py\n```\n\n🚀 Usage\nStart the Monitoring System\n```bash\npython3 main.py\n```\nInteract with the Telegram Bot\n\n```bash\n+-------------+------------------------------------+\n| Command     | Description                        |\n+-------------+------------------------------------+\n| /status     | Get Raspberry Pi system status     |\n| /scada_data | Fetch latest SCADA readings        |\n| /help       | Show available commands            |\n+-------------+------------------------------------+\n```\n\n🛠 Future Enhancements\n\n🔍 Improve SCADA Data Extraction (Direct Modbus/OPC-UA access).\n\n📡 Optimize Router Configuration (Intercept PLC traffic).\n\n🔐 Enhance Security Measures (VPN-based tunneling).\n\n🗃 Saving data to a PostgreSQL database on a VPS.\n\n📊 Implement Data Visualization via Grafana.\n\n📝 License\nThis project is licensed under the MIT License.\n\n👥 Contributors\n- [Hubert Homaei](https://github.com/homaei) and [Aagustin di Bartolo](https://github.com/Jacklamotta).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhomaei%2Fscada-pi-telegram","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhomaei%2Fscada-pi-telegram","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhomaei%2Fscada-pi-telegram/lists"}