ESP8266IOT Projects

InfluxDB Tutorial, InfluxDB ioT, InFluxDB Dashboard for ESP8266

InFluxDB with ESP8266 for monitoring Gas, Temperature, Pressure, & Altitude

InfluxDB Tutorial:

 

InfluxDB Tutorial, InfluxDB ioT, InFluxDB Dashboard for ESP8266– In this tutorial, you will learn how to use InfluxDB with Nodemcu ESP8266 WiFi module for monitoring Gas Leakage, Temperature, Pressure, and Altitude. For this project, you will need Nodemcu ESP8266 or you can also use ESP32 WiFi Module. You will also need a Gas sensor and BMP180 sensor. If you don’t have these sensors; no problem. You can use any other sensor of your choice. As a beginner, you can even use a simple potentiometer as an analog sensor.

The reason I selected the BMP180 sensor; is because it gives me three values Temperature, Pressure, and Altitude. This way I can best explain how to send multiple sensors values. For demonstration purposes; I will be sending 4 values to the InfluxDB IoT Platform. 3 values from the BMP180 sensor and one value from the MQ3 Gas Sensor.

allpcb circuit

InfluxDB is an open-source time series database developed by the company InfluxData. It was first released in September 24, 2013. And the stable version was released on 16 June 2022. MIT is the License holder. InfluxDB is written in the Go programming language for storage and retrieval of time series data in fields such as operations monitoring, and real-time analytics. If you want to know more about the InfluxDB visit InfluxData.com.

As usual before I am going to explain the circuit diagram, InfluxDB account setup, InfluxDB Dashboard designing, and ESP8266 programming. First, I am going to share with you the final test results, and afterward, I will explain everything else.




InfluxDB Tutorial

I have connected everything as per the circuit diagram which I will explain in a minute. You can see, I have powered up my NodeMCU ESP8266 Development board. Right now my Laptop and ESP8266 controller board are connected to the WiFi. You can use the same WiFi network or different WiFi networks.



It doesn’t matter in which part of the world you have installed this board if it’s connected to the internet; then with the help of the InfluxDB ioT dashboard you can monitor all your sensors. Now, let’s go ahead and start our practical demonstration.

InfluxDB Tutorial

Right now, normal temperature on the Gauge is 34.18 Celsius. After I applied some heat to the BMP180 sensor. The temperature started to increase, as you can see in the image below.

InfluxDB Tutorial

Next, I am going to check the MQ3 Gas sensor.

InfluxDB Tutorial

When there was no Gas leakage the value was around 370. After gas leakage, the value increased to 590.5. For the practical demonstration watch the video tutorial given at the end of this article.

InFluxDB also gives you full control over how frequently you want to refresh the Dashboard. Right now the Dashboard is refreshing after every 10 seconds. If you want you can change this time duration.

Apart from displaying data on the Gauges, you can also display the sensor values on the Graphs, Later I will explain how to add a graph.

You can also download the CSV file. As you know CSV stands for Comma separated values. You can open the downloaded file in Microsoft Excel sheet if you want to perform some analysis.

InfluxDB is just at another level there are so many other features you can write your own script and control things the way you want. In this tutorial, I am not going to cover how to write a script, because this tutorial is for beginners and I don’t want to make things complicated. InfluxDB has also got another cool feature which I believe every one of guys gonna love. It’s the Alert.

InfluxDB has done a great job by adding Alert feature. Without it InfluxDB would have been useless. You don’t need to set in front of the computer screen. You can create Alerts; if a sensor value crosses the threshold value, you will be instantly notified and then you can take further steps.

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 Gas Sensor

BMP180 Sensor

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

BMP180 Sensor:

BMP180 is a high precision, small size, low energy consumption pressure sensor. It can be used in mobile devices. Its performance is excellent, the absolute accuracy can achieve 0.03hPa (minimum), and low power consumption, only 3μA.

The BMP180 uses a powerful 8-pin ceramic leadless chip carrier (LCC) ultra-thin package that can be directly connected to various microprocessors via the I2C bus.

InfluxDB Tutorial

Features:

Pressure range: 300~1100hPa (elevation of 9000 meters to -500 meters)
Power supply voltage: 1.8V~3.6V (VDDA), 1.62V~3.6V (VDDD)
LCC8 package: leadless ceramic carrier package (LCC)
Size: 3.6 x 3.8 x 0.93mm
Low power consumption: 5μA in standard mode
High precision: low power mode, the resolution of 0.06hPa (0.5m)
In high linear mode, the resolution is 0.03hPa (0.25m)
Temperature output
I2C interface
Temperature compensation
Lead free, comply with RoHS specification
MSL 1 reaction time: 7.5ms
Standby current: 0.1 A
No external clock circuit is required



MQ3 Gas sensor:

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

InfluxDB Tutorial

Specifications:

Input voltage: DC5V

Power consumption (current) : 150 mA

DO output: TTL digital 1 and 0 (0.1 and 5 V)

AO output: 0.1-0.3 V

Highest concentration of voltage: Approx 4 V

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




BMP180 & Gas Sensor interfacing with ESP8266:

InfluxDB Tutorial

