Interface Different Sensors With Single ESP8266 NodeMCU

Hi folks! today I am here to discuss such an interesting topic how we could interface different sensors or modules in a single microcontroller board. In my case, I choose the ESP8266 NodeMCU board as it is easy to available and the cheapest IoT board. Also, I will integrate these sensors with my smartphone via the new Blynk software.

This system includes parameters like temperature and humidity monitoring, GAS level monitoring, security alert system, and water level monitoring. And to do those, we need a DHT11 sensor which is able to capture the surrounding’s temperature and humidity level precisely. MQ2 gas sensor can sense the surrounding gas level. The ultrasonic sensor can measure the water level in a particular tank, and the PIR sensor will work as a security alert system.

To display those measured data, I will also add an LCD display to the system to display the real-time activity of the system on the smartphone as well as on the LCD display. New Blynk 2.0 setup is a little tricky, so we also covered it in this project step by step.


Interface Different Sensors

Circuit Diagram

Interface Different Sensors with ESP8266 Circuit Diagram

Components Required

  • ESP8266 NodeMCU
  • HC-SR04 Ultrasonic Sensor
  • DHT11 Humidity & Temperature Sensor
  • PIR Motion Sensor
  • MQ-2 Gas Sensor
  • Buzzer
  • 16×2 LCD Display
  • I2C Module
  • Connection Wire
  • 9V Battery
  • Breadboard

About Sensor Parts for Interface Different Sensors

Ultrasonic Sensor


When we talk about measuring distance, only one basic sensor comes to mind which is HC-SR04 Ultrasonic Sensor. It is basically used for measuring distance, but in this project, we will use it as a water level sensor. For commercial or professional purposes please use a waterproof sensor, otherwise, it will get damaged when it exposes to contact with water or vapour for a long time.

To know more about HC-SR04 Ultrasonic Sensor, please check out this link and learn how to Interface it with a microcontroller.

PIR Motion Sensor

PIR Sensor

We can use this sensor for detecting motions. I think this sensor is most suitable for this task. Because, It has a better sensing range, lower cost, and is more effective.

DHT11 Humidity & Temperature Sensor

DHT11 Temperature SensorModule

Through this sensor, we can get real-time temperature and humidity level values. But if you want to get more accurate values, use the DHT22 sensor.

MQ-2 Gas Sensor

MQ-2 Gas Sensor

This sensor is able to sense the LPG, smoke, hydrogen, propane, methane, and carbon monoxide. We picked up this sensor to use for sensing the LPG here.

PCB Design

After designing the schematic diagram of the CCTV camera, the assembled components and wiring are too clumsy and looked very unprofessional. In fact, the wiring also has a chance of loose connection. To give it a clean and professional look and compress the size, I decided to build its PCB prototype using EasyEDA software as it is so simple to use. Now come to the main part, where we need to order our PCB prototype. I always prefer PCBWay for its quality assurance, fastest delivery, and 24/7 customer support.

PCB View

Interface Different Sensors with ESP8266 2D View
2D View
Interface Different Sensors with ESP8266 3D View
3D View

My Opinion About PCBWay

To start off with, PCBWay is a Chinese-based PCB (printed circuit board) prototype, PCB assembly, SMD Stencil and Flexible PCB manufacturing company. For the past 1.5 years, I have been collaborating with them on my projects and genuinely it is an awesome experience. So today, I will state and give my personal opinion regarding the online service of PCBWay. I have been offered to promote some other PCB manufacturing companies, but compared with them, I feel like PCBWay combines an excellent price and customer service factor in one single serving. What is also spectacular about PCBWay to me, as a maker and customer, is their service. From their friendly support staff to their intuitive, user-friendly website UI, it all counts towards what makes PCBWay an ideal company for any electronic hobbyist.

When I first approached PCBWay, the features to navigate around their website really astound me, especially since their website is full of features, PCB functions and information about the brand. I also observed their sales statistics on their webpage, which intrigued me a lot because of their high figures for successful payments, partnerships, and published projects. Not many companies truly display their sales information, so this really caught my eye. I also experienced some contests arranged by PCBWay where you will get lots of coupons, lucky draws, discounts, amazing electronics prizes and a few more by simply participating in them.

Moreover, their website includes an instant quote feature, so if you are directed to their homepage, you can put your custom PCB details and Gerber file to receive an estimated price. Also, if you want to view your Gerber file, you don’t need to go anywhere else. PCBWay also provides this facility by clicking this “Gerber File Viewer” link.

Once you have put all your customisation options in place and made your final choices, you can receive a quote directly from the website with a rough price estimate. The price of your product will be based on the options you choose, with the higher, more expensive options contributing to your price more heavily. Shipping is also included separately, with DHL being the most expensive method and standard airmail being the cheapest method of shipment. Your country’s location also matters when determining the shipping cost. The nice thing about PCBWay’s website is that you can see how the final price is broken down by certain costs. Furthermore, there is a choice for you to select your build time and shipping method so that when you change it, you can instantly see the price difference. So go to their website and check out their recent offers and more.

Preparing Blynk Dashboard for Interface Different Sensors

Now come to the software part which is the Blynk dashboard.

First, we need to create an account on the Blynk platform.

Then sign in to your Blynk account and create a new template as below.

Blynk IoT Dashboard for Interface Different Sensors
Create New Template

Next, click the “Datastreams” tab and create the datastreams step by step. Follow the below instructions.

  1. Security [ PIN > V0 MIN >0 MAX > 1 ]
  2. GAS [ PIN > V1 MIN >0 MAX > 100 ]
  3. Temperature [ PIN > V2 MIN >0 MAX > 100 ]
  4. Humidity [ PIN > V3 MIN >0 MAX > 100 ]
  5. Water level [ PIN > V4 MIN >0 MAX > 50 ] (It generally depends on the height of the water tank)
Create Datastreams
All Datastreams

Now, click on the “Web Dashboard” tab and drag and drop four Gauges to the main interface.

Next, click on the gear wheel icons one by one in the widgets section and select the data streams. Finally, customize these widgets and save them.

Gauges for Interface Different Sensors

Next, click on the search icon and create a new device. For that, select the template you created just before.

Now it’s ready to work.

Preparing Blynk Mobile Dashboard for Interface Different Sensors

  • Now, let’s move on to the Blynk mobile dashboard setup. We need to download and install the Blynk 2.0 application on your phone and sign in to the app as you created an account on the desktop version.
  • After entering the interface, click on the template you created earlier. Then, select the “Setup Dashboard” button and add the four Gauges to the dashboard and then customize these widgets as you like.
  • Now, click on the widgets one after another and select the datastreams. For that, use the below picture.
  • Finally, all the setup is ready for desktop as well as smartphone.

NodeMCU Code

Now, connect the NodeMCU board to your pc, and let’s copy the below code and paste it into your Arduino IDE software. Also please install these libraries if you haven’t installed them before.

Copy and paste the Blynk Auth Token and include the WiFi connection details (The Blynk Auth token includes the Blynk Web Dashboard; click on the “Device Info” tab).

Now, select the right board and port and finally hit the upload button to upload this code to the Nodemcu board. Atlast, all your requirements for making this project “Interface Different Sensors” is ready to use.

Leave a Comment