Introduction: Gas Leak and High Temperatures Detector

About: The Tutorial Education Program is an honors program for Brazilian undergraduates, sponsored by the Ministry of Education. Based on philosophical principles of tutorial education in which small groups of academ…

The project was made with the intention of being used at home, being a simple gas leak and high temperatures detector that uses ESP-01 and sends an alert by the IFTTT to your phone.

Step 1: Components

For the project the following items will be used:

  • 1 ESP-011
  • Gas Sensor mq-91
  • Temperature Sensor dht-111
  • Voltage Calculator ams1117 (5v to 3,3v)

All of these materials can be found easily on the internet. If the idea is to do this project as soon as possible, it is recommended to buy the items on the "Mercado Livre" website (if you're in Brazil), since it is safe, fast (about 1 week or 2 the items arrive at the destination) and cheaper than in conventional stores. However, if the project is not in a hurry, it is much cheaper to buy items abroad such as Ebay, Aliexpress, etc. But there is no guarantee of when and if the product will arrive at its destination.

Step 2: Hardware - Setting Up the Circuit

The circuit schematic can be found and downloaded on the file Detector_Vazamento_Gas.fzz down below, we used the a program called Fritzing to create the schematic, and to comprehend the connections on the protoboard. Set it up on a protoboard to test it and if everything works correctly make a PCB board for your circuit.

Step 3: Software - Downloading the Code

The code can be downloaded in the file below or in the following link: https://github.com/andreocunha/Detector_Vazamento_Gas_ESP-01_IFTTT

Download the Arduino IDE on your computer to upload the code to ESP-01.

Step 4: Software - Explanation of the Code (Sensors Operation)

First, let's explain how the temperature sensor and gas sensor work. All the code that involves the sensors is inside the void loop(), which will trigger functions to send messages to your cell phone with the help of IFTTT. Within this same fragment of the code, the measurements are made by the sensors and evaluated in the program itself, telling whether or not the environment is in danger or at risk of fire.

For the gas sensor, since the ESP8266-01 has only digital ports, we had to use the values HIGH and LOW, representing that when the voltage is high the air is normalized, with the voltage low, there is a high amount of gases flammable in the environment, and then, using the sendAlarmGas() function, sends a message to your phone. In addition, it is possible to see the values being read by the analog port, activating or not the function. And for the temperature sensor, which is measured at each loop, we did an if() so if the temperature is higher than 40º C, activate the sendAlarmFogo() function that will send a message alerting the temperature increased.

Step 5: Software - Explanation of the Code (IFTTT)

Using the "webhooks" functionality, present at https://ifttt.com/maker_webhooks, we created a trigger capable of triggering a web request that sends us, by message, certain information. In our case, this information will be a high rise in the ambient temperature, indicating a fire or a warning about the detection of gas, which may come from a leak. The tutorial to create this trigger is at the following link: https://github.com/andreocunha/Detector_Vazamento_Gas_ESP-01_IFTTT

For this trigger to work, you must first connect the ESP-01 to your wi-fi network. Such configuration is done in the void setup () function. The activation of this trigger is within the sendAlarmFogo () and sendAlarmGas () functions. You can check these features in the code snippets above.

Step 6: Printed Circuit Board (PCB)

If everything went well so far, make a PCB board (we usually use the software EAGLE CAD to make it) and then, weld the components. The circuit will look like the one shown on the picture above.

Step 7: The Project Working

Watch the video of the final demonstration of the project.

Step 8: Project's License

This work is licensed with the License Creative Commons Atribuição 4.0 Internacional.