Sensor DHT22 and ESP8266-01

Hi everyone! I'm trying to assemble the project shown in this link: How to Show Arduino Sensor Data on a Web Page - Circuit Basics

I have everything connected the same except the voltage divider, I decided to connect the 3.3V and 5V pins directly


When I enter the IP shown in the serial monitor on my website, the readings of temperature and humidity are both 2147483647, what could be causing this? I already tested the DHT22 sensor separately and it is working properly, I am using the board library 2.5.0 for the ESP and the 1.4.0 Ardafruit library for the DHT sensor.

#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <DHT.h>
//#include <Ardafruit_DHT_Particle.h>
#include <NTPClient.h>
#include <WiFiUdp.h>

#define DHTPin 2 
#define DHTTYPE DHT22   
DHT dht(DHTPin, DHTTYPE);                

WiFiUDP ntpUDP;
const long utcOffsetInSeconds = -21600;
NTPClient timeClient(ntpUDP, "pool.ntp.org", utcOffsetInSeconds);
unsigned long epochTime = timeClient.getEpochTime();
struct tm *ptm = gmtime ((time_t *)&epochTime);

const char* ssid = "MasterExploderReloaded";  
const char* password = "CarlosAndFer2010."; 

ESP8266WebServer server(80);

String SendHTML(float TemperatureWeb,float HumidityWeb, String TimeWeb, String DateWeb);
void handle_OnConnect();
void handle_NotFound();

float Temperature;
float Humidity;
String formattedTime;
String Date;
int Day;
int Month;
int Year;

void setup() {
  Serial.begin(115200); //115200 
  pinMode(DHTPin, INPUT);           

  Serial.println("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
  delay(1000);
  Serial.print(".");
  } 
  Serial.println("");
  Serial.println("Connected to WiFi");
  Serial.print("IP: ");  Serial.println(WiFi.localIP());

  server.on("/", handle_OnConnect);
  server.onNotFound(handle_NotFound);
  server.begin();
  dht.begin();
  timeClient.begin();
}
void loop() {
  
  server.handleClient();
  
}

void handle_OnConnect() {

  timeClient.update();
 
  unsigned long epochTime = timeClient.getEpochTime(); 
  String formattedTime = timeClient.getFormattedTime();
  
  struct tm *ptm = gmtime ((time_t *)&epochTime); 

  int monthDay = ptm->tm_mday;
  int currentMonth = ptm->tm_mon+1;
  int currentYear = ptm->tm_year+1900;
 
  formattedTime = timeClient.getFormattedTime(); 
  Date = String(currentYear) + "-" + String(currentMonth) + "-" + String(monthDay);
  Temperature = dht.readTemperature(); 
  Humidity = dht.readHumidity(); 
  server.send(200, "text/html", SendHTML(Temperature,Humidity,formattedTime,Date)); 
}

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

