Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/iswarya-singaram/gas_level_monitoring-thingspeak
This system leverages the MQ2 gas sensor and ESP8266 to monitor gas levels, with data visualization available on the ThingSpeak cloud platform.
https://github.com/iswarya-singaram/gas_level_monitoring-thingspeak
esp8266 mq2-gas-sensor thingspeak
Last synced: 2 days ago
JSON representation
This system leverages the MQ2 gas sensor and ESP8266 to monitor gas levels, with data visualization available on the ThingSpeak cloud platform.
- Host: GitHub
- URL: https://github.com/iswarya-singaram/gas_level_monitoring-thingspeak
- Owner: Iswarya-Singaram
- Created: 2024-06-16T09:45:21.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-06-16T11:39:54.000Z (5 months ago)
- Last Synced: 2024-10-17T17:23:40.037Z (20 days ago)
- Topics: esp8266, mq2-gas-sensor, thingspeak
- Homepage:
- Size: 36.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Gas_Level_Monitoring-ThingSpeak
Welcome to the Gas Level Monitoring System project! This system leverages the MQ2 gas sensor and ESP8266 to monitor gas levels, with data visualization available on the ThingSpeak cloud platform. The data from the gas sensor is sent wirelessly to ThingSpeak using the ESP8266, enabling real-time monitoring and analysis of gas levels.
## Overview
This project is designed to provide an easy and efficient way to monitor gas levels in various environments. By using the MQ2 gas sensor, we can detect the presence of gases such as LPG, smoke, alcohol, propane, hydrogen, methane, and carbon monoxide. The ESP8266 Wi-Fi module connects the sensor to the internet, allowing the data to be sent to the ThingSpeak cloud platform where it can be observed and analyzed.
## Features
- Real-Time Monitoring: Continuously monitors gas levels and provides real-time data.
- Wireless Data Transmission: Sends sensor data to the ThingSpeak cloud platform via Wi-Fi.
- Cloud Visualization: Visualize and analyze gas sensor data on ThingSpeak.
## Components
- MQ2 Gas Sensor: Detects various gases and provides an analog signal output.
- ESP8266 Wi-Fi Module: Connects to Wi-Fi and sends data to the cloud.
- ThingSpeak Cloud Platform: Receives and visualizes sensor data.
## Getting Started
To get started with this project, follow the instructions below:
## Hardware Setup
### Connect the MQ2 gas sensor to the ESP8266:
## Software Setup
#### 1.Download the latest Arduino IDE from the official website
~~~
https://www.arduino.cc/en/software
~~~
After installing arduino IDE
#### 2.Configure the ESP8266 Board in Arduino IDE:
- Open Arduino IDE
- Go to File > Preferences.
- In the Additional Board Manager URLs field, add the following URL:
- Go to Tools > Board > Boards Manager.
- Search for esp8266 and install the ESP8266 package.
~~~
http://arduino.esp8266.com/stable/package_esp8266com_index.json
~~~
Note: In the Arduino IDE, Board Manager URLs are used to specify the location of additional hardware definitions for boards that are not included by default in the IDE. These URLs point to JSON files that contain metadata and links to the necessary files for supporting additional microcontroller boards.
#### 3.Setting up ThingSpeak
1.Create a ThingSpeak account at
~~~
https://thingspeak.com
~~~
2. Create a new channel and add a field for the gas sensor data.
3. Note the Write API Key from the API Keys tab.
4. Update your Arduino sketch with the API Key in the following source code.
~~~
#include
const char* ssid = "YOUR_WIFI_SSID";
const char* password = "YOUR_WIFI_PASSWORD";
const char* thingspeakServer = "api.thingspeak.com";
const int thingspeakAPIKey = YOUR_THINGSPEAK_API_KEY;
const int thingspeakChannelID = YOUR_THINGSPEAK_CHANNEL_ID;
const int gasSensorPin = A0; // Adjust based on your sensor's analog pin connection
WiFiClient client;
void setup() {
Serial.begin(115200);
Serial.println("Connecting to WiFi");
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
}
void loop() {
// Read analog value from gas sensor
int sensorValue = analogRead(gasSensorPin);
// Convert sensor value to a meaningful unit (adjust based on sensor datasheet)
// This example assumes a linear relationship between sensor value and gas concentration (replace with your sensor's conversion method)
float gasConcentration = sensorValue * 5.0 / 1023.0; // Assuming 0-5V sensor output
// Prepare HTTP request to Thingspeak
String dataString = "api_key=" + String(thingspeakAPIKey) + "&field1=" + String(gasConcentration);
Serial.print("Connecting to Thingspeak...");
if (connectToThingspeak()) {
Serial.println("Connected!");
client.print("POST /update HTTP/1.1\n");
client.print("Host: " thingspeakServer "\n");
client.print("Content-Type: application/x-www-form-urlencoded\n");
client.print("Connection: close\n");
client.print("Content-Length: ");
client.print(dataString.length());
client.println("\n");
client.println(dataString);
delay(1000); // Wait for Thingspeak to process data
} else {
Serial.println("Connection failed!");
}
client.stop();
delay(10000); // Adjust delay between readings as needed
}
boolean connectToThingspeak() {
if (!client.connected()) {
Serial.print("Connecting to server: ");
Serial.println(thingspeakServer);
if (client.connect(thingspeakServer, 80)) {
return true;
} else {
return false;
}
}
return true;
}
~~~
#### 4.Upload the code to your ESP8266:
1.Select Tools > Board > NodeMCU 1.0 (ESP-12E Module).
2.Select the appropriate Port.
3.Click the Upload button.
Once the setup is complete, the ESP8266 will connect to your Wi-Fi network and start sending gas sensor data to ThingSpeak. You can visualize the data on your ThingSpeak channel.
## Contributing
Contributions are welcome! If you have any ideas for improvements or encounter any issues, feel free to open an issue or submit a pull request.