{"id":28171028,"url":"https://github.com/arkadip2007/gas-sensor-iot","last_synced_at":"2025-06-29T22:34:36.607Z","repository":{"id":285523848,"uuid":"958421364","full_name":"Arkadip2007/gas-sensor-iot","owner":"Arkadip2007","description":"gas-sensor-iot","archived":false,"fork":false,"pushed_at":"2025-04-01T11:07:06.000Z","size":33,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-15T18:15:44.892Z","etag":null,"topics":["gas-sensor-iot","iot"],"latest_commit_sha":null,"homepage":"","language":"C++","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/Arkadip2007.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}},"created_at":"2025-04-01T07:07:59.000Z","updated_at":"2025-04-01T11:07:09.000Z","dependencies_parsed_at":"2025-04-01T08:33:29.051Z","dependency_job_id":"be7ad92e-fbab-41e4-bb3b-b3437cbde1ae","html_url":"https://github.com/Arkadip2007/gas-sensor-iot","commit_stats":null,"previous_names":["arkadip2007/gas-sensor-iot"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Arkadip2007/gas-sensor-iot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arkadip2007%2Fgas-sensor-iot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arkadip2007%2Fgas-sensor-iot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arkadip2007%2Fgas-sensor-iot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arkadip2007%2Fgas-sensor-iot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Arkadip2007","download_url":"https://codeload.github.com/Arkadip2007/gas-sensor-iot/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arkadip2007%2Fgas-sensor-iot/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262678765,"owners_count":23347418,"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":["gas-sensor-iot","iot"],"created_at":"2025-05-15T18:15:47.429Z","updated_at":"2025-06-29T22:34:36.536Z","avatar_url":"https://github.com/Arkadip2007.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gas-sensor : **MQ-5**, which is used to detect **Natural Gas, LPG, Coal Gas, and Methane (CH4)**.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/user-attachments/assets/8c88f6e2-da76-450e-9b22-146384c38860\" alt=\"Image 1\" width=\"46%\" style=\"margin-right: 10px;\"/\u003e\n  \u003cimg src=\"https://github.com/user-attachments/assets/070cae4e-8c13-49db-8e65-6c502084ed14\" alt=\"Image 2\" width=\"46%\" style=\"margin-right: 10px;\"/\u003e\n  \u003c/br\u003e\n  \u003cimg src=\"https://github.com/user-attachments/assets/9978502d-1cb4-4b93-8705-b2094268ac38\" alt=\"Image 1\" width=\"46%\" style=\"margin-right: 10px;\"/\u003e\n  \u003cimg src=\"https://github.com/user-attachments/assets/7193adff-664c-4704-8f98-dc999653d9cd\" alt=\"Image 2\" width=\"46%\" style=\"margin-right: 10px;\"/\u003e\n\u003c/p\u003e\n\n---\n\n### **🛠️ Components Required:**  \n- **MQ-5 Gas Sensor**  \n- **Arduino Uno** (or NANO) \n- **Jumper Wires**  \n- **Power Supply (5V from Arduino)**  \n\n---\n\n### **🔌 Wiring Connections:**  \n\n| **MQ-5 Sensor Pin** | **Arduino Pin** |  \n|--------------------|---------------|  \n| **VCC**           | **5V**         |  \n| **GND**           | **GND**        |  \n| **A0 (Analog Output)** | **A0**         |  \n| **D0 (Digital Output, Optional)** | **D7** (if needed) |  \n\n---\n\n### Code --\u003e\n\n```cpp\nint gasSensorPin = A0;  // Analog pin connected to MQ-5\nint digitalPin = 7;     // Digital pin (optional)\nint sensorValue;\nint threshold = 400;    // Set a reasonable threshold\n\nvoid setup() {\n  Serial.begin(9600);\n  pinMode(digitalPin, INPUT);\n  \n  Serial.println(\"MQ-5 Gas Sensor Test\");\n  Serial.println(\"Warming up... Please wait 2-3 minutes.\");\n  delay(3000);  // Allow sensor to stabilize (increase to 2-3 min for real use)\n}\n\nvoid loop() {\n  sensorValue = analogRead(gasSensorPin);\n  Serial.print(\"Gas Level (Analog): \");\n  Serial.println(sensorValue);\n  \n  if (sensorValue \u003e threshold) {  // Use a stable threshold\n    Serial.println(\"🚨 Gas detected!\");\n  } else {\n    Serial.println(\"✅ No gas detected.\");\n  }\n\n  delay(2000);  // Increase delay for more stable readings\n}\n```\n\n[\u003cimg align=\"right\" alt=\"servo\" width=\"300\" src=\"https://github.com/user-attachments/assets/2b8eeee4-d67a-4e69-8d25-24c1e578f5e1\"\u003e](https://www.linkedin.com/posts/arkadip2008_gas-detection-system-activity-7312738420567535616--Y2n)\n\n\n### Output \u0026 Video\n\n```go\n✅ No gas detected.\nGas Level (Analog): 117\n✅ No gas detected.\nGas Level (Analog): 247\n✅ No gas detected.\nGas Level (Analog): 738\n🚨 Gas detected!\nGas Level (Analog): 762\n🚨 Gas detected!\nGas Level (Analog): 687\n🚨 Gas detected!\nGas Level (Analog): 132\n✅ No gas detected.\nGas Level (Analog): 104\n✅ No gas detected.\nGas Level (Analog): 88\n✅ No gas detected.\nGas Level (Analog): 57\n✅ No gas detected.\nGas Level (Analog): 47\n✅ No gas detected.\nGas Level (Analog): 50\n✅ No gas detected.\nGas Level (Analog): 50\n✅ No gas detected.\nGas Level (Analog): 569\n🚨 Gas detected!\nGas Level (Analog): 142\n✅ No gas detected.\nGas Level (Analog): 61\n```\n\n---\n\n# add Display 📟\n\n---\n\n\u003cdetails\u003e\n  \u003csummary style=\"opacity: 0.85;\"\u003e\u003cb\u003e✅📟 LED Display Check\u003c/b\u003e\u003c/summary\u003e\u003cbr\u003e\n  \u003c!-- \u003cdiv style=\"display: flex; align-items: center; gap: 10px;\" align=\"center\"\u003e --\u003e\n\n![Screenshot (256)](https://github.com/user-attachments/assets/29ec3e39-5bb3-4fa1-a841-228fd8d5b1af)\n\n\u003cimg align=\"right\" alt=\"servo\" width=\"45%\" src=\"https://github.com/user-attachments/assets/a57d6876-6cf3-43a0-a774-8a33723bf9ea\"\u003e\n\n## Check the Display working or Not?\n\n```cpp\n//YWROBOT\n//Compatible with the Arduino IDE 1.0\n//Library version:1.1\n#include \u003cWire.h\u003e \n#include \u003cLiquidCrystal_I2C.h\u003e\n\nLiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x27 for a 16 chars and 2 line display\n\nvoid setup()\n{\n  lcd.init();                      // initialize the lcd \n  lcd.init();\n  // Print a message to the LCD.\n  lcd.backlight();\n  lcd.setCursor(3,0);\n  lcd.print(\"Hello, world!\");\n  lcd.setCursor(2,1);\n  lcd.print(\"I am ARKADIP\");\n   lcd.setCursor(0,2);\n  lcd.print(\"MAHAPATRA\");\n   lcd.setCursor(2,3);\n  lcd.print(\"04 MARCH, 2025\");\n}\n\n\nvoid loop()\n{\n}\n```\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/user-attachments/assets/e649d1b7-9742-471b-b64e-d0848bd303ad\" alt=\"Image 1\" width=\"46%\" style=\"margin-right: 10px;\"/\u003e\n  \u003cimg src=\"https://github.com/user-attachments/assets/5a671c34-e5a5-4461-ac0c-20c3e398c184\" alt=\"Image 2\" width=\"46%\" style=\"margin-right: 10px;\"/\u003e\n\u003c/p\u003e\n\n| 👆 [More ways to Text in LCD display](https://github.com/Arkadip2007/LCD-iot/blob/main/README.md) |\n| --- |\n\n\u003c/details\u003e\n\n---\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/user-attachments/assets/be92dc37-b063-4132-a6e0-58af4cd97594\" alt=\"Image 1\" width=\"46%\" style=\"margin-right: 10px;\"/\u003e\n  \u003cimg src=\"https://github.com/user-attachments/assets/bd0f90eb-67af-4784-8921-d57b3de495c7\" alt=\"Image 2\" width=\"46%\" style=\"margin-right: 10px;\"/\u003e\n\u003c/p\u003e\n\nAdd a **JHD162A (16x2 LCD) with an I2C module** to display **live gas levels** from MQ-5  Gass sensor.  \n\n---\n\n### **🛠️ Components Required:**  \n- **Arduino Uno/Nano**  \n- **MQ-5 Gas Sensor**  \n- **JHD162A (16x2 LCD) with I2C Module**  \n- **Jumper Wires**  \n\n---\n\n### **🔌 Connections:**  \n\n| **Component** | **Arduino Pin** |  \n|-------------|---------------|  \n| **MQ-5 VCC** | **5V** |  \n| **MQ-5 GND** | **GND** |  \n| **MQ-5 A0** | **A0** |  \n| **I2C LCD VCC** | **5V** |  \n| **I2C LCD GND** | **GND** |  \n| **I2C LCD SDA** | **A4 (SDA)** |  \n| **I2C LCD SCL** | **A5 (SCL)** |  \n\n---\n\n### **📜 Arduino Code with I2C LCD Display**  \n\n## ❌ Code 01 with LCD\n\n```cpp\n#include \u003cWire.h\u003e\n#include \u003cLiquidCrystal_I2C.h\u003e\n\n// LCD setup (default I2C address 0x27 or 0x3F)\nLiquidCrystal_I2C lcd(0x27, 16, 2);  \n\nint gasSensorPin = A0;  // MQ-5 Analog Output\nint threshold = 400;    // Gas detection threshold\n\nvoid setup() {\n  Serial.begin(9600);\n  lcd.begin(16, 2); // Initialize the LCD with 16 columns and 2 rows\n  lcd.backlight();  // Turn on LCD backlight\n\n  Serial.println(\"MQ-5 Gas Sensor Test\");\n  lcd.setCursor(0, 0);\n  lcd.print(\"MQ-5 Sensor Test\");\n  lcd.setCursor(0, 1);\n  lcd.print(\"Warming up...\");\n  delay(3000);  // Warm-up time\n}\n\nvoid loop() {\n  int sensorValue = analogRead(gasSensorPin);\n  \n  // Print values to Serial Monitor\n  Serial.print(\"Gas Level: \");\n  Serial.println(sensorValue);\n\n  // Display gas level on LCD\n  lcd.clear();\n  lcd.setCursor(0, 0);\n  lcd.print(\"Gas Level: \");\n  lcd.print(sensorValue);\n  \n  // Gas detection message\n  lcd.setCursor(0, 1);\n  if (sensorValue \u003e threshold) {\n    Serial.println(\"🚨 Gas Detected!\");\n    lcd.print(\"🚨 Gas Detected!\");\n  } else {\n    Serial.println(\"✅ Safe\");\n    lcd.print(\"✅ Safe\");\n  }\n\n  delay(2000);  // Delay for stability\n}\n```\n\n---\n\n### **🛠️ How It Works ?**  \n- The **gas level is displayed live** on the LCD screen.  \n- If gas exceeds the **threshold (400)**, it shows **\"🚨 Gas Detected!\"**.  \n- If the environment is **safe**, it shows **\"✅ Safe\"**.  \n- The Serial Monitor also prints the same information.  \n\n---\n\n### **📟 LCD Display Output:**  \n#### **Normal Air (Safe Condition)**  \n```\nGas Level: 180  \n✅ Safe  \n```\n#### **When Gas is Detected (Lighter near sensor)**  \n```\nGas Level: 650  \n🚨 Gas Detected!  \n```\n\n---\n\n### **🔹 Points to know:**  \n- If the LCD **doesn’t display** anything, try changing `0x27` to `0x3F` in `LiquidCrystal_I2C lcd(0x27, 16, 2);`.  \n- The **threshold (`400`)** can be adjusted based on your sensor's response.  \n- Always give the sensor **2-3 minutes of warm-up** for accurate readings.  \n\n---\n\n# ❌ code 02 with LCD\n\n```cpp\n#include \u003cWire.h\u003e\n#include \u003cLiquidCrystal_I2C.h\u003e\n\n// Initialize LCD with I2C address (Change 0x27 to 0x3F if needed)\nLiquidCrystal_I2C lcd(0x27, 16, 2);\n\nint gasSensorPin = A0;  // MQ-5 Analog Output\nint threshold = 400;    // Gas detection threshold\n\nvoid setup() {\n  Serial.begin(9600);    // Initialize serial communication at 9600 baud rate\n  lcd.begin(16, 2);      // Initialize LCD with 16 columns and 2 rows\n  lcd.backlight();       // Turn on LCD backlight\n\n  Serial.println(\"MQ-5 Gas Sensor Test\");\n  lcd.setCursor(0, 0);\n  lcd.print(\"MQ-5 Sensor Test\");\n\n  delay(5000);  // Warm-up time for MQ-5 sensor\n  lcd.clear();\n}\n\nvoid loop() {\n  int sensorValue = analogRead(gasSensorPin);  // Read the value from the gas sensor\n  \n  // Print values to Serial Monitor for debugging\n  Serial.print(\"Gas Level: \");\n  Serial.println(sensorValue);\n\n  // Display gas status on LCD\n  lcd.clear();  // Clear the LCD screen before printing new data\n  lcd.setCursor(0, 0);  // Set cursor to the first column of the first row\n  lcd.print(\"Gas Status:\");  // Display static text\n\n  lcd.setCursor(0, 1);  // Move cursor to the first column of the second row\n  if (sensorValue \u003e threshold) {  // Check if gas level exceeds the threshold\n    Serial.println(\"🚨 GAS DETECTED!\");\n    lcd.print(\"🚨 GAS DETECTED!\");  // Display gas detected message\n  } else {\n    Serial.println(\"✅ SAFE\");\n    lcd.print(\"✅ SAFE\");  // Display safe message\n  }\n\n  delay(2000);  // Delay for stability before taking another reading\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farkadip2007%2Fgas-sensor-iot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farkadip2007%2Fgas-sensor-iot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farkadip2007%2Fgas-sensor-iot/lists"}