Humidity Measurement Using HYT939 and Arduino Nano

Humidity Measurement Using HYT939 and Arduino Nano

HYT939 is a digital humidity sensor which works on I2C communication protocol.

  • 2 respects

Components and supplies

Apps and online services

About this project


HYT939 is a digital humidity sensor which works on I2C communication protocol. Humidity is a pivotal parameter when it comes to medical systems and laboratories. So, in order to accomplish these goals, we tried to interface HYT939 with Arduino Nano. In this tutorial, the interfacing of the HYT939 sensor module with Arduino Nano is demonstrated.

To read the humidity values, we have used Arduino with an I2C adapter. This I2C adapter makes the connection to the sensor module easy and more reliable.

The communication protocol on which the sensor works is I2C. I2C stands for the inter-integrated circuit. It is a communication protocol in which the communication takes place through SDA (serial data) and SCL (serial clock) lines. It allows connecting multiple devices at the same time. It is one of the simplest and most efficient communication protocol.

Step 1: Hardware required

The materials that we need for accomplishing our goal includes the following hardware components:

1. HYT939

2. Arduino Nano

3. I2C Cable

4. I2C shield for Arduino Nano

Step 2: Hardware Hookup

The hardware hookup section basically explains the wiring connections required between the sensor and the Arduino Nano. Ensuring correct connections is a basic necessity while working on any system for the desired output. So, the requisite connections are as follows:

  • The HYT939 will work over I2C. Here is the example wiring diagram, demonstrating how to wire up each interface of the sensor.
  • Out-of-the-box, the board is configured for an I2C interface, as such we recommend using this hookup if you’re otherwise agnostic. All you need is four wires!

Only four connections are required Vcc, Gnd, SCL and SDA pins and these are connected with the help of I2C cable. These connections are demonstrated in the pictures above.

Step 3: Arduino Code for humidity measurement

Let's start with the Arduino code now. While using the sensor module with the Arduino, we include the Wire.h library. This library contains the functions which facilitate the I2C communication between the sensor and the Arduino board.

The entire Arduino code is given below for the convenience of the user:

// HYT939 I2C address is 0x28(40)
#define Addr 0x28
void setup()
// Initialise I2C communication as MASTER  
// Initialise Serial Communication  
void loop()
unsigned int data[4]; 
// Start I2C Transmission  
// Send normal mode command  
// Stop I2C transmission  
// Request 4 bytes of data  
Wire.requestFrom(Addr, 4);
// Read 4 bytes of data  
// humidity msb, humidity lsb, temp msb, temp lsb  
if(Wire.available() == 4)  
data[0] =;    
data[1] =;    
data[2] =;    
data[3] =;        
// Convert the data to 14-bits    
float humidity = (((data[0] & 0x3F) * 256.0) +  data[1]) * (100.0 / 16383.0);    
float cTemp = (((data[2] * 256.0) + (data[3] & 0xFC)) / 4) * (165.0 / 16383.0) - 40;    
float fTemp = (cTemp * 1.8) + 32;        
// Output data to serial monitor    
Serial.print("Relative Humidity : ");    
Serial.println(" %RH");    
Serial.print("Temperature in Celsius : ");    
Serial.println(" C");   
Serial.print("Temperature in Fahrenheit : ");    
Serial.println(" F");  

In the wire library, Wire.write() and are used to write the commands and read the sensor output. Following part of the code illustrates the reading of sensor output.

// Read 4 bytes of data  
// humidity msb, humidity lsb, temp msb, temp lsb  
if(Wire.available() == 4)  
data[0] =;    
data[1] =;    
data[2] =;    
data[3] =;

The sensor output is shown in the picture above.

Step 4: Applications

HYT939, being efficient digital humidity sensors, are employed in medical systems and autoclaves. Pressure dew point measurement and drying systems also find the usage of this sensor module. In various laboratories where appropriate humidity level is a pivotal parameter for conducting experiments, this sensor can be deployed there for humidity measurements.



HYT939 Schematic
Fm4airyiptjfb4c tdkmmao9vh


Similar projects you might like

Add projectSign up / Login