top of page
Writer's pictureRamesh G

IoT Weather Station BMP180

Updated: Jul 2, 2021



In this project, To interface BMP180 Barometric Pressure Sensor with NodeMCU ESP8266 12E. This sensor are fairly simple to use, pre-calibrated and don’t require extra components so you can start measuring temperature, pressure & altitude.



Circuit Diagram



Component required

1. NodeMCU ESP8266-12E Board

2. BMP 180


BMP180 Chip

BMP180 can measure barometric pressure from 300 to 1100 hPa (9000m to -500m above sea level), and temperature from -40°C to 85°C with ±1.0°C accuracy.The pressure measurements are so precise (low altitude noise of 0.25m), you can even use it as an altimeter with ±1 meter accuracy.


VCC is connected to the 3.3V of Node MCU.

GND is connected to the ground of Node MCU.

SCL is D1 of Node MCU.

SDA is D2 of Node MCU.


BMP180 MODULE Features

  • Can measure temperature and altitude.

  • Pressure range: 300 to 1100hPa

  • High relative accuracy of ±0.12hPa

  • Can work on low voltages

  • 3.4Mhz I2C interface

  • Low power consumption (3uA)

  • Pressure conversion time: 5msec

  • Potable size

BMP180 MODULE Specifications

  • Operating voltage of BMP180: 1.3V – 3.6V

  • Input voltage of BMP180MODULE: 3.3V to 5.5V

  • Peak current : 1000uA

  • Consumes 0.1uA standby

  • Maximum voltage at SDA , SCL : VCC + 0.3V

  • Operating temperature: -40ºC to +80ºC

Installing Libraries

BMP180 Download

Calculating the altitude and barometric pressure with BMP180 module needs to install Library so that we can use simple commands to read the temperature, barometric pressure and altitude data.


This is a helper libary to abstract away I2C & SPI transactions and registers


To install the library navigate to the Sketch > Include Library > Manage Libraries… Wait for Library Manager to download libraries index and update list of installed libraries.


Subscribe and Download code.


arduino Code


#include <ESP8266WebServer.h>

#include <Wire.h>

#include <Adafruit_BMP085.h>

#include <Adafruit_I2CDevice.h>

Adafruit_BMP085 bmp;


float temperature,pressure,pressuresealevel,altitude,altitudereal;

const char* ssid = "TP-Link_3200"; // YOUR ssiD

const char* password = "9500112137"; //?YOUR WIFI PASSWORD

ESP8266WebServer server(80);

void setup() {

Serial.begin(9600);

if (!bmp.begin()) {

Serial.println("Could not find a valid BMP085 sensor, check wiring!");

while (1) {}

}

Serial.println("Connecting to ");

Serial.println(ssid);

//Connect to your local wi-fi network

WiFi.begin(ssid, password);

//check wi-fi is connected to wi-fi network

while (WiFi.status() != WL_CONNECTED) {

delay(1000);

Serial.print(".");

}

Serial.println("");

Serial.println("WiFi connected..!");

Serial.print("Got IP: "); Serial.println(WiFi.localIP());

server.on("/", handle_OnConnect);

server.onNotFound(handle_NotFound);

server.begin();

Serial.println("HTTP server started");

}

void loop() {

server.handleClient();

}

void handle_OnConnect() {

temperature = bmp.readTemperature();

pressure = bmp.readPressure();

altitude = bmp.readAltitude();

pressuresealevel = bmp.readSealevelPressure();

altitudereal = bmp.readAltitude();

server.send(200, "text/html", SendHTML(temperature,pressure,pressuresealevel,altitude,altitudereal));

}

void handle_NotFound(){

server.send(404, "text/plain", "Not found");

}

