ESP8266IOT Projects

Nodemcu and BMP180 “temperature, pressure & Altitude” internet of things project “iot”

Nodemcu And BMP180 Project Description:

 

In this tutorial, you will learn how to use the BMP180 sensor with Nodemcu esp8266 wifi module, with the help of this project you can monitor the temperature, pressure, and Altitude values using Blynk application from anywhere around the world. This project is based on two-way communication; we will be monitoring and controlling both at the same time. This project is based on my previous two tutorials.

In this tutorial you will learn how to use the BMP180 sensor, this tutorial explains the datasheet and basic circuit diagram.

 

While this tutorial explains the two-way communication between the Nodemcu esp8266 wifi module and Arduino using the Blynk application.

I recommend you should first watch these two tutorials for the best understanding.


Amazon Links:

12v Adaptor:

Arduino Uno

Arduino Nano

Mega 2560:

Nodemcu ESP8266 WiFi Module:

LM7805 Voltage Regulator:

470uf capacitor:

330-ohm resistor:

DC Female Power Jack:

Female Headers:

Male Headers:

BMP180 sensor:

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

Arduino Nodemcu and BMP180 Circuit Diagram:

Nodemcu and BMP180-
Nodemcu and bmp180

This is the complete circuit diagram. This schematic is designed in the Cadsoft eagle 9.1.0 version. If you want to learn how to make a schematic and PCB then watch my tutorial.

Let’s start with the power supply. 7805 voltage regulator is used to regulate the input voltage at 5 volts. These 5 volts can be used to power up the Nodemcu module if in case you want to use it alone. You can simply connect the output of the voltage regulator with the VIN pin of the Nodemcu and make sure you connect the ground as well. This power supply can also be used to power up the Arduino, by connecting its output with the VIN pin of the Arduino and removing the wire which is connected with the 5v.



You can also power up Arduino using a 12v adaptor, and then you can disconnect this power supply. And you can power the Nodemcu using the Arduino 5 volts. But my recommendation is to use the external power supply for the Nodemcu esp8266 wifi module.

The TX and RX pin’s of the Nodemcu are connected with pin2 and pin3 of the Arduino. So the Nodemcu will communicate serially with Arduino Uno through pin2 and pin3. Pin2 is RX and pin3 is TX, which will be defined in the programming using the software serial library.

The VIN pin of the bmp180 sensor is connected with 3.3v of the Arduino, SCL is connected with A5 and SDA is connected with A4 and the ground is connected with the Arduino’s ground.

A led is connected with pin number 13 and a 330-ohm resistor is connected in series. I will use the Arduino’s onboard led for the demonstration purposes.

I soldered all the components as per the circuit diagram. If you want to learn how to make a power supply for the Nodemcu so that it can be easily powered up using a 12v adaptor or battery then you should watch my tutorial on Nodemcu power supply.


Note: this old version of the Blynk app is no more functional. For the blynk mobile App setup and Blynk.cloud dashboard setup ready my article on the New Blynk V2.0. In this article I have explained how to migrate your projects from Blynk 1.0 to the new Blynk V2.0. You can also watch the video.

Mobile Application Designing:

For the Blynk application designing and Setup watch video Tutorial given at the end of this Article.

Programming:

Arduino Programming:

Nodemcu and BMP180-

#include <SoftwareSerial.h>
#include <Wire.h>
#include <Adafruit_BMP085.h>
SoftwareSerial nodemcu(2,3);

// Connect VCC of the BMP180 / BMP085 sensor to 3.3V
// Connect GND to Ground
Adafruit_BMP085 bmp;

long int data; 
int relay1 = 13; 
int relay2 = 12;


int sdata1 = 0; // temperature data
long int sdata2 = 0; // pressure data
int sdata3 = 0; // altitude data

String cdata; // complete data

void setup()
{
Serial.begin(9600); 
nodemcu.begin(9600);
pinMode(relay1, OUTPUT); 
pinMode(relay2, OUTPUT);


  if (!bmp.begin()) {
    Serial.println("Could not find a valid BMP180 sensor, check wiring!");
    while (1) {}
  }

}

