Introduction: LPG / Biogas Detection System With MediaTek LinKIt One

About: I like to make things more simple with easily available resources. My favorite quote: A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a…

The LinKIt One development platform has been designed and launched by MediaTek Labs with a small footprint, which enables the creation of wearables and IoT devices, with rich connectivity. Instructables HQ have seeded around 250 community members with the LinKIt One board to see what they can make with the board. I am one of those recipients and this is my first project with the board : LPG / Biogas Detection System with MediaTek LinKIt One.

The aim of this project is to 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 to prevent disasters. I have made this project as simple as possible so that anybody can follow and make one at their home.

Step 1: Opening the Box

On opening the LinKIt One box, you will find the following items :

  • LinKIt One Board
  • Battery
  • Micro USB Cable
  • GSM Antenna
  • Wi-Fi + Bluetooth Antenna
  • GPS Antenna
  • LinKIt One board Pinout Diagram
  • A Quick Start Guide

Keep those manuals safely as you may need to refer to them from time to time as the markings on the board can not be clearly read due to its small footprint. The details are also available at MediaTech Labs web site.

Step 2: What You Need for the Gas Detection System

LinKIt One Board with Battery and Micro USB cable : The LinKIt One Board can be powered by a battery as well as through USB by connecting to a computer / Laptop.

Grove Base Shield : Though two numbers of Grove connectors are provided on the board, the Grove Base Shield makes it easier to connect the sensors with LinKIt One. Moreover, the output of the digital pins on LinKIt one is 3.3 volts where as we need 5 volts for the sensors

Grove Gas Sensor MQ5 with connector cable : the Grove Gas Sensor MQ-5 module works on 5 volts and can detect presence of LPG, Methane, Iso-butane, and Propane at the concentration levels between 200 - 10000 ppm. The Gas Sensor consists of circuits to fetch signal as well as heater coil to provide a working environment. The components are enclosed in an Anti-explosion network so that the heater element inside the sensor will not cause an explosion.

Grove Buzzer with connector cable : The grove Buzzer module can be connected to any of the digital connectors on the base shield. Here we will connect to Digital pin D6 on the Base Shield

A suitable plastic case to keep the assembled system : This is optional, but helps to keep every thing tidy and neat inside

Step 3: Setting Up the Board

Detailed instructions are provided to Get Started with the LinKIt One Development Platform at MediaTek Labs web site here :

http://labs.mediatek.com/site/global/developer_too...

Select the versions of Operating Systems you use and also Arduino IDE installed in your system. Follow the instructions to set up the board and the Arduino IDE.

You can download the desired version of Arduino IDE from here :

https://www.arduino.cc/en/Main/Software

After setting up the board and Arduino IDE, please go to the Control Panel / Device Manager menu. If your board is set up correctly, you may find two new ports listed there, "MTK USB Debug Port" and "MTK USB Modem Port". Please not down both the com port numbers. Please see the last picture here for reference.

I have installed MediaTek LinkIt SDK for Arduino 1.1.05 and Arduino 1.5.6 r2 for windows, both of them run without any problem. If you have any doubts or problems, please post a comment here and I will be ready to help to the best of my knowledge.

Step 4: Arduino Code for the System

Here is the code for the gas sensors system which I have developed going through many demo codes and on-line instructions. The code is very easy to understand. you can find description of each line of code alongside after // (couple of forward slashes)

You can copy and paste the code directly in your Arduino IDE. Make sure to select the Board as LinKIt One and Port as the "MTK USB Debug Port" number (Port 33 in my case) you have noted down earlier. You can verify the code and then upload to your Board.

/* 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

}

}

Step 5: Assemble and Test the Code

  • The Grove Base Shield V2 is compatible with LinKIt One Board and will work on 5 volt power supply. You can find the power selector switch on the Base Shield near the Analogue Connector A0. Slide the power selector switch towards 5 Volts. The Grove Base Shield can be directly inserted on the MediaTek LinKIt One Board.
  • Connect the Gas sensor MQ5 to Analog connector A0 on the Base Shield
  • Connect the smaller end of the micro USB cable to the LinKIt One and the other end to computer.
  • Open Arduino and run the Gas Sensor code we have already uploaded to LinKIt One.
  • To monitor the working of the Gas sensor, first you need to select the Port number as that of "MTK USB Modem Port" which you have noted down earlier (mine is port 34).
  • Now open the Serial monitor by clicking on the magnifier at top right of Arduino. You can see Gas sensor readings on the serial monitor. Inside room it shows readings of 63, 64, 65 and so on.

We can not use the buzzer here as the values displayed by the sensor is less than 200.

Step 6: Testing With Gas

  • Disconnect the LinKIt One from the computer and attach the Grove Buzzer module to D6 on the Base Shield with a connector cable
  • Attach the battery and slide the power switch to Battery mode.
  • The buzzer will sound briefly while the board boots up from battery.
  • When the beeping stops, place gas sensor near the Gas stove burner.
  • Slightly open the gas regulator to let gas out and the buzzer will sound alarm

Watch the video to see the testing of gas sensor

Step 7: Install in a Suitable Plastic Case

We can install the entire Gas sensor assembly in a suitable plastic case which will keep everything neat and tidy as well safe from oil fumes during cooking

  • select a suitable plastic case
  • Attach small strips of double sided tape on the bottom metal plate of LinKIt one and attach to the bottom portion of plastic case
  • The battery can be attached to the top cover of plastic case using a strip of double sided tape.
  • Cut and make an opening so that the Sensor cable can be taken out from the box..
  • Switch on the system, close the box. Use couple of rubber bands to attach the Gas sensor to the box.

This system can be placed above the gas stove with suitable holder arrangements.

Step 8: Making Long Sensor Cable

As an afterthought, I decided to make a longer connector cable for gas sensor so that the entire system can be placed safely away from the burners. Only the gas sensor will be placed immediately above the burners.

  • Cut a connector cable in to two halves.
  • Select suitable length of four wires.
  • Strip ends of all wires and connect each end to both the halves of connectors.
  • Test with a Multi Meter that the connection at both ends are correct.
  • You can use Heat shrink tubes and insulation tape to secure the connections.

The last picture shows the gas sensor attached to the system with a long sensor cable.

Step 9: Install Gas Detection System

I have placed the plastic case with LinKIt One and other accessories other than the Gas sensor module on top of the chimney. The gas sensor MQ5 is attached above the burners with the help of the long connector cable.

Step 10: Problem With Battery and Solution

The battery included with the LinKIt One board does not have enough juice to run the system. It hardly lasted for half an hour before the battery went dead. The gas sensor module MQ5 consumes lot of current to keep a heated work environment inside the sensor.

To overcome this problem, I have used a 5 volt power bank to power the LinKIt One board through a micro USB cable. The power bank has an output of 5 volts at 1 Amp and lasted for a day. The four LEDs on the power bank also help us in monitoring the juice left in it. I have cut a hole with a knife (not so pretty) at the side of the plastic case to attach the USB cable to the LinKIt One board.

Step 11: Conclusion

The system is very simple. Hope I have explained everything with easy to understand steps here. Please feel free to post your comments if you need any clarifications or suggestions for improvement.

Epilog Contest VII

Participated in the
Epilog Contest VII