Contents

Interfacing MTH02 Temperature and Humidity Sensor with Arduino

MTH02 Temperature and Humidity Sensor Features

There are various types of temperature and humidity sensors on the market in terms of price, accuracy and measurement range. The MTH02O is one the smallest type of these sensors. This sensor uses a digital pin to transfer the temperature and humidity data.

Features:

  • Low power consumption
  • Small size
  • temperature Measurement range: -40°C to +70°C with 0.5°C accuracy
  • Humidity range: 18% to 98% with 3% accuracy

Application:

  • HVAC
  • Consumer Products
  • Testing and measuring
  • Data Logging
  • Dehumidifiers
  • Humidifiers

Download the datasheet of this module here.

MTH02 Temperature and Humidity Sensor Pinout

This module has 3 pins:

  • VCC: Module power supply
  • GND: Ground
  • DATA: Digital output signal

You can see the pinout of this module here.

Required Material

Hardware component

Arduino UNO R3 × 1
MTH02 Temperature and Humidity Sensor × 1

Software Apps

Arduino IDE

Interfacing MTH02 Temperature and Humidity Sensor with Arduino

Step 1: Circuit

The following circuit shows how you should connect Arduino to MTH02 sensor. Connect wires accordingly.

Note

Use the PH connectors to connect the MTH02 module to Arduino.

Step 2: Library

Download the relevant library here and decompress it. Then copy it to Library section of Arduino.

Tip

If you need more help with installing a library on Arduino, read this tutorial: How to Install an Arduino Library

Step 3: Code

Upload the following code to your Arduino.

    /*
  MTH02-Temperature-Humidity-Sensor
  Modified on 06 Feb 2021
  by Amir Mohammad Shojaee @ Electropeak
  
Home
*/ #include "mth02.h" #define MTHPIN 12 MTH mth(MTHPIN); void setup(){ Serial.begin(9600); mth.begin(); } void loop(){ delay(5000); float tempC = mth.readTemperature(); float tempF = mth.readTemperature(true); float hum = mth.readHumidity(); Serial.print("Temp C: "); Serial.print(tempC,1); Serial.print("\t Temp F: "); Serial.print(tempF,1); Serial.print("\t Humidity: "); Serial.print(hum,1); Serial.print(" %"); Serial.println(""); }

At the beginning of this program, we include the MTH02 library. Then, in the main part of the code, ambient temperature and humidity are read and then displayed on the Serial Monitor.

You will see these parameters on the Serial Monitor: Temperature (degrees Celsius and degrees Fahrenheit) and humidity (percentage).

Liked What You See?​
Get Updates And Learn From The Best​

Leave a Reply

Your email address will not be published. Required fields are marked *