void loop()
{
  
if(nodemcu.available() == 0 )
{
      Serial.print("Temperature = ");
    Serial.print(bmp.readTemperature());
    sdata1 = bmp.readTemperature();
    Serial.println(" *C");
    
    Serial.print("Pressure = ");
    Serial.print(bmp.readPressure());
    sdata2 = bmp.readPressure();
    Serial.println(" Pa");
    
    // Calculate altitude assuming 'standard' barometric
    // pressure of 1013.25 millibar = 101325 Pascal
    Serial.print("Altitude = ");
    Serial.print(bmp.readAltitude());
    sdata3 = bmp.readAltitude();
    Serial.println(" meters");  
  

   cdata = cdata + sdata1+","+sdata2+","+sdata3; 
   Serial.println(cdata); 
   nodemcu.println(cdata);
   delay(1000); // 100 milli seconds
   cdata = ""; 
}

if ( nodemcu.available() > 0 ) 
{
  data = nodemcu.parseInt();
  delay(100); 
  Serial.println(data); 

  if ( data == 10 )
  {
    digitalWrite(relay1, LOW); 
  }

    if ( data == 11 )
  {
    digitalWrite(relay1, HIGH); 
  }

  // relay2 

    if ( data == 12 )
  {
    digitalWrite(relay2, LOW); 
  }

    if ( data == 13 )
  {
    digitalWrite(relay2, HIGH); 
  }
}



}


Nodemcu esp8266 wifi module Programming:

#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SoftwareSerial.h>
#include <SimpleTimer.h>

int pinValue1;
int pinValue2;
int pinValue3;
int pinValue4;


char auth[] = "80a57c58dde24141834e87f459881ac3";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "ZONG MBB-E8231-6E63";
char pass[] = "08659650";

SimpleTimer timer;

String myString; // complete message from arduino, which consistors of snesors data
char rdata; // received charactors

//for temperature , pressure and altitude
int firstVal, secondVal,thirdVal; // 
// This function sends Arduino's up time every second to Virtual Pin (1).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void myTimerEvent()
{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V1, millis() / 1000);
  
}



void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);

    timer.setInterval(1000L,sensorvalue1); 
     timer.setInterval(1000L,sensorvalue2); 
     timer.setInterval(1000L,sensorvalue3);

}

void loop()
{
   if (Serial.available() == 0 ) 
   {
  Blynk.run();
  timer.run(); // Initiates BlynkTimer
   }
   
  if (Serial.available() > 0 ) 
  {
    rdata = Serial.read(); 
    myString = myString+ rdata; 
   // Serial.print(rdata);
    if( rdata == '\n')
    {
   //  Serial.println(myString); 
  // Serial.println("fahad");
// new code
String l = getValue(myString, ',', 0);
String m = getValue(myString, ',', 1);
String n = getValue(myString, ',', 2); 


firstVal = l.toInt();
secondVal = m.toInt();
thirdVal = n.toInt();

  myString = "";
// end new code
    }
  }

}

void sensorvalue1()
{
int sdata = firstVal;
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V2, sdata);

}
void sensorvalue2()
{
int sdata = secondVal;
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V3, sdata);

}

void sensorvalue3()
{
int sdata = thirdVal;
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V4, sdata);

}

String getValue(String data, char separator, int index)
{
    int found = 0;
    int strIndex[] = { 0, -1 };
    int maxIndex = data.length() - 1;

    for (int i = 0; i <= maxIndex && found <= index; i++) {
        if (data.charAt(i) == separator || i == maxIndex) {
            found++;
            strIndex[0] = strIndex[1] + 1;
            strIndex[1] = (i == maxIndex) ? i+1 : i;
        }
    }
    return found > index ? data.substring(strIndex[0], strIndex[1]) : "";
}

// in Blynk app writes values to the Virtual Pin 10
BLYNK_WRITE(V10)
{
   pinValue1 = param.asInt(); // assigning incoming value from pin V10 to a variable

  Serial.print(pinValue1);

}


// in Blynk app writes values to the Virtual Pin 11
BLYNK_WRITE(V11)
{
   pinValue2 = param.asInt(); // assigning incoming value from pin V10 to a variable

  Serial.print(pinValue2);

}

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...

Leave a Reply

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

Back to top button