ESP8266

Firebase Project using ESP8266, MQ3 Sensor, & Flame Sensor

Firebase and ESP8266:

 

Firebase Project using ESP8266, MQ3 Sensor, & Flame Sensor– In today’s article, you will learn how to use Google Firebase with ESP8266 for sensor monitoring. For demonstration purposes, I will be using the MQ3 Gas Sensor module and a Flame Sensor.

Before starting this project, there are some important things that I want to share with you. About 2 years ago I made 4 videos related to Google Firebase, which people liked a lot. I used Firebase with ESP8266 for sensor monitoring and I also did the same project using ESP32 WiFi + Bluetooth Module.

allpcb circuit

Apart from this, I also designed my own Android application for Firebase Database, in which, I monitored the DHT11 Temperature and Humidity sensor.

And in the 4th video, I again used Google Firebase at a slightly more complex level. In which I created a complete student attendance system using Firebase.

Now you guys must be thinking that if I have already made basic and advanced level projects on Google Firebase, then why am I making a basic video again today.

Well, the videos that I just mentioned, I made these videos 2 years ago. 2 years is a long time. In the meantime, there have been some updates in the firebase libraries, due to which you may face some difficulties in following the previous videos.

It’s not that those projects are useless, if you guys update the firebase library, all your issues will be gone. Today I am going to make a complete project again. You are advised to read this article with concentration, if you already have any pending project, then I am sure, after reading this article you guys will be able to resolve the related issues from your firebase database project.

As usual, before I am going to explain the circuit diagram, Firebase setup, and programming. First, I am going to share with you the test results and afterward, I will explain everything else.



Firebase ESP8266

I have connected the MQ3 Gas sensor and Flame Sensor with my ESP8266 Development board as per the circuit diagram which I will explain in a minute.


As you can see I have powered up the ESP8266 and I have also opened my Google Firebase account.

Firebase ESP8266

Right now Nodemcu ESP8266 and Laptop are connected to the internet. Right now I am using the same WiFi network. But if you want you can also use different WiFi networks. It’s an IoT “Internet of things” based project. You can monitor your sensors from any part of the world, obviously if the internet connection is available.

I have created this Realtime Firebase Database with the name Flame and MQ3 Sensor. This realtime Firebase database receives sensors values from the Nodemcu ESP8266 and displays the values over here. I am using digital mode of the Flame sensor, in the digital mode, the output of the flame sensor can be either 1 or 0. So, if no flame is detected then the message “No Fire” is printed and if the Flame is detected then the message “Fire Detected” is printed.

While I am using Analog mode of the MQ3 sensor. You will see different values depending on the amount of Gas leakage. Anyway, let’s go ahead and start the testing.

Firebase ESP8266

When the flame sensor detected the fire the status of the Flame sensor on the Google Firebase changed to “Fire Detected”.


Then I also tested the MQ3 Sensor and the value on the Firebase changed to 392. For the practical demonstration watch the video tutorial given at the end of this article.

Firebase ESP8266

I am sure by now, you might have got an idea of how does this system work. So, without any further delay let’s get started!!!

Amazon Links:

Nodemcu ESP8266 WiFi Module

MQ3 Sensor

Flame Sensor

ESP32 WiFi + Bluetooth Module (Recommended)

Disclosure: These are affiliate links. As an Amazon Associate I earn from qualifying purchases.


Flame sensor:

Firebase ESP8266

This is the Flame Sensor Module which is also known as the Infrared IR Fire Sensor Detector. This Flame Sensor is extremely sensitive to IR wavelengths between 760-1100nm light. This flame sensor is ideal for short-range fire detection and can be used to monitor projects or as a safety precaution to cut devices OFF / ON or to turn ON buzzers or Send SMS. It can be used in hundreds of projects. I have found that this Flame Sensor is mostly accurate up to about 3 feet. I think this much range is enough.

Flame Sensor Specifications and Pinout:

On the right we have a black IR LED sensor. The Flame Sensor Module has a total of 4 male headers on the left side which are clearly labeled as

  1. A0 which is the Analog output pin of the Flame Sensor
  2. G this is the ground pin and it should be connected with the ground pin of the power supply or the Arduino board.
  3. + pin the input supply pin and this is where we connect 3.3v or 5v from the Arduino Board.
  4. D0 is the digital output signal pin which can be connected with any i/o pin of the Arduino board or it can be directly connected with TTL supported circuits for directly controlling the buzzers and relays etc.

This Flame sensor module is also provided with a Potentiometer which can be used for adjusting the Fire Flame detection sensitivity. The Flame sensor module is also provided with two LEDs L1 and L2. One LED is turned ON when you power up the Flame Sensor module while the other LED only lights up when it detects the flame.