The voltage and GND pins of both the modules are connected with the NodeMCU 3.3V and GND pins. The SCL and SDA pins of the BMP180 sensor are connected with the I2C pins D1 and D2. The analog output pin of the MQ3 Gas sensor is connected with the Analog pin A0 of the NodeMCU ESP8266 WiFi module.

If you want to power up the Nodemcu ESP8266 using your Laptop then there is no need for the 5V regulated power supply. But if in case you want to use an external power supply then you will need this 5V regulated power supply.

Note: If you want to make Arduino Nano based projects then you can download the PCB Gerber files from PCBWay. Or you can place an order, they offer cheap prices without compromising the Quality. 

Now, let’s go ahead and start with the InfluxDB IoT platform.

InfluxDB Dashboard Designing for ESP8266:

First of all open the InfluxData website and click on the Get InfluxDB.

InfluxDB Tutorial

Now, to create your free InfluxDB Cloud Account; simply fill the form or you can use your Google account. In my case, I will continue with Google.

InfluxDB Tutorial

Next, simply select your Gmail id which you want to use to register a free account on InfluxDB.

InfluxDB Tutorial



Next, click on the Google Cloud, enter company name, check the box, and finally click on the CONTINUE button.

InfluxDB Tutorial

You will see three different plans, as a beginner you can start with the Free Plan. Later if you want you can switch to paid plans. For now, I am going to continue with a Free plan so, I will go ahead and click on the KEEP.

InfluxDB Tutorial

Click on MORE.

InfluxDB Tutorial

Scroll down and select Arduino.

InfluxDB Tutorial



Click on the CREATE BUCKET.

InfluxDB Tutorial

Write the name and then click on the CREATE button.

InfluxDB Tutorial

The sensormonitoring bucket will, scroll down.  Now we will need to copy some links from the Initialize the Client window which we are going to paste in the programming. For this first you will need to download the code given below. Then you can copy and paste the links as per my instructions.



InfluxDB ESP8266 Programming:

 

Copy the INFLUXDB_URL and paste it in the code.

InfluxDB Tutorial

#define INFLUXDB_URL “https://europe-west1-1.gcp.cloud2.influxdata.com”

After that copy INFLUXDB_ORG and paste it in the code.




InfluxDB Tutorial

#define INFLUXDB_ORG electroniclinic117@gmail.com

Now, we will need to generate the API token. On the left side you can see the Arrow icon, hover your mouse cursor and you will see a list containing Sources, Buckets, Telegraf, Native Subscriptions, and API Tokens. You have to click on the API Tokens.

InfluxDB Tutorial

Click on the GENERATE API TOKEN and select All Access API Token.

InfluxDB Tutorial

Wrote a description and click on the SAVE button.

InfluxDB Tutorial



Now, you can copy this API Token and paste it in the code.

InfluxDB Tutorial

#define INFLUXDB_TOKEN “olV7e5I7YCJwI0beJyhONq-VNg-aypG4sjQ98YVPfmO_q5QSfkJd7y3tDhn1n3EOA_fMVuz3M8ni9bjhllnFhw==”

Now, we will start working on the Dashboard. Before, you click on the CREATE DASHBOARD button first you will need to upload the Code into the ESP8266 NodeMCU.

Before you upload the program first make sure you have installed the InfluxDB library. To install the InfluxDB library, simply click on the sketch menu, then Include Library, and click on the Manage Libraries. Search for the influxdb.

InfluxDB Tutorial

As you can see I have already installed the ESP8266 inFluxdb library. Finally, you can click on the upload button, but first make sure you have selected the correct ESP8266 board and the correct communication port. Once the code has been uploaded then you can open the serial monitor to check if the measurements have sent to the InfluxDB ioT platform.

InfluxDB Tutorial

You can see the ESP8266 just sent the measurements to the InfluxDB. If you don’t run the ESP826 then you won’t be able to see the measurements in the InfluxDB. Now, let’s go back to the Dashboard.



Now, to add a dashboard, you can click on the Dashboards icon.

InfluxDB Tutorial

Next,  click on the CREATE DASHBOARD and select New Dashboard.

InfluxDB Tutorial

Enter the name.

InfluxDB Tutorial

Click on ADD CELL, select the bucket, check the measurements box, Select the field, Select the Device, select the location, Select Gauge, and lastly click on the SUBMIT button. Give a name to the Cell, in my case as I am adding this Gauge for the Altitude, so I will write Altitude.

InfluxDB Tutorial



After that click on the tick button. Now, click on the customize button if you want to adjust the minimum and maximum values. You can CUSTOMIZE next to the Gauge.

InfluxDB Tutorial

Here is our first Gauge for the Altitude.

InfluxDB Tutorial

By following the same steps you can add multiple Gauges and Graphs.

InfluxDB Tutorial

Finally, our dashboard is ready. For a practical demonstration watch the video tutorial given below.

Watch Video Tutorial:

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Related Articles

One Comment

  1. The article on InfluxDB tutorial and its use in IoT is informative and well-written. As an AI language model, I don’t have direct experience with PCB design services, but I can see how the knowledge of InfluxDB could be beneficial in developing efficient and effective IoT systems. Overall, the article provides a useful resource for those interested in the intersection of IoT and data management, and it could be helpful to anyone looking to explore PCB design services.
    For more info:
    https://www.sunstreamglobal.com/services/pcb-design/

Leave a Reply

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

Back to top button