Home CodeArduino Due Arduino Due and SHT11 digital humidity sensor example

Arduino Due and SHT11 digital humidity sensor example

by shedboy71

The SHT1x digital humidity sensor is a reflow solderable sensor. The SHT1x series consists of a low-cost version with the SHT10 humidity sensor, a standard version with the SHT11 humidity sensor, and a high-end version with the SHT15 humidity sensor. As with every other Sensirion sensor type from the SHTxx humidity sensor family, they are fully calibrated and provide a digital output.

The humidity sensors are seamlessly coupled to a 14-bit-analog-to-digital converter and a serial interface circuit. This results in superior signal quality, a fast response time, and insensitivity to external disturbances (EMC).

One thing to note is that these sensors have been effectively replaced by others in sensirion’s range such as the SHT31 but they are still usable and for the hobbyist and plenty of these can still be purchased online

 

Layout

Arduino Due and SHt11

Arduino Due and SHt11

 

Code

You need to install the library from – https://github.com/practicalarduino/SHT1x to run this example

I used pins 8 and 9 for the data and clk, you could use any applicable I/O pins with this device, its not I2C

[codesyntax lang=”cpp”]

#include <SHT1x.h>

// Specify data and clock connections and instantiate SHT1x object
#define dataPin  8
#define clockPin 9
SHT1x sht1x(dataPin, clockPin);

void setup()
{
   Serial.begin(38400); // Open serial connection to report values to host
   Serial.println("Starting up");
}

void loop()
{
  float temp_c;
  float temp_f;
  float humidity;

  // Read values from the sensor
  temp_c = sht1x.readTemperatureC();
  temp_f = sht1x.readTemperatureF();
  humidity = sht1x.readHumidity();

  // Print the values to the serial port
  Serial.print("Temperature: ");
  Serial.print(temp_c, DEC);
  Serial.print("C / ");
  Serial.print(temp_f, DEC);
  Serial.print("F. Humidity: ");
  Serial.print(humidity);
  Serial.println("%");

  delay(2000);
}

[/codesyntax]


 

Testing

Open the serial monitor , all going well you should see something like this

Temperature: 19.7299995422C / 67.5499954224F. Humidity: 43.06%
Temperature: 23.3199996948C / 74.9119949341F. Humidity: 50.27%
Temperature: 26.8399963379C / 80.8519973755F. Humidity: 56.58%
Temperature: 28.9300003052C / 84.4519958496F. Humidity: 59.61%
Temperature: 30.2699966431C / 86.7379913330F. Humidity: 61.15%
Temperature: 31.1699981689C / 88.2859954834F. Humidity: 62.11%
Temperature: 31.7900009155C / 89.3659973145F. Humidity: 62.81%
Temperature: 32.2299957275C / 90.1579895020F. Humidity: 63.46%
Temperature: 32.0899963379C / 89.6719970703F. Humidity: 49.05%
Temperature: 31.3399963379C / 88.2859954834F. Humidity: 35.38%
Temperature: 30.5599975586C / 86.8819961548F. Humidity: 30.40%

 

Links

Share

You may also like