trijalsrimal
Published © GPL3+

Esp Data Transferring System

This esp controlled system can take data from the surroundings and send it in real time to a webpage.

BeginnerFull instructions provided253
Esp Data Transferring System

Things used in this project

Hardware components

Grove - Barometer Sensor (BMP280)
Seeed Grove - Barometer Sensor (BMP280)
×1
BH1750 light intensity sensor
×1
NODE MCU ESP8266 12-E
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×2
Jumper wires (generic)
Jumper wires (generic)
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1
9V battery (generic)
9V battery (generic)
×1
9V Battery Clip
9V Battery Clip
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1

Software apps and online services

Arduino IDE
Arduino IDE
Fritzing
Arduino Web Editor
Arduino Web Editor

Story

Read more

Schematics

FRITZING FILE FOR THE PROJECT

Code

CODE FOR THE PROJECT

Arduino
#include <ESP8266WebServer.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>
#include <BH1750.h>
#define SEALEVELPRESSURE_HPA (1013.25)
IPAddress local_IP(192, 168, 10, 147  );
IPAddress gateway(192, 168, 10, 1);
IPAddress subnet(255, 255, 0, 0);
IPAddress primaryDNS(8, 8, 8, 8);   //optional
IPAddress secondaryDNS(8, 8, 4, 4); //optional
Adafruit_BMP280 bmp;
BH1750 lightMeter;
float temperature, lux, pressure;
const char* ssid = "Amit";  // Enter SSID here
const char* password = "keshariyaji19";  //Enter Password here


//change this with the pin that you use

ESP8266WebServer server(80);              
 
void setup() {
  Serial.begin(115200);
  delay(100);
   Wire.begin();
  bmp.begin(0x76);   
lightMeter.begin();

  Serial.println("Connecting to ");
  Serial.println(ssid);
  if (!WiFi.config(local_IP, gateway, subnet, primaryDNS, secondaryDNS)) {
    Serial.println("STA Failed to configure");
  }
  
  WiFi.begin(ssid, password);

  
  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() / 100.0F;
  lux = lightMeter.readLightLevel();
  server.send(200, "text/html", SendHTML(temperature,lux,pressure)); 
}

void handle_NotFound(){
  server.send(404, "text/plain", "Not found");
}

String SendHTML(float temperature,float lux ,float pressure){
  String ptr = "<!DOCTYPE html> <html>\n";
  ptr +="<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, user-scalable=no\">\n";
  ptr +="<title>Trijal's Environment Sensing Station</title>\n";
  ptr +="<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;background-color:red;}\n";
  ptr +="body{margin-top: 50px;} h1 {color:cyan ;margin: 50px auto 30px;}\n";
  ptr+= "p {font-size: 30px;color: violet ;margin-bottom: 20px;}\n";  ptr +="</style>\n";
  ptr +="</head>\n";
  ptr +="<body>\n";
  ptr +="<div id=\"webpage\">\n";
  ptr +="<h1>TRIJAL'S ENVIRONMENTAL STATION</h1>\n";
  ptr +="<p>Temperature: ";
  ptr +=temperature;
  ptr +="&deg;C</p>";
  ptr +="<p>Light Intensity: ";
  ptr +=lux;
  ptr +="lux</p>";
  ptr +="<p>Pressure: ";
  ptr +=pressure;
  ptr +="hPa</p>";
  ptr +="</div>\n";
  ptr +="</body>\n";
  ptr +="</html>\n";
  
return ptr;
  }
  

Credits

trijalsrimal

trijalsrimal

0 projects • 1 follower

Comments

Add projectSign up / Login