XY-MD02 Temperature and Humidity Sensor

I had ordered months ago a XY-MD02 Temperature and Humidity Transmitter Detection Sensor Module Modbus SHT40 Temperature Sensor from some Chinese source (it is available from many on-line shops). Now I had finally some time to test it.


Product name: temperature and humidity transmitter
DC power supply: DC 5V-30V
Output signal: RS485 signal
Temperature accuracy: ±0.5℃ (25℃)
Humidity accuracy: ±3%RH
Temperature range: 0%RH-80%RJ
Temperature resolution: 0.1℃
Humidity resolution: 0.1%RH
Equipment power consumption: ≤0.2W
Communication address: 1-247 can be set, default 1
Communication protocol: Modbus-RTU protocol and custom common protocol
Baud rate: configurable, default 9600, 8-bit data, 1-bit stop, no parity

This product integrates the MODBUS protocol and the common protocol Using RS485 hardware interface. The user can choose the communication protocol. The product adopts industrial grade chip, high-precision SHT40 temperature and humidity sensor.


My plan was to first test it with Modbus protocol. I wired this sensor to PC using a cheap “no name” USB to RS-485 adapter. For powering the sensor I used 5V from USB port (wired to sensor with cut USB cable).


Here is the overview of the supported Modbus communications protocol.


I think I need to read the temperature and humidity register. To use it I need some software to handle Modbus communications and help testing if it works.

CAS Modbus Scanner is a free proprietary application from Chipkin Automation Systems that I used as first tool to verify that basic Modbus communications works and devices could be found on but. It’s Discover functionality allowed to find that device is there, but for some reason the software did not seem to get successfully data from it.


So it seems that I needed some other tool to make communications work. PowerHud Mobbus Tester from https://www.modbustester.com/ could read the data successfully from the sensor.


How to interpret data info from https://www.aliexpress.com/item/1005001475675808.html


In addition to Modbus protocol, there is another protocol called common protocol. That “common protocol” is a simple ASCII protocol that can be used with any common serial port terminal program. I followed the instructions from XY-MD02 Temp Humidity Serial UART Communication article and video. Here is the most important takeout of special Putty settings in addition to serial port (9600 BPS 8N1) needed to get communications to work:


I got this other protocol to work with Putty program. The READ command reads the temperature and humidity values.


The common protocol has said to have an automatic upload function (connecting RS485 through the serial port adjustment tool will automatically output temperature and humidity). That can be started using command AUTO.

Links to more material:

XY-MD02 Sensor Setting – Modbus RTU Network

XY-MD02 Temp Humidity Serial UART Communication


Product pages with data:


Source code links:


Be the first to post a comment.

Leave a Comment

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