ESP8226 + SHT20 - wrong temperature output

Hi i am trying to create simple program that can read temperature and humidity from sht20 and send it to thingspeak server. Well, everything seems to work BUT i am getting wrong values for humidty and temperature 988 instead of correct values. What i found is that 988 means is that sensor is not found. Weird thing is that when i use sht20 sensor alone without esp sensor, board(as shown in picture below) and code it works as it should work giving "right" temperature and humidity.

#include "ESP8266WiFi.h"
#include "ESP8266HTTPClient.h"

#include <Wire.h>
#include "DFRobot_SHT20.h"

DFRobot_SHT20    sht20;

HTTPClient http;  //Declare an object of class HTTPClient
WiFiClient client;

const char* ssid = "XXXX"; //Enter SSID
const char* password = "XXXX"; //Enter Password

void setup()

{
  Serial.begin(115200);
    sht20.initSHT20();
    delay(100);
    sht20.checkSHT20();
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {

    delay(1000);
    Serial.print("Connecting..");

  }



}


void loop()
{
  if (WiFi.status() == WL_CONNECTED) { //Check WiFi connection status


    float humidity = sht20.readHumidity();
    float temperature = sht20.readTemperature();

    String url = "http://api.thingspeak.com/update?api_key=XXXXXXXXXX";
    String data = "&field1=" + String(humidity) + "&field2=" + String(temperature);

    http.begin(client, String(url + data));  //Specify request destination
    int httpCode = http.GET();                                  //Send the request

    if (httpCode > 0) { //Check the returning code

      String payload = http.getString();   //Get the request response payload
      Serial.println(payload);
      Serial.println(humidity);
      Serial.println(temperature);
    }

    http.end();   //Close connection
    delay(15000);
  } else {
    delay(15000);
  }
}



I just cant figure out whats wrong and will be thanful for any help on how to get correct data.

Hi, @jurajko
Welcome to the forum and thankyou for using code tags.

What do you mean without the ESP sensor, you only have one sensor don't you the SHT20?

Can you please post a circuit diagram?

Thanks.. Tom... :grinning: :+1: :coffee: :australia:

Yes sorry you are right esp is "wifi module" i will post my circuits but i never done it so it may take a while.


This is my circuit please note that that green thing is SHT20 up to down - VCC, SDA, GND, SCL
And during upload code from arduino there is one more ground in ESP8266 on GPIO_2

Hi,
Why have you got the RESET pin held LOW/gnd?
You shouldn't have to connect anything to the RESET pin.

Tom... :grinning: :+1: :coffee: :australia:

you have a sketch for the esp8266 but the sensor is wired to Uno

TomGeorge - I had problems uploading code to that device i found that RESET somewhere on the forum. But when i unplug that reset i have still the same problem.

Juraj - ou thanks i am pretty new to this. Please can you point me somehow to the right path of what should i do now?

Hi.

When you upload your code to the UNO do you disconnect the Tx and Rx connections to the ESP8266?
I think that may be your upload problem, Tx and Rx are used to program the UNO.

Tom... :grinning: :+1: :coffee: :australia:

@TomGeorge, don't you see that it is an esp8266 sketch? it would not work in Uno. OP uploads to esp8266. the Uno is only a USB-to-TTL-Serial adapter here

what you want?
a) buy a Wemos D1 mini, wire the sensor to it and use this sketch.
b) upload AT firmware into esp-01 and modify the sketch for Uno with my WiFiEspAT library to use the esp-01 as WiFi adapter

c) advanced option: wire the sensor to esp-01

Thanks now i know what to do :smiley:

Hi,
If you are going to buy another controller.
But an ESP32 and do all your work on that, no UNO needed.

Tom... :grinning: :+1: :coffee: :australia:

I actually ordered Wemos D1, nodecmu and gonna try it with that but yeah that esp32 looks good even bluetooth is there :smiley: