DFRobot SHT10 humidy and temperature sensor

As part of our dust and carbon monoxide (CO) air quality sensor we need to measure air humidity as it is necessary for the CO sensor. The humidity sensor requires temperature. This sensor is simple compared to the CO sensor but I did run into a few bumps along the way giving me incorrect readings (-40). I believe this was due to some problems with the Arduino library. I also needed to alter the code to the Fio’s 3.3V rather than the common arduino 5V. I’ll provide some resources below that can help others achieve the connection of a Arduino Fio to a DFRobot SH10 humidity and temperature sensor.

Information & resources

Close up of SHT10

Temperature and humidity sensor SHT10

Connecting Fio to the SHT10 sensor

The connections are fairly simple. The red and blacks go to 3.3V and ground respectively. You just need to connect the data and clock to digital pins on the fio.

Code

The main code is simple. Note that requesting a humidity reading, readHumidity(), requires a temperature reading. Rather than making a separate request for the temperature, you can simply get the reading collected during the humidity reading – retrieveTemperatureC(). You can still make a specific request for a new temperature reading by calling readTemperatureC().

The real work in getting the sensor to work well with the Fio went into modifying the SHT1 library. To simplify I threw out any Fahrenheit measurements – it will only return Celsius. Make sure you install the modified SHT1 library on github.

#include "SHT1x.h"
#define dataPin 7
#define sckPin 8 //serial clock

// We are using the SHT10
// Humid accuracy +/- 5%
// Steady accuracy between 10-80
// example at 10/90 +/- 6%, 0/100 +/- 7.5%

// Temp accuracy +/- .5 degrees celcius
// Temp error increases more as we get farther from 25 celc.
// example: @ 0/50 degrees, +/- 1.2 degrees

SHT1x th_sensor(dataPin, sckPin);

void setup()
{
  Serial.begin(9600);
  Serial.println("Starting up");
}

void loop()
{  
  float temp_c;
  float humid;
  
  // Read values from the sensor
  humid = th_sensor.readHumidity();
  // Since the humidity reading requires the temperature we simply
  // retrieve the reading capture from the readHumidity() call. See the lib.
  temp_c = th_sensor.retrieveTemperatureC();
  
  // Print data
  Serial.print("Temperature: ");
  Serial.print(temp_c);
  Serial.print(", Humidity: ");
  Serial.println(humid);

  delay(4000);
}

Leave a Reply