SHT15 Humidity and Temperature Sensor Hookup Guide
This Tutorial is Retired!
This tutorial covers concepts or technologies that are no longer current. It's still here for you to read and enjoy, but may not be as useful as our newest tutorials.
SHT1X Arduino Library and Example
Luckily, there is an Arduino library and some example code to make using the SHT15 as easy as possible. Grab the SHT15 library for Arduino from the SHT15 GitHub Repository , or you can download the files directly from the button below. Alternative library options can be found here.
Need help using the Library Manager or want to install the library the old fashioned way? Visit our Arduino Library tutorial, for more information.
Alternatively, you can use the Sensirion Library.
Once the library is installed, open Arduino, and expand the examples menu. You should see the SHT_1X submenu.
Load this example onto the Arduino. Open the serial terminal at 9600bps. You will see the current humidity and temperature in the room!
Here is the same example sketch if you would rather copy and paste:
language:c
/******************************************************************************
SHT15 Example
Joel Bartlett @ SparkFun Electronics
16 Sept 2015
This example shows how to get the temperature in F or C and humidity
Developed/Tested with:
SparkFun RedBoard
Arduino IDE 1.6.5
Connections:
GND -> A2
Vcc -> A3
DATA -> A4
SCK -> A5
Requires:
SHT1X Arduino Library
https://github.com/sparkfun/SHT15_Breakout/
This code is beerware.
Distributed as-is; no warranty is given.
******************************************************************************/
#include <SHT1X.h>
//variables for storing values
float tempC = 0;
float tempF = 0;
float humidity = 0;
//Create an instance of the SHT1X sensor
SHT1x sht15(A4, A5);//Data, SCK
//delacre output pins for powering the sensor
int power = A3;
int gnd = A2;
void setup()
{
Serial.begin(9600); // Open serial connection to report values to host
pinMode(power, OUTPUT);
pinMode(gnd, OUTPUT);
digitalWrite(power, HIGH);
digitalWrite(gnd, LOW);
}
//-------------------------------------------------------------------------------------------
void loop()
{
readSensor();
printOut();
delay(1000);
}
//-------------------------------------------------------------------------------------------
void readSensor()
{
// Read values from the sensor
tempC = sht15.readTemperatureC();
tempF = sht15.readTemperatureF();
humidity = sht15.readHumidity();
}
//-------------------------------------------------------------------------------------------
void printOut()
{
Serial.print(" Temp = ");
Serial.print(tempF);
Serial.print("F, ");
Serial.print(tempC);
Serial.println("C");
Serial.print(" Humidity = ");
Serial.print(humidity);
Serial.println("%");
}