Arduino Project Hub

Humidity Measurement Using HYT939 and Arduino Nano

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

  • 157 views
  • 0 comments
  • 1 respect

Components and supplies

HYT939
×1
Ard nano
Arduino Nano R3
×1
I2C wire
×1
I2C shield
×1

Apps and online services

About this project

Introduction

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 the 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:

Lets start with the Arduino code now. While using the sensor module with the Arduino, we include Wire.h library. "Wire" 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:

#include
// HYT939 I2C address is 0x28(40)
#define Addr 0x28
void setup()
{  
// Initialise I2C communication as MASTER  
Wire.begin();  
// Initialise Serial Communication  
Serial.begin(9600);  
delay(300);
}
void loop()
{  
unsigned int data[4]; 
// Start I2C Transmission  
Wire.beginTransmission(Addr);  
// Send normal mode command  
Wire.write(0x80);  
// Stop I2C transmission  
Wire.endTransmission();  
delay(300);    
// 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] = Wire.read();    
data[1] = Wire.read();    
data[2] = Wire.read();    
data[3] = Wire.read();        
// 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.print(humidity);    
Serial.println(" %RH");    
Serial.print("Temperature in Celsius : ");    
Serial.print(cTemp);    
Serial.println(" C");   
Serial.print("Temperature in Fahrenheit : ");    
Serial.print(fTemp);    
Serial.println(" F");  
}  
delay(300);
}

In wire library Wire.write() and Wire.read() is 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] = Wire.read();    
data[1] = Wire.read();    
data[2] = Wire.read();    
data[3] = Wire.read();
}

The sensor output is shown in the picture above.

Step 4: Applications:

HYT939 being an efficient digital humidity sensor are employed in Medical systems, 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.

Schematics

HYT939 Schematic
Fm4airyiptjfb4c tdkmmao9vh

Code

Comments

Similar projects you might like

Arduino 101 BLE App

Project in progress by Alexis Santiago Allende

  • 1,689 views
  • 10 comments
  • 21 respects

FM radio

Project tutorial by Patrick Müller

  • 7,904 views
  • 1 comment
  • 34 respects

Avoid Injuries with Smart Backpack

Project tutorial by Chathuranga Liyanage

  • 932 views
  • 2 comments
  • 12 respects

Aquariumatic

Project in progress by Craig Hissett

  • 6,855 views
  • 2 comments
  • 16 respects

Arduino Digital Clock Version 2

Project showcase by John Wafik William

  • 425 views
  • 0 comments
  • 6 respects

Arduino Temperature Control

Project tutorial by Team pandhoit

  • 913 views
  • 3 comments
  • 9 respects
Add projectSign up / Login