Specifications:

  • The working voltage: 3.3V-5V
  • The output format: DO digital switching outputs (0 and 1) and AO analog voltage output
  • Comparator: wide voltage LM393
  • Length: 4.5cm / 1.77in
  • Weight: 4g



MQ3 Gas sensor:

Firebase ESP8266

Features:

  1. Double panel design, with power indicator and TTL output signal.
  2. Have DO switch signal (TTL) output and AO analog signal output.
  3. TTL output signal for low level effectively. (when the low output electric signal lights at ordinary times, can be directly connect single chip microcomputer or relay module)
  4. Analog output voltage with concentration, the higher concentration, the higher voltage.
  5. Has better sensitivity with the liquefied petroleum gas, natural gas, city gas, smoke.
  6. Has long service life and reliable stability
  7. Rapid response recovery features

Specifications:

  1. Input voltage: DC5V
  2. Power consumption (current) : 150 mA
  3. DO output: TTL digital 1 and 0 (0.1 and 5 V)
  4. AO output: 0.1-0.3 V
  5. Highest concentration of voltage: Approx 4 V
  6. Detection range of alcohol: detection range of 10 ~ 1000 PPM

Connection mode:

  1. VCC: Positive (5 v)
  2. GND: Connect power negative
  3. DO: TTL switch signal output
  4. AO: Analog signal output


Firebase ESP8266, Circuit Diagram:

Firebase ESP8266

The power supply pins of MQ3 Sensor and Flame Sensor are connected with the 3.3V and GND pins of the Nodemcu ESP8266 WiFi module. The digital output pin D0 of the Flame sensor is connected with the D0 pin on the Nodemcu module. While the Analog output pin of the MQ3 Sensor is connected with the A0 analog pin of the Nodemcu ESP8266 WiFi module.

For the initial testing, you don’t need this 5V regulated power supply, you can use your laptop to power up the Nodemcu module. But if you are thinking about its practical implementation then you will need an external power supply.  Now, let’s go ahead and start working on the Google Firebase.

Google Firebase Database setup:

Search for the Firebase and click on the first link

Firebase ESP8266

Next, click on Go to console.

Firebase ESP8266


 

Next, click on Create a project.

Firebase ESP8266

 Enter the Project name, in my case, I am going to select “Flame and MQ3 sensor” avoid long project names. Check the boxes to confirm the Firebase terms and click on the Continue button.

Firebase ESP8266

Disable the Google Analytics for this project and click on the Create project button.

Firebase ESP8266

Once your project is ready click on the Continue button. This step may take a minute or so. Now, click on the Authentication.

Firebase ESP8266

Click on Get started.

Firebase ESP8266


Then in Sign-in provider click on Anonymous.

Firebase ESP8266

Click on Enable and save the changes.

Firebase ESP8266

After you click on the save button, on the next page you will see the Status is now changed to Enabled.

Now, click on the Project Overview on the left side. Scroll down and click on the See all Extensions features.

Firebase ESP8266

Scroll down and select Realtime Database.

Firebase ESP8266

Click on Create Database.

Firebase ESP8266

While the United States selected, click on the Next button.

Firebase ESP8266

Select Start in test mode and click the Enable button.

Firebase ESP8266

Copy this link.

Firebase ESP8266

Open the programming file and paste this link next to the DATABASE_URL.

Firebase ESP8266

Now, open the Project settings.

Firebase ESP8266



Copy the Web API key.

Firebase ESP8266

Again open the programming file and paste it next to the API_KEY.

Firebase ESP8266

We are done with all the settings, Now, I can click on the Realtime Database and start monitoring my Sensors. Now, let’s go ahead and take a look at the programming.

ESP8266 Board Manager & Library:

If you have never used the Nodemcu ESP8266 WiFi module, then I highly recommend that you guys should read my getting started article on the Nodemcu ESP8266, in that article I have explained how to install the ESP8266 board manager URL link. If you do not install the ESP8266 board then you won’t be able to find the NodeMCU ESP8266 in the boards list in the Arduino IDE. So, installing the ESP8266 board is the first thing that you have to do.

After you are done with installing the ESP8266 or ESP32, now, In order to connect your Google Firebase Database account with the Nodemcu ESP8266 or ESP32 you will need this Firebase_ESP_Client library. To install this library, simply click on the Sketch menu, then Include Library, and click on the Manage Libraries.

Firebase ESP8266

Search for the firebase Arduino. As you can see I have already installed the Firebase Arduino Client Library for ESP8266 and ESP32.


Firebase ESP8266, Programming:

Watch Video Tutorial on YouTube

 

 

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button