You'll need to install a library to make Arduino IDE support the sensor. This library includes drivers for the HTS221 sensor and sample code for you to jumpstart your project.
For ESP32 based systems, we're currently supporting Arduino core. Please make sure you've installed the following:
ESP32 Hardware libraries for the Arduino IDE.
Python for the compilation of Arduino projects.
Drivers for your host device, e.g., USB Virtual Serial Port driver.
Please download the library archive from https://github.com/Turta-io/Modular
Then, copy its contents to your Arduino Libraries folder.
You can find the Arduino Libraries folder inside your Arduino sketch directory. It is generally located inside the My Documents folder.
The library comes with included samples. There is no need to download additional files for the examples.
The hardware, its drivers and the sample code are open source. You can use them under the terms of the MIT license. Please feel free to customize and prototype them for your projects.
Turta_TempRH_Module library is responsible for initializing the sensor, reading calibration data and reading temperature and humidity values with respect to calibration data.
To use the library on Arduino IDE, add the following #include statement to the top of your sketch.
Then, create an instance of the Turta_TempRH_Module class.
Now you're ready to access the library by calling the th instance.
To initialize the sensor, call the begin method.
This method turns the sensor on and then reads the calibration coefficients to the memory.
Returns the last measured temperature reading from the sensor.
Returns the last measured relative humidity reading from the sensor.
Double: Relative humidity.
HTS221 Sensor includes advanced functions, just like controlling its internal heater for humidity sensing. Heater control methods will be implemented in the next release.
You can open the example from Arduino IDE > File > Examples > Examples from Custom Libraries > Turta Temp RH Module. There is one example of this sensor.
If you're experiencing difficulties while working with your device, please try the following steps.
Problem: You're reading NaN instead of sensor data. Cause: The host device does not communicate with the sensor over the I2C protocol. There is a software bug on the ESP32 Arduino hardware library which prevents I2C communication. Solution: Please update the ESP32 hardware library.
Problem: Temperature reading is above, and humidity reading is below from it should be. Cause: ESP32's CPU can reach up to 240MHz, which heats itself and surroundings. Solution: For temperature and humidity reading applications, it would be better first to read the sensor data, then run the other tasks. If you're making just a temperature & humidity sensing device, you may wish to DeepSleep the host device while it is idle.
Problem: Humidity reading is much higher than it should be. Cause: In some cases, moisture does not escape from the sensor quickly. Solution: Please run the example application for a few hours and observe if the humidity level is decreasing. If not, you can bake the sensor module at 100 °C for 15 minutes to make moisture escape from the sensor's measuring hole.
Problem: Sensor readings are not accurate after inserting the sensor to the slot, while the application is running. Cause: The sensor library reads the calibration coefficients at the beginning of the application. If you insert the sensor module after the application is started, the library does not get the calibration coefficients and return inaccurate readings. Solution: Please press the reset button on the host board, or upload the application again while the sensor module is in the sensor slot.