Antoni Raj
Published © GPL3+

LPG / Biogas Detection System With MediaTek LinKIt One

Use the LinKIt One to detect leakage of LPG / Biogas in the kitchen and sound an alarm so that necessary measures can be taken in time.

BeginnerFull instructions provided755
LPG / Biogas Detection System With MediaTek LinKIt One

Things used in this project

Story

Read more

Code

Code

C/C++
/* Gas Sensor MQ 5 with LinkIt One to detect LPG / Biogas Leakage
* Grove Buzzer will sound alarm when gas leakage is detected
*/
int buzzer = 6; // 'Buzzer' will be connected to D6 using Grove Base Shield
int sensor = A0; // Gas Sensor MQ 5 will be connected to Analog pin 0
int sensorValue = 0; // The initial gas sensor value will be set to 0

// The setup routine runs once when you press reset
void setup() {
  pinMode(buzzer, OUTPUT); // Initialize the digital pin 6 as buzzer output
  Serial.begin(9600); // Initialize serial communication at 9600 bits per second
}

// The loop routine runs over and over again forever
void loop() {
  sensorValue = analogRead(sensor); // Read the input on analog pin 0 ('sensor')
  Serial.println(sensorValue, DEC); // Print out the value on serial monitor
  if (sensorValue > 200) { // If sensorValue is greater than 200
    digitalWrite(buzzer, HIGH); // Activate digital output buzzer and sound alarm
  }
  else {
    digitalWrite(buzzer, LOW); // Deactivate buzzer - the buzzer will not sound
  }
}

Credits

Antoni Raj

Antoni Raj

3 projects • 7 followers
Retired Civil Engineer spending my spare time building projects

Comments