Connect Gas Sensor With Bluetooth Using Arduino Mega 2560

Introduction

  • In this article, I will explain about connecting the Gas Sensor to the Bluetooth.
  • When the gas is leaked, it can automatically send the message to the app.
  • We can control the gas leakage in the house.
Parts Of Lists
  • Arduino Mega 2560
  • Bluetooth
  • Gas Sensor
  • Bread Board
  • Hook Up wires
Connection
 
Step 1
 
Connection from Arduino Board to the Bluetooth.
 
Bluetooth Board
Vcc 5v
Gnd Gnd
RX TX
TX RX
 
Step 2
 
Connection from Arduino Board to the Sensor.
 
Sensor Board
Vcc 5v
Gnd Gnd
Vin A0
 
Programming
  1. const int AOUTpin = 0; //the AOUT pin of the CO sensor goes into analog pin A0 of the arduino      
  2. const int DOUTpin = 8; //the DOUT pin of the CO sensor goes into digital pin D8 of the arduino       
  3. const int ledPin = 13; //the anode of the LED connects to digital pin D13 of the arduino      
  4. int limit;    
  5. int value;    
  6. void setup()    
  7. {    
  8.     Serial.begin(9600);    
  9.     //sets the baud rate pinMode(DOUTpin, INPUT);      
  10.     //sets the pin as an input to the arduino pinMode(ledPin, OUTPUT);      
  11.     //sets the pin as an output of the arduino      
  12. }    
  13. void loop()    
  14. {    
  15.     value = analogRead(AOUTpin); //reads the analaog value from the CO sensor's AOUT pin       
  16.     limit = digitalRead(DOUTpin); //reads the digital value from the CO sensor's DOUT pin       
  17.     Serial.print("CO value: ");    
  18.     Serial.println(value); //prints the CO value       
  19.     Serial.print("Limit: ");    
  20.     Serial.print(limit); //prints the limit reached as either LOW or HIGH (above or underneath)       
  21.     delay(100);    
  22.     if (limit == HIGH)    
  23.     {    
  24.         Serial.println("Bad");    
  25.     }    
  26.     else    
  27.     {    
  28.         Serial.println("OK");    
  29.     }    
  30. }   
Explanation
  • We have to build the App in the App inverter
  • They can show the Gas level in the App
  • When the gas is leaked, it can be used to control the gas level through the App
  • When the gas is leaked, it can be printed in the Serial monitor as Bad.