mLink Explained – DHT22 Temperature & Humidity Sensor

mLink Explained - DHT22 - BLOG IMAGE

In this video I’m showing you the mLink DHT22 sensor is a serial (I2C/IIC) temperature and humidity sensor module. It adds the ability of your microcontoller/Arduino to measure temperature (in oC) and relative humidity (%RH) to 1 decimal place using only its I2C interface. It is compatible with other mLink or standard I2C modules allowing you to daisy-chain several different types of modules together using only the two I2C pins of your microcontroller.

To install the library on the Arduino IDE see our forum post here.

For Raspberry Pi use this page here.

Here’s a video showing how to install the library.

On the support forum here there’s a quick connection example.

I use the mLink DHT22 temperature and humidity sensor, a Hobby Components Uno Plus, and male to female dupont cables.

Here’s the video

Here’s the example sketch

/* FILE:    DHT22_Read.ino
   DATE:    24/09/21
   VERSION: 1.0
   AUTHOR:  Andrew Davies

This sketch uses the mLink library to read the temperature (in oC) an humidity 
(in RH%) from the mLink DHT22 sensor module (SKU: HCMODU0181).

Please see Licence.txt in the library folder for terms of use.

#include "mLink.h"          // Include the library

mLink mLink;                // Create an instance of the library

#define I2C_ADD 0x51        // Default I2C address

void setup() 
  mLink.init();             // Initialise the library

void loop() 
  mLink.write(I2C_ADD, DHT22_START_MEAS);  // Trigger a new measurement
  while(mLink.busy(I2C_ADD));                 // Wait for the new measurement

  float temp = mLink.DHT22_Temp(I2C_ADD);     // Get the temperature in oC
  float hum =  mLink.DHT22_Hum(I2C_ADD);      // Get the humidity in %RH
  Serial.print("Temperature: "); Serial.println(temp);
  Serial.print("Humidity:    "); Serial.println(hum);

Leave a Reply

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