bhaskar
Published © Apache-2.0

ESP8266 temp Humidity monitoring web app using Arduino IDE

the new ESP8266 WiFi works with arduino IDE, this ESP8266 comes with UART,I2C and GPIO. can be programmed directly from arduino IDE

IntermediateFull instructions provided2 hours4,732
ESP8266 temp Humidity monitoring web app using Arduino IDE

Things used in this project

Hardware components

Adafruit HUZZAH ESP8266 Breakout
Adafruit HUZZAH ESP8266 Breakout
×1
ControlEverything.com HIH6130
×1
ControlEverything.com I2C adapter for ESP8266
×1
ControlEverything.com I2C cable
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

ESP8266 schematic

This will show how you can connect your ESP8266 to an I2C sensor

Code

Code snippet #1

Plain text
#include <ESP8266WiFi.h>

#include<WiFiClient.h>
#include <ESP8266WebServer.h>
#include<ESP8266mDNS.h>
#include <Wire.h>
// HIH6130 I2C address is 0x27(39)

#define Addr 0x27

const char* ssid     = "NETGEAR34";
const char* password = "sillyviolet195";

ESP8266WebServer server ( 80 );

////////////////////////////////////////////////////////////////
void handleRoot() {
  char temp[400];
  unsigned int data[4];
   Wire.beginTransmission(Addr);
  // Select data register
  Wire.write(0x00);
  // Stop I2C Transmission
  Wire.endTransmission();</p><p>  // Request 4 bytes of data
  Wire.requestFrom(Addr, 4);</p><p>  // Read 4 bytes of data
  // humidity msb, humidity lsb, temp msb, temp lsb
  if (Wire.available() == 4)
  {
    data[0] = Wire.read();
    data[1] = Wire.read();
    data[2] = Wire.read();
    data[3] = Wire.read();
  }</p><p>  // Convert the data to 14-bits
  int humidity = ((((data[0] & 0x3F) * 256) + data[1]) * 100.0) / 16383.0;
  int temp1 = ((data[2] * 256) + (data[3] & 0xFC)) / 4;
  int cTemp = (temp1 / 16384.0) * 165.0 - 40.0;
  int fTemp = cTemp * 1.8 + 32;</p><p>  // Output data to serial monitor
  Serial.print("Relative Humidity :");
  Serial.print(humidity);
  Serial.println(" %RH");
  Serial.print("Temperature in Celsius :");
  Serial.print(cTemp);
  Serial.println(" C");
  Serial.print("Temperature in Fahrenheit :");
  Serial.print(fTemp);
  Serial.println(" F");
  delay(500);</p><p> snprintf ( temp, 400,</p><p>"
\
  
\
    
\
    
</p><p>\
    
</p><p>\
  </p><p>\
  
\
    
</p><h1>Weather Monitoring using ESP8266</h1><p>\
    
</p><h1>HIH6130 I2C sensor mini Module</h1><p>\
    
</p><p>fTemp_cTemp_Humidity: %02d:%02d:%02d</p><p>\
    </p><p>\
</p><p>",</p><p>    fTemp, cTemp, humidity
  );
  
  server.send ( 200, "text/html", temp );
  }
/////////////////////////////////////////////////////////////////
void handleNotFound() {
  String message = "File Not Found\n\n";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += ( server.method() == HTTP_GET ) ? "GET" : "POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";</p><p>  for ( uint8_t i = 0; i < server.args(); i++ ) {
    message += " " + server.argName ( i ) + ": " + server.arg ( i ) + "\n";
  }</p><p>  server.send ( 404, "text/plain", message );
}</p><p>void setup ( void ) {
  Wire.begin(2,14);
  Serial.begin ( 115200 );
  WiFi.begin ( ssid, password );
  Serial.println ( "" );</p><p>  // Wait for connection
  while ( WiFi.status() != WL_CONNECTED ) {
    delay ( 500 );
    Serial.print ( "." );
  }</p><p>  Serial.println ( "" );
  Serial.print ( "Connected to " );
  Serial.println ( ssid );
  Serial.print ( "IP address: " );
  Serial.println ( WiFi.localIP() );</p><p>  if ( MDNS.begin ( "esp8266" ) ) {
    Serial.println ( "MDNS responder started" );
  }</p><p>  server.on ( "/", handleRoot );</p><p> 
  server.onNotFound ( handleNotFound );
  server.begin();
  Serial.println ( "HTTP server started" );
}</p><p>void loop ( void ) {
  server.handleClient();
}</p>

Github

https://github.com/bhaskar-anil429/ESP8266-Weather-web-app

Github

https://github.com/ControlEverythingCommunity/HIH6130

Github

https://github.com/esp8266/Arduino

Credits

bhaskar

bhaskar

6 projects • 14 followers
Hardware engineer

Comments