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.