ESP-12E Based Weather Station – NodeMCU 12-E, BME280 and Yaler

By | July 20, 2019

Preface :

  • Develop a Weather Station which can be accessed through the internet

Advantage :

  • Extremely low budget
  • Easily available hardware
  • Easy to configure

Hardware Components Required :

  1. NodeMCU – ESP 8266-12E
  2. BME280 I2C or SPI Temperature Humidity Pressure Sensor
  3. Breadboard

Internet Subscription Required :


Hardware Details

ESP8266 – NodeMCU 12E

BME/BMP 280 Sensor

Bread Board

Jumper cables

Pin Configuration

Pin Number D3 ESP — > SDA Pin BMP/BME 280

Pin Number D4 ESP — > SDB Pin BMP/BME 280

Pin Number 3V3 ESP — > VIN Pin BMP/BME 280

Pin Number GND ESP — > GND Pin BMP/BME 280

Online Subscription for Domain

Send an email to get an account by paying their fee.

Once you get the user account note down your Relay-Host and Relay-Domain

Install Arduino (if you dont have) from

After installation Open the Arduino software.

Tools –> Boards –> Board Manager

You can also download the Yaler library files from

Once download copy to Arduino Library folder make sure your folder looks like below.


Internet Accessible Weather Station by Haneef Puttur


#include <Wire.h>
#include <ESP8266WiFi.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <YalerESP8266WiFiServer.h>

Adafruit_BME280 bme; // I2C

// Replace with your network details
const char* ssid = "wifiname"; // Replace with SSID
const char* password = "Password"; // Replace with Wifi Password

const char* relaydomain = ""; // Replace with relay domain from
const char* relayhost = "haneef-xxxx-xxxx"; // Replace with relay host from

float h, t, p, pin, dp;
char temperatureFString[6];
char dpString[6];
char humidityString[6];
char pressureString[7];
char pressureInchString[6];

#undef BME280_ADDRESS
#define BME280_ADDRESS (0x76)
// Web Server on port 80
//WiFiServer server(80);
YalerESP8266WiFiServer server(relaydomain, 80, relayhost);
// only runs once on boot
void setup() {
// Initializing serial port for debugging purposes
Wire.begin(D3, D4);
// Connecting to WiFi network
Serial.print("Connecting to ");

WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
Serial.println("WiFi connected");

// Starting the web server
Serial.println("Web server running. Waiting for the ESP IP...");

// Printing the ESP IP address
Serial.println(F("BME280 test"));

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

void getWeather() {

h = bme.readHumidity();
t = bme.readTemperature();
// t = t*1.8+32.0; // enable this line if you want in FarenHeit
dp = t-0.36*(100.0-h);

p = bme.readPressure()/100.0F;
pin = 0.02953*p;
dtostrf(t, 5, 1, temperatureFString);
dtostrf(h, 5, 1, humidityString);
dtostrf(p, 6, 1, pressureString);
dtostrf(pin, 5, 2, pressureInchString);
dtostrf(dp, 5, 1, dpString);


// runs over and over again
void loop() {
// Listenning for new clients
WiFiClient client = server.available();

if (client) {
Serial.println("New client");
// bolean to locate when the http request ends
boolean blank_line = true;
while (client.connected()) {
if (client.available()) {
char c =;

if (c == '\n' && blank_line) {
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close");
// your actual web page that displays temperature
client.println("<!DOCTYPE HTML>");
client.println("<head><META HTTP-EQUIV=\"refresh\" CONTENT=\"15\"></head>");
client.println("<body><h1>Haneef Puttur - Weather Station</h1>");
client.println("<table border=\"2\" width=\"456\" cellpadding=\"10\"><tbody><tr><td>");
client.println("<h3>Temperature = ");
client.println("&deg;C</h3><h3>Humidity = ");
client.println("%</h3><h3>Approx. Dew Point = ");
client.println("&deg;F</h3><h3>Pressure = ");
client.println("hPa (");
if (c == '\n') {
// when starts reading a new line
blank_line = true;
else if (c != '\r') {
// when finds a character on the current line
blank_line = false;
// closing the client connection
Serial.println("Client disconnected.");

Please dont forget edit below lines in code before uploading with your own parameters

const char* ssid = “wifiname”; // Replace with SSID

const char* password = “Password”; // Replace with Wifi Password

const char* relaydomain = “”; // Replace with relay domain from const char* relayhost = “haneef-xxxx-xxxx”; // Replace with relay host from

Run and Upload the Code.

Once successfully uploaded if all goes well you can access the Weather station from internet using the link relaydomain.relayhost   which you configured.


Updated Version of this article available below

BME 280 – Node MCU Weather Station