Convert code RHT03 to DHT11 ESP8266

hi i try to convert this code for working with DHT11 , the original code is for RHT03

THIS IS THE CODE, THE QUESTION IS HOW CHANGE ALL PARAMETRS FOR WORK TO DHT11

Hola estoy tratando de convertir este codigo que esta escrito para el sensor RHT03 origininalmente pero como no tengo ese sensor quiero adaptar el codigo para que me funcione con un DHT11 que si tengo a la mano, no soy muy experto con el codigo de arduino y quisiera una mano amiga la placa donde lo estoy corriendo es un ESP8266.

estoy tratando por mi parte de adaptarlo pero no logro dar.

#include <SparkFun_RHT03.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>


const int RHT_SENSOR_PIN = 4;

// Objects to be initialized
WiFiServer server(SERVER_PORT); 
RHT03 rht;

void setup () {
    // Setup for Arduino Uno + ESP8266 connection
    Wire.begin(ESP_SDA_PIN, ESP_SCL_PIN);
    
    // Begin transmission with slave on 115200
    Serial.begin(TRANSMISSION_BAUD_RATE);
    Wire.beginTransmission(WIRE_ADDRESS);
    
    // Print results to 9600
    Serial.begin(PRINT_BAUD_RATE);
    WiFi.begin(WIFI_USER, WIFI_PASS);
    rht.begin(RHT_SENSOR_PIN);
    server.begin();
    
    while (WiFi.status() != WL_CONNECTED) {
        Serial.println("Connecting...");
        delay(DELAY_TIME);
    }
}

void sendMetricsToWebApp() {
    int rhtResult[2];
    int latestHumidityValue;
    int latestTemperatureValue;
    
    // (1) Get humidity and temperature data...
    int rhtResultCode = updateRHTSensor(rhtResult);
    if (rhtResultCode == ERROR_CODE) {
        Serial.println("RHT sensor update failed...\n");
        delay(DELAY_TIME);   
        return;
    }
    latestHumidityValue = rhtResult[0];
    latestTemperatureValue = rhtResult[1];
    Serial.println("Humidity = " + String(latestHumidityValue) + " %");
    Serial.println("Temp (F) = " + String(latestTemperatureValue) + " degrees");

int updateRHTSensor(int* rhtResult) {
    int rhtUpdate = rht.update();
    
    if (rhtUpdate == SUCCESS_CODE) {
        rhtResult[0] = rht.humidity();
        rhtResult[1] = rht.tempF();
        return SUCCESS_CODE;
    }
    else {
        return ERROR_CODE;
    }
}

Please follow the advice given in the link below when posting code. Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

Moderator:
Moved from Spanish forum to English Forum.

Other post/duplicate DELETED
Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.

Continued cross posting could result in a time out from the forum.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.