Introduction: Tutorial on How to Make a Smoke Detection System Using Intel Galileo Gen2.

In this project, we will go over how to build a smoke sensor

circuit with an Intel Galileo Gen2 board among a little more devices.

We will use the MQ2 smoke sensor in this case because it is sensible to both smoke and flammable gas.

The MQ2 smoke works in the following way:

The MQ-2 smoke sensor reports smoke by the voltage level that it outputs. The more smoke there is, the greater the voltage that it outputs. Conversely, the less smoke that it is exposed to, the less voltage it outputs.

The MQ-2 also has a built-in potentiometer to adjust the sensitivity to smoke. By adjusting the potentiometer, you can change how sensitive it is to smoke, so it's a form of calibrating it to adjust how much voltage it will put out in relation to the smoke it is exposed to.

We will wire the MQ-2 to an Intel Galileo Gen2 board so that that it can read the amount of voltage output by the sensor and sound a buzzer if the sensor outputs a voltage above a certain threshold. This way, we will know that the sensor is detecting smoke and we will sound a buzzer alerting a person such as a homeowner to this fact.

Step 1: Components Required to Set Up the Smoke Detection System.

MQ-2

Smoke Sensor. Intel Galileo Gen2 board. Buzzer.

The MQ-2 sensor is a very cheap device available at e-bay ranging from $2 to $3. Cheap right?

Important, it is recommended that you do not obtain the standalone sensor but the whole MQ-2 board. This is because if you buy the standalone sensor, you will have to finish building the whole schematic before you can connect it to the Galileo board. So that less work is required for integrating this with the Galileo board, it is recommended that you buy the complete MQ-2 sensor circuit. This you can see below.

If you buy the complete board, there are 3 leads which need to be connected.

Step 2: MQ-2 Smoke Sensor Circuit Schematic

The red wire and the black wire buzzer will be connected to

pin digital 12 and pin ground of the Galileo board.

So to power the smoke sensor, we connect analog output pin 2 of the smoke sensor to the 5V terminal of the Galileo board and terminal 3 to the GND terminal of the board. This gives the smoke sensor the 5 volts it needs to be powered.

The output of the sensor goes into analog pin A0 of the board. Through this connection, the Galileo can read the analog voltage output from the sensor. The board has a built-in analog-to-digital converter, so it is able to read analog values without any external ADC chip.

Depending on the value that the Galileo reads determines the action that will occur with the circuit. We will make it in our code that if the sensor outputs a voltage above a certain threshold, the buzzer will go off, alerting a user that smoke has been detected.

Step 3: Writing the Code

We need to write the code so that the whole thing can work.
There are a few software available to write the necessary code for making the board run including but not limited to: Atmel Studio, Arduino IDE and Visual studio. I used the more popular Arduino IDE.

Step 1. Connect your Galileo board to power supply and connect it to your pc via USB.

Step 2. Open the Arduino IDE and make a new project.

Step 3. Go to tools option and choose Intel Galileo. If you can’t find that option select boards manager.

Step 4. Paste the following code into your project page.

/*Code for MQ-2 Smoke Sensor Circuit Built with an Galileo Board*/<br>
const int sensorPin= 0;
const int buzzerPin= 12;
int smoke_level;
void setup() {
Serial.begin(115200); //sets the baud rate for data transfer in bits/second
pinMode(sensorPin, INPUT);//the smoke sensor will be an input to the galileo
pinMode(buzzerPin, OUTPUT);//the buzzer serves an output in the circuit
}
void loop() {
smoke_level= analogRead(sensorPin); //arduino reads the value from the smoke sensor
Serial.println(smoke_level);//prints just for debugging purposes, to see what values the sensor is picking up
if(smoke_level > 200){ //if smoke level is greater than 200, the buzzer will go off
digitalWrite(buzzerPin, HIGH);
}
else{
digitalWrite(buzzerPin, LOW);
}

}
<p>Step 5. Go to the sketch option and click verify.</p><p>Step 6. Go to sketch option again and select upload.</p><p>Your device is now ready to test and run.</p>