{"id":32752137,"url":"https://github.com/luckyjoy/virtual_sensor_simulation","last_synced_at":"2026-05-15T01:02:34.543Z","repository":{"id":318718229,"uuid":"1074354194","full_name":"luckyjoy/virtual_sensor_simulation","owner":"luckyjoy","description":"Create 100 virtual sensors that the MQTTTransport successfully connects to a MQTT broker.","archived":false,"fork":false,"pushed_at":"2025-10-11T18:54:03.000Z","size":49,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-11T19:02:15.127Z","etag":null,"topics":["asyncio-python","mqtt","mqtt-broker","python3","sensors","simulations"],"latest_commit_sha":null,"homepage":"https://github.com/luckyjoy/virtual_sensor_simulation","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luckyjoy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-11T16:17:34.000Z","updated_at":"2025-10-11T18:54:06.000Z","dependencies_parsed_at":"2025-10-11T19:02:25.519Z","dependency_job_id":"a9c18fa1-1aec-4b19-86aa-4aa9f2610b6e","html_url":"https://github.com/luckyjoy/virtual_sensor_simulation","commit_stats":null,"previous_names":["luckyjoy/virtual_sensor_simulation"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/luckyjoy/virtual_sensor_simulation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckyjoy%2Fvirtual_sensor_simulation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckyjoy%2Fvirtual_sensor_simulation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckyjoy%2Fvirtual_sensor_simulation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckyjoy%2Fvirtual_sensor_simulation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luckyjoy","download_url":"https://codeload.github.com/luckyjoy/virtual_sensor_simulation/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckyjoy%2Fvirtual_sensor_simulation/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33049594,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"online","status_checked_at":"2026-05-14T02:00:06.663Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["asyncio-python","mqtt","mqtt-broker","python3","sensors","simulations"],"created_at":"2025-11-04T00:01:08.547Z","updated_at":"2026-05-15T01:02:34.515Z","avatar_url":"https://github.com/luckyjoy.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🚀 Virtual Sensor Simulator (100+ Sensors)\n\n[![Python](https://img.shields.io/badge/Python-3.9%2B-blue.svg?logo=python)](https://www.python.org/)  \n[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)  \n[![Build](https://img.shields.io/github/actions/workflow/status/luckyjoy/virtual_sensor_simulation/ci.yml?label=CI%2FCD)](https://github.com/luckyjoy/virtual_sensor_simulation/actions)  \n[![Docker](https://img.shields.io/badge/Docker-Ready-blue?logo=docker)](https://hub.docker.com/)  \n[![MQTT](https://img.shields.io/badge/MQTT-Asyncio--MQTT-orange)](https://mqtt.org/)\n\nA high-performance **virtual IoT sensor simulator** built for **embedded systems** and **firmware CI/CD** environments.  \nIt enables **large‑scale load testing**, **data validation**, and **MQTT / HTTP transport** performance benchmarking.\n\n---\n\n## 📘 Overview\n\nThe simulator uses **Python asyncio** to achieve high concurrency, while allowing full configuration of:\n\n- Message rate, jitter, and duration  \n- Sensor payload schemas and noise  \n- Fault injection and recovery  \n- Logging and telemetry analysis  \n\n### 🎯 Primary Goals\n\n- Validate sensor message generation and JSON serialization  \n- Benchmark MQTT and HTTP transports  \n- Assess system throughput (e.g. 100+ msgs/sec)  \n- Provide consistent configuration via CLI or YAML  \n\n---\n\n### ⚙️ Installation\n\n```bash\ngit clone git clone https://github.com/luckyjoy/virtual_sensor_simulation.git\ncd robotics_tdd\npip install -r requirements.txt  # Optional for local testing\n```\n\n---\n\n## 🌐 MQTT Architecture\n\n**MQTT (Message Queuing Telemetry Transport)** is a lightweight pub/sub protocol suited for IoT or constrained / lossy networks.\n\n| Role        | Description                                 |\n|-------------|---------------------------------------------|\n| **Publisher**  | Sends sensor data messages to the broker     |\n| **Subscriber** | Receives messages from broker subscriptions |\n| **Broker**     | Routes messages between publishers \u0026 subscribers |\n\n---\n\n## 🗺️ MQTT Flow Diagram\n\n```mermaid\ngraph TD\n    A[\"Virtual Sensors\"] --\u003e B[\"MQTT Broker (Mosquitto)\"]\n    B --\u003e C[\"Subscribers / Consumers\"]\n    C --\u003e D[\"Data Platform or Dashboard\"]\n```\n\n---\n\n## 📁 Project Structure\n\n```\nvirtual_sensor_simulation/\n├── .github/\n│   └── workflows/\n│       └── ci.yml\n├── sensor_sim/\n│   ├── __init__.py\n│   ├── config.yaml\n│   ├── simulator.py\n│   └── … (other modules, classes, utils, etc.)\n├── Dockerfile\n├── docker-compose.yml\n├── requirements.txt\n├── run_sim.py\n├── .dockerignore\n├── .gitignore\n└── README.md\n```\n\n---\n\n## ⚙️ Features\n\n- 🧩 Async simulation supporting **100–10,000 sensors** (host / network dependent)  \n- 🌐 Two transport modes: *MQTT* (QoS 0 / 1 via `asyncio-mqtt`) or *HTTP* (POST via `aiohttp`)  \n- ⚡ Fully configurable: message rate, jitter, duration, schemas, and fault injection  \n- 🧪 Per-sensor identity: battery models, location, noise profiles  \n- 📊 Optional CSV logging of all emitted messages  \n- 🧘 Graceful shutdown \u0026 built-in backpressure handling  \n- 🧱 CI‑friendly: designed to run in GitHub Actions, Jenkins, or other pipelines  \n\n---\n\n## 🚀 Quick Start\n\n### 1. Create \u0026 activate a Python virtual environment\n\n```bash\npython3 -m venv .venv \u0026\u0026 source .venv/bin/activate\n# On Windows:\npython -m venv .venv \u0026\u0026 .venv\\Scripts\\activate\n```\n\n### 2. Install dependencies\n\n```bash\npip install -r requirements.txt\n```\n\n### 3. Run 100 sensors over MQTT\n\n```bash\npython run_sim.py --count 100 --transport mqtt   --mqtt-host localhost --mqtt-port 1883   --topic-prefix sim/sensors --rate 1.0\n```\n\n### 4. Run over HTTP\n\n```bash\npython run_sim.py --count 100 --transport http   --http-url http://localhost:8080/ingest --rate 1.0\n```\n\n### 5. Use a config file\n\n```bash\npython run_sim.py --config sensor_sim/config.yaml\n```\n\n### 6. Using Docker + Mosquitto\n\n```bash\ndocker compose up --build\n# In another terminal:\ndocker compose run --rm simulator python run_sim.py   --count 100 --transport mqtt --mqtt-host mosquitto --topic-prefix sim/sensors\n```\n\n---\n\n## 🧪 Example Payload\n\n```json\n{\n  \"sensor_id\": \"vs-0042\",\n  \"ts\": \"2025-08-28T21:00:00.123Z\",\n  \"battery_pct\": 92.3,\n  \"temperature_c\": 24.8,\n  \"humidity_pct\": 41.2,\n  \"firmware\": \"1.2.3\",\n  \"status\": \"OK\",\n  \"seq\": 512\n}\n```\n\n---\n\n## 🧱 CI/CD Smoke Test Example\n\nLaunch 20 sensors at 1 Hz for 60 seconds:\n\n```bash\npython run_sim.py --count 20 --duration 60 --rate 1   --transport mqtt --mqtt-host $BROKER_HOST\n```\n\n---\n\n## 🧠 Tips \u0026 Best Practices\n\n- Start small (e.g. 20 sensors) before scaling up.  \n- Use flags like `--drop-rate`, `--spike-rate`, `--fault-every` to simulate edge conditions.  \n- Prefer asyncio concurrency over multiple processes for efficiency.  \n- Monitor CPU, memory, and network utilization at scale.  \n\n---\n\n## 🧩 License \u0026 Contributions\n\nThis project is licensed under the **MIT License**.  \nContributions, issues, and pull requests are welcome — feel free to open discussions or propose enhancements.\n\n---\n\n© 2025 Virtual Sensor Simulator | Maintained by [luckyjoy](https://github.com/luckyjoy)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluckyjoy%2Fvirtual_sensor_simulation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluckyjoy%2Fvirtual_sensor_simulation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluckyjoy%2Fvirtual_sensor_simulation/lists"}