Hello,
I have two TH02 and when connected to the ESP32 by I2C they only give me the following values -50ºC of Temperature and -24% of Humidity.
The code is what’s on the sensor wiki.
HI, have you encountered any difficulties?
I can see that the wiki code is for Arduino. Not sure if the library is compatible with Esp32. Try the code with an Arduino Uno. Then see if the sensor still returns unrealistic results. Thus you can be sure if the sensor is faulty or there is just an incompatibility.
Anyway, you can consider DHT22 too. It is compatible with ESP32.
According to the datasheet page 19 - section 5.1. I2C Interface seems like the right data were not given from the TH02, where -50ºC of Temperature and -24% of Humidity were the calculated conversion result based on the 0 reading value.
So I guess this could be cause by the Arduino Sketch code of the Pin definition with the wire(I2C) library used for ESP32. Maybe share your Arduino code or the error message so we could get more information to debug with.
Thanks
I dont have a arduino
Here is the code:
#include <TH02_dev.h>
#include "Arduino.h"
#include "Wire.h"
void setup()
{
Serial.begin(115200); // start serial for output
Serial.println("****TH02_dev demo by seeed studio****\n");
/* Power up,delay 150ms,until voltage is stable */
delay(150);
/* Reset HP20x_dev */
TH02.begin();
delay(100);
/* Determine TH02_dev is available or not */
Serial.println("TH02_dev is available.\n");
}
void loop()
{
float temper = TH02.ReadTemperature();
Serial.println("Temperature: ");
Serial.print(temper);
Serial.println("C\r\n");
float humidity = TH02.ReadHumidity();
Serial.println("Humidity: ");
Serial.print(humidity);
Serial.println("%\r\n");
delay(1000);
}
Thanks for the code.