String SendHTML(float temperature,float pressure,float pressuresealevel,float altitude, float altitudereal){

String ptr = "<!DOCTYPE html>";

ptr +="<html>";

ptr +="<head>";

ptr +="<title>ESP8266 Weather Station</title>";

ptr +="<meta name='viewport' content='width=device-width, initial-scale=1.0'>";

ptr +="<link href='https://fonts.googleapis.com/css?family=Open+Sans:300,400,600' rel='stylesheet'>";

ptr +="<style>";

ptr +="html { font-family: 'Open Sans', sans-serif; display: block; margin: 0px auto; text-align: center;color: #444444;}";

ptr +="body{margin: 0px;} ";

ptr +="h1 {margin: 50px auto 30px;} ";

ptr +=".side-by-side{display: table-cell;vertical-align: middle;position: relative;}";

ptr +=".text{font-weight: 600;font-size: 19px;width: 200px;}";

ptr +=".reading{font-weight: 300;font-size: 50px;padding-right: 25px;}";

ptr +=".temperature .reading{color: #FF1919;}";

ptr +=".pressure .reading{color: #3B97D3;}";

ptr +=".pressuresealevel .reading{color: #27A5A2;}";

ptr +=".altitude .reading{color: #F29C1F;}";

ptr +=".altitudereal .reading{color: #955BA5;}";

ptr +=".superscript{font-size: 17px;font-weight: 600;position: absolute;top: 10px;}";

ptr +=".data{padding: 10px;}";

ptr +=".container{display: table;margin: 0 auto;}";

ptr +=".icon{width:65px}";

ptr +="</style>";

ptr +="</head>";

ptr +="<body>";

ptr +="<h1>BMP180 Weather Station</h1>";

ptr +="<h1>ESP8266 Web Server</h1>";

ptr +="<div class='container'>";

ptr +="<div class='data temperature'>";

ptr +="<div class='side-by-side icon'>";

ptr +="<svg enable-background='new 0 0 19.438 54.003'height=54.003px id=Layer_1 version=1.1 viewBox='0 0 19.438 54.003'width=19.438px x=0px xml:space=preserve xmlns=http://www.w3.org/2000/svg xmlns:xlink=http://www.w3.org/1999/xlink y=0px><g><path d='M11.976,8.82v-2h4.084V6.063C16.06,2.715,13.345,0,9.996,0H9.313C5.965,0,3.252,2.715,3.252,6.063v30.982";

ptr +="C1.261,38.825,0,41.403,0,44.286c0,5.367,4.351,9.718,9.719,9.718c5.368,0,9.719-4.351,9.719-9.718";

ptr +="c0-2.943-1.312-5.574-3.378-7.355V18.436h-3.914v-2h3.914v-2.808h-4.084v-2h4.084V8.82H11.976z M15.302,44.833";

ptr +="c0,3.083-2.5,5.583-5.583,5.583s-5.583-2.5-5.583-5.583c0-2.279,1.368-4.236,3.326-5.104V24.257C7.462,23.01,8.472,22,9.719,22";

ptr +="s2.257,1.01,2.257,2.257V39.73C13.934,40.597,15.302,42.554,15.302,44.833z'fill=#FF1919 /></g></svg>";

ptr +="</div>";

ptr +="<div class='side-by-side text'>Temperature</div>";

ptr +="<div class='side-by-side reading'>";

ptr +=(int)temperature;

ptr +="<span class='superscript'>&deg;C</span></div>";

ptr +="</div>";

ptr +="<div class='data pressure'>";

ptr +="<div class='side-by-side icon'>";

ptr +="<svg enable-background='new 0 0 40.542 40.541'height=40.541px id=Layer_1 version=1.1 viewBox='0 0 40.542 40.541'width=40.542px x=0px xml:space=preserve xmlns=http://www.w3.org/2000/svg xmlns:xlink=http://www.w3.org/1999/xlink y=0px><g><path d='M34.313,20.271c0-0.552,0.447-1,1-1h5.178c-0.236-4.841-2.163-9.228-5.214-12.593l-3.425,3.424";

ptr +="c-0.195,0.195-0.451,0.293-0.707,0.293s-0.512-0.098-0.707-0.293c-0.391-0.391-0.391-1.023,0-1.414l3.425-3.424";

ptr +="c-3.375-3.059-7.776-4.987-12.634-5.215c0.015,0.067,0.041,0.13,0.041,0.202v4.687c0,0.552-0.447,1-1,1s-1-0.448-1-1V0.25";

ptr +="c0-0.071,0.026-0.134,0.041-0.202C14.39,0.279,9.936,2.256,6.544,5.385l3.576,3.577c0.391,0.391,0.391,1.024,0,1.414";

ptr +="c-0.195,0.195-0.451,0.293-0.707,0.293s-0.512-0.098-0.707-0.293L5.142,6.812c-2.98,3.348-4.858,7.682-5.092,12.459h4.804";

ptr +="c0.552,0,1,0.448,1,1s-0.448,1-1,1H0.05c0.525,10.728,9.362,19.271,20.22,19.271c10.857,0,19.696-8.543,20.22-19.271h-5.178";

ptr +="C34.76,21.271,34.313,20.823,34.313,20.271z M23.084,22.037c-0.559,1.561-2.274,2.372-3.833,1.814";

ptr +="c-1.561-0.557-2.373-2.272-1.815-3.833c0.372-1.041,1.263-1.737,2.277-1.928L25.2,7.202L22.497,19.05";

ptr +="C23.196,19.843,23.464,20.973,23.084,22.037z'fill=#3B97D3 /></g></svg>";

ptr +="</div>";

ptr +="<div class='side-by-side text'>Pressure</div>";

ptr +="<div class='side-by-side reading'>";

ptr +=(int)pressure;

ptr +="<span class='superscript'>hPa</span></div>";

ptr +="</div>";

ptr +="<div class='data pressuresealevel'>";

ptr +="<div class='side-by-side icon'>";

ptr +="<svg enable-background='new 0 0 40.542 40.541'height=40.541px id=Layer_1 version=1.1 viewBox='0 0 40.542 40.541'width=40.542px x=0px xml:space=preserve xmlns=http://www.w3.org/2000/svg xmlns:xlink=http://www.w3.org/1999/xlink y=0px><g><path d='M34.313,20.271c0-0.552,0.447-1,1-1h5.178c-0.236-4.841-2.163-9.228-5.214-12.593l-3.425,3.424";

ptr +="c-0.195,0.195-0.451,0.293-0.707,0.293s-0.512-0.098-0.707-0.293c-0.391-0.391-0.391-1.023,0-1.414l3.425-3.424";

ptr +="c-3.375-3.059-7.776-4.987-12.634-5.215c0.015,0.067,0.041,0.13,0.041,0.202v4.687c0,0.552-0.447,1-1,1s-1-0.448-1-1V0.25";

ptr +="c0-0.071,0.026-0.134,0.041-0.202C14.39,0.279,9.936,2.256,6.544,5.385l3.576,3.577c0.391,0.391,0.391,1.024,0,1.414";

ptr +="c-0.195,0.195-0.451,0.293-0.707,0.293s-0.512-0.098-0.707-0.293L5.142,6.812c-2.98,3.348-4.858,7.682-5.092,12.459h4.804";

ptr +="c0.552,0,1,0.448,1,1s-0.448,1-1,1H0.05c0.525,10.728,9.362,19.271,20.22,19.271c10.857,0,19.696-8.543,20.22-19.271h-5.178";

ptr +="C34.76,21.271,34.313,20.823,34.313,20.271z M23.084,22.037c-0.559,1.561-2.274,2.372-3.833,1.814";

ptr +="c-1.561-0.557-2.373-2.272-1.815-3.833c0.372-1.041,1.263-1.737,2.277-1.928L25.2,7.202L22.497,19.05";

ptr +="C23.196,19.843,23.464,20.973,23.084,22.037z'fill=#27A5A2 /></g></svg>";

ptr +="</div>";

ptr +="<div class='side-by-side text'>Pressure Sea Level</div>";

ptr +="<div class='side-by-side reading'>";

ptr +=(int)pressuresealevel;

ptr +="<span class='superscript'>hPa</span></div>";

ptr +="</div>";

ptr +="<div class='data altitude'>";

ptr +="<div class='side-by-side icon'>";

ptr +="<svg enable-background='new 0 0 58.422 40.639'height=40.639px id=Layer_1 version=1.1 viewBox='0 0 58.422 40.639'width=58.422px x=0px xml:space=preserve xmlns=http://www.w3.org/2000/svg xmlns:xlink=http://www.w3.org/1999/xlink y=0px><g><path d='M58.203,37.754l0.007-0.004L42.09,9.935l-0.001,0.001c-0.356-0.543-0.969-0.902-1.667-0.902";

ptr +="c-0.655,0-1.231,0.32-1.595,0.808l-0.011-0.007l-0.039,0.067c-0.021,0.03-0.035,0.063-0.054,0.094L22.78,37.692l0.008,0.004";

ptr +="c-0.149,0.28-0.242,0.594-0.242,0.934c0,1.102,0.894,1.995,1.994,1.995v0.015h31.888c1.101,0,1.994-0.893,1.994-1.994";

ptr +="C58.422,38.323,58.339,38.024,58.203,37.754z'fill=#F29C1F /><path d='M19.704,38.674l-0.013-0.004l13.544-23.522L25.13,1.156l-0.002,0.001C24.671,0.459,23.885,0,22.985,0";

ptr +="c-0.84,0-1.582,0.41-2.051,1.038l-0.016-0.01L20.87,1.114c-0.025,0.039-0.046,0.082-0.068,0.124L0.299,36.851l0.013,0.004";

ptr +="C0.117,37.215,0,37.62,0,38.059c0,1.412,1.147,2.565,2.565,2.565v0.015h16.989c-0.091-0.256-0.149-0.526-0.149-0.813";

ptr +="C19.405,39.407,19.518,39.019,19.704,38.674z'fill=#F5B962 /></g></svg>";

ptr +="</div>";

ptr +="<div class='side-by-side text'>Altitude</div>";

ptr +="<div class='side-by-side reading'>";

ptr +=(int)altitude;

ptr +="<span class='superscript'>m</span></div>";

ptr +="</div>";

ptr +="<div class='data altitudereal'>";

ptr +="<div class='side-by-side icon'>";

ptr +="<svg enable-background='new 0 0 58.422 40.639'height=40.639px id=Layer_1 version=1.1 viewBox='0 0 58.422 40.639'width=58.422px x=0px xml:space=preserve xmlns=http://www.w3.org/2000/svg xmlns:xlink=http://www.w3.org/1999/xlink y=0px><g><path d='M58.203,37.754l0.007-0.004L42.09,9.935l-0.001,0.001c-0.356-0.543-0.969-0.902-1.667-0.902";

ptr +="c-0.655,0-1.231,0.32-1.595,0.808l-0.011-0.007l-0.039,0.067c-0.021,0.03-0.035,0.063-0.054,0.094L22.78,37.692l0.008,0.004";

ptr +="c-0.149,0.28-0.242,0.594-0.242,0.934c0,1.102,0.894,1.995,1.994,1.995v0.015h31.888c1.101,0,1.994-0.893,1.994-1.994";

ptr +="C58.422,38.323,58.339,38.024,58.203,37.754z'fill=#955BA5 /><path d='M19.704,38.674l-0.013-0.004l13.544-23.522L25.13,1.156l-0.002,0.001C24.671,0.459,23.885,0,22.985,0";

ptr +="c-0.84,0-1.582,0.41-2.051,1.038l-0.016-0.01L20.87,1.114c-0.025,0.039-0.046,0.082-0.068,0.124L0.299,36.851l0.013,0.004";

ptr +="C0.117,37.215,0,37.62,0,38.059c0,1.412,1.147,2.565,2.565,2.565v0.015h16.989c-0.091-0.256-0.149-0.526-0.149-0.813";

ptr +="C19.405,39.407,19.518,39.019,19.704,38.674z'fill=#C5A6CE /></g></svg>";

ptr +="</div>";

ptr +="<div class='side-by-side text'>Altitude Real</div>";

ptr +="<div class='side-by-side reading'>";

ptr +=(int)altitudereal;

ptr +="<span class='superscript'>m</span></div>";

ptr +="</div>";

ptr +="</div>";

ptr +="</body>";

ptr +="</html>";

return ptr;

}


Then, upload the code to your NodeMCU board. Make sure you have selected the right board and COM port. Also, make sure you’ve inserted your WiFi Credentials in the code.

After a successful upload, open the Serial Monitor at a baud rate of 115200. Press the “EN/RST” button on the ESP8266 board. Now it should print its IP address.




727 views0 comments

Comments


bottom of page