String SendHTML(float TemperatureWeb,float HumidityWeb, String TimeWeb,String DateWeb){
  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>ESP8266 Global Server</title>\n";

  ptr +="</head>\n";
  ptr +="<body>\n";
  ptr +="<div id=\"webpage\">\n";
  ptr +="<h1>ESP8266 Global Server</h1>\n";

  ptr +="<p>Date: ";
  ptr +=(String)DateWeb;
  ptr +="</p>";
  ptr +="<p>Time: ";
  ptr +=(String)TimeWeb;
  ptr +="</p>";
  ptr +="<p>Temperature: ";
  ptr +=(int)TemperatureWeb;
  ptr +="C</p>";
  ptr +="<p>Humidity: ";
  ptr +=(int)HumidityWeb;
  ptr +="%</p>";
  
  ptr +="</div>\n";
  ptr +="</body>\n";
  ptr +="</html>\n";
  return ptr;

This is the code used

You don't need an UNO if you use an I2C based sensor, here Hum, Temp, and pressure are all served on a webpage.

/*
   Field 1 temp
   Field 2 humidity
   field 3 pressure

   GPIO0 -> SDA pin of the I2C port
   GPIO2 -> SCL pin of the I2C port

 * */

//#define serialActive   //switches serial monitoring on/off
//#define fixedIP         //need define IP and gateway

#include <Wire.h>
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <stdio.h>

MDNSResponder mdns;

const char* deviceID = "OutdoorSensors";
const char* hostName = "Outdoor Environment";

const char* ssid = "xxxxxxxx";  // Replace with your network credentials
const char* password = "xxxx";



ESP8266WebServer server(80);

String temperature;
String humidity;
String pressure;
unsigned long timer;

String webPage1 = "";
String webPage2 = "";
String webPage3 = "";


void setup() {
# ifdef serialActive
  Serial.begin(19200);
# endif

  // Initialise wifi connection
  connectWifi();

  timer = millis();

  webPage1 += "<head><title>";
  webPage1 += hostName;
  webPage1 += "</title><META HTTP-EQUIV=\"refresh\" CONTENT=\"5; URL=/\"></head>";
  webPage1 += "<meta name = \"viewport\" content = \"width = device-width\">";
  webPage1 += "
<body bgcolor=\"#E6E6FA\">
<h1 align=center>";
  webPage1 += hostName;
  webPage1 += "</h1><p align=center><a href=\"\"><button style=\"border-radius:12px;width:150px;height:50px;font-size: 16px;background-color: #e7e7e7;color:black;\"><strong>  Refresh</strong></button></a></p></body>";

  webPage3 = "</body>";

  //I2C stuff
  Wire.pins(2, 0); //swapped 0, 2 from wiring example because mistake wiring (SDA, SCL)
  Wire.begin(2, 0);
  delay(500);


  server.on("/", []() {
    server.send(200, "text/html", webPage1 + webPage2 + webPage3);
  });
  server.begin();
}

void loop() {
  if (!WiFi.status()) {
    connectWifi();   // Initialise wifi connection
  }

  if (millis() >= timer + 2000) {
    getT9602values(0x28);
    getPressure(0x2B);
    timer = millis();

    webPage2 = "<p font-size:16px; align=center><strong>";
    webPage2 += temperature + "  &#38;#176C 

" ; //&#38;#176; °
    webPage2 += humidity + "  %rH 

";
    webPage2 += pressure + "  hPa  </strong></p>";

# ifdef serialActive
    Serial.println(webPage2);
# endif
  }

  server.handleClient();

}

//________________________________________get sensor values subroutines_____________________
void getPressure(byte address) {
  //For Barometric NPA-700N-17.5A in hPa, Multiplier = 1000, Offset = 200
  // For NPA-700N-015A in hPa, Multiplier = 1034.212, Offset = 0

#define Units "hPa"
#define Multiplier 1000
#define Offset 200

  byte aa, bb, cc, dd;
  float Data_value;

  Wire.beginTransmission(address);
  Wire.write(0);
  Wire.endTransmission();

  Wire.requestFrom(address, 4);
  aa = Wire.read();
  bb = Wire.read();
  cc = Wire.read();
  dd = Wire.read();

  Data_value = ((aa & 0x3F ) << 8) | bb ;
  //Serial.print(aa);Serial.print(", ");Serial.print(bb);Serial.print(", ");Serial.print(cc);Serial.print(", ");Serial.print(dd);Serial.print(", ");
  Data_value = (float)(( Data_value - 1638 ) / ( 14745 - 1638 )) * Multiplier + Offset;
  pressure = ftos(round ((float) Data_value), 0, 4);
}


void getT9602values(byte address)
{

  byte aa, bb, cc, dd;
  double var;

  Wire.beginTransmission(address);
  Wire.write(0);
  Wire.endTransmission();

  Wire.requestFrom(address, 4);
  aa = Wire.read();
  bb = Wire.read();
  cc = Wire.read();
  dd = Wire.read();

  // humidity = (rH_High [5:0] x 256 + rH_Low [7:0]) / 16384 x 100
  var  = round((float)(((unsigned)(aa & 0x3F ) << 8) + (unsigned)bb) / 16384.0 * 100.0);
  humidity = ftos(var, 1, 4);

  // temperature = (Temp_High [7:0] x 64 + Temp_Low [7:2]/4 ) / 16384 x 165 - 40
  var = round((float)((unsigned)(cc  * 64) + (unsigned)(dd >> 2 )) / 16384.0 * 165.0 - 40.0);
  temperature = ftos(var, 1, 4); //Float Value, Number of Decimals, characters to return
}


String ftos(float var, int nd, int cc) // variable, number of decimal places, character count
{
  int j;
  char buffer1[10];
  String buffer2;

  dtostrf(var, cc, nd, buffer1);  //dtostrf(floatvar, StringLengthIncDecimalPoint, numVarsAfterDecimal, charbuf);
  for (j = 0; j < cc; j++) {
    buffer2 = buffer2 + buffer1[j];
  }
  return buffer2;
}

//______connect to wifi – returns true if successful or false if not
void connectWifi() {
  WiFi.hostname(deviceID);
  boolean state = true;
  int i = 0;


  WiFi.mode(WIFI_STA);
#ifdef fixedIP
  WiFi.config(ip, gateway, subnet);               // IP Address, DNS, gateway, subnet
#endif
  WiFi.begin(ssid, password);

# ifdef serialActive
  Serial.println("");
  Serial.println("Connecting to WiFi");

  // Wait for connection
  Serial.print("Connecting ...");
# endif

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
# ifdef serialActive
    Serial.print(".");
# endif
    if (i > 10) {
      state = false;
      break;
    }
    i++;
  }
# ifdef serialActive
  if (state) {
    Serial.println("");
    Serial.print("Connected to ");
    Serial.println(ssid);
    Serial.print("IP address: ");
    Serial.println(WiFi.localIP());

  }
  else {
    Serial.println("");
    Serial.println("Connection failed.");
  }
# endif

  if (mdns.begin("esp8266", WiFi.localIP())) {
#ifdef serialActive
    Serial.println("MDNS responder started");
#endif
  }
}

Sensors are an Amphenol 3.3V T9602 Hum/Temp, and an Amphenol NPA series pressure sensor.