What is a MQ5 sensor?
The Grove – Gas Sensor (MQ5) module is useful for gas leakage detection (in home and industry). It is suitable for detecting H2, LPG, CH4, CO, Alcohol. Due to its high sensitivity and fast response time, measurements can be taken as soon as possible.
And, how does it work?
The MQ series of gas sensors use a small heater inside with an electro-chemical sensor. They are sensitive for a range of gasses and are used indoors at room temperature.
They can be calibrated more or less (see the section about “Load-resistor” and “Burn-in”) but a known concentration of the measured gas or gasses is needed for that.
Now, what is IOT?
The Internet of Things (IoT) is a system of interrelated computing devices, mechanical and digital machines, objects, animals or people that are provided with unique identifiers and the ability to transfer data over a network without requiring human-to-human or human-to-computer interaction.
ThingSpeak
ThingSpeak is an IoT platform that enables you to collect, store, analyse, visualize, and act on data from sensors or actuators, such as Arduino, Raspberry Pi, BeagleBone Black, and other hardware.
The core element of ThingSpeak is a ‘ThingSpeak Channel’. A channel stores the data that we send to ThingSpeak and comprises of the below elements:
- 8 fields for storing data of any type – These can be used to store the data from a sensor or from an embedded device.
- 3 location fields – Can be used to store the latitude, longitude and the elevation. These are very useful for tracking a moving device.
- 1 status field – A short message to describe the data stored in the channel.
To use ThingSpeak, we need to sign up and create a channel. Once we have a channel, we can send the data, allow ThingSpeak to process it and also retrieve the same. Let us start exploring ThingSpeak by signing up and setting up a channel.
MATERIALS REQUIRED
Arduino Uno board
Arduino Ethernet Shield
Ethernet cable
USB cable
PIR Motion Sensor
Jumper Wires
So, What are we doing here?
In this project, we interface a MQ-5 Gas sensor to an Arduino Ethernet Shield which in turn is connected to an Arduino Board.
After this we upload the Arduino code and send the values to Thingspeak.
Our aim is to analyse the data sent by Arduino in Thingspeak, So when there is no gas leak, a certain value(0-1023) will be read by the analog pin which in turn is converted to the corresponding voltage(0-5V) which will be recorded in ThingSpeak and then plotted. Similarly when there is a gas leak the voltage reading changes. This also is recorded in ThingSpeak and a graph is plotted using the same for easy understanding of the data.
Circuit Diagram!
Wire up and upload the given code below!
Also remember to download the latest version of ThinkSpeak library and add it to your previously existing libraries.
#include "ThingSpeak.h"
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
EthernetClient client;
unsigned long myChannelNumber = 128887;
const char * myWriteAPIKey = "EO8WR8LTRQ4PJNXW";
#define VOLTAGE_MAX 5.0
#define VOLTAGE_MAXCOUNTS 1023.0
void setup() {
Serial.begin(9600);
Ethernet.begin(mac);
ThingSpeak.begin(client);
}
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Convert the analog reading
// On Arduino: 0 - 1023 maps to 0 - 5 volts
// On ESP8266: 0 - 1023 maps to 0 - 1 volts
// On Particle: 0 - 4095 maps to 0 - 3.3 volts
float voltage = sensorValue * (VOLTAGE_MAX / VOLTAGE_MAXCOUNTS);
Serial.print(voltage);
Serial.println();
ThingSpeak.writeField(myChannelNumber, 1, voltage, myWriteAPIKey);
delay(20000); // ThingSpeak will only accept updates every 15 seconds.
}
So, Once you are done uploading you can observe your results directly on ThinkSpeak albeit with a delay of about 15 seconds. ( If you want very minimal delay there are multiple paid cloud servers that you can opt for, and ThinkSpeak is free)
No comments:
Post a Comment