Generic Generic XY-MD02 RS485 Temperature and Humidity Sensor Modbus RTU template

Generic XY-MD02 RS485 Temperature and Humidity Sensor

RS485 sensor that measures temperature and relative humidity.

The XY-MD02 is an RS485 sensor that measures temperature and relative humidity in rooms, control cabinets and storage spaces. This Modbus RTU template reads both values and lets you set the device address, the baud rate and a correction for each reading from ModbusCloud.

Protocol
Modbus RTU
Connection
RS485, 9600 baud
Registers
6, read and write
Brand
Generic
Key readings
Temperature · Relative humidity · Temperature and humidity correction
Available commands
Device address · Baud rate · Temperature correction · Humidity correction
Compatible models
XY-MD02
Last updated

Registers (6)

6 read, 4 write

NameUnitAccessAddress (Hidden until you enter your email)Function (hidden)Type (hidden)
Temperature°CRead1FC04int16
Humidity%RHRead2FC04uint16
Device AddressRead and write257FC03 / FC06uint16
Baud RateRead and write258FC03 / FC06uint16
Temperature Correction°CRead and write259FC03 / FC06int16
Humidity Correction%RHRead and write

Loading registers…

The ModbusCloud Gateway, front at an angle, with the RS485 terminal and the antenna connectors

Send your device list

If a device is not in the library yet, we build the template for free as soon as we have the register data.

Use cases

  • Show temperature and humidity of a server room, cold store or warehouse on a dashboard, with 365 days of history.
  • Get an email when the humidity in a greenhouse, archive or crawl space rises above your limit.
  • Watch for frost in an outdoor cabinet or freezer room; temperatures below zero are read correctly.
  • Align a sensor with a reference instrument by setting its temperature or humidity correction remotely.
  • Check the address and baud rate of each sensor before you add more sensors to the same RS485 line.

Installation

  1. Connect A+ and B- to RS485 A and B on the ModbusCloud Gateway and power the sensor with 5 to 30 V DC. Terminate a long line with 120 ohm.

  2. Give each sensor its own address before you connect several to one bus. The factory address is 1.

  3. In ModbusCloud, add a Modbus device (RTU) with address 1, 9600 baud, 8 data bits, no parity and 1 stop bit, and import this template.

  4. Check that temperature and humidity match the room.

Things to watch for

The sensor does not answer. What should I check?

Check that A+ goes to A and B- to B; swapped wires are the most common cause. Out of the box the sensor uses address 1, 9600 baud, 8 data bits, no parity and 1 stop bit.

Below freezing the temperature shows over 6500 °C.

The temperature is a signed value. A copy of the template that reads it as unsigned turns -20.5 °C into 6533.1. Keep the data type from this template.

How do I change the address or the baud rate?

Write the new value to Device Address or Baud Rate, then change the device settings in ModbusCloud to match. Read Baud Rate first: if it shows 0, the sensor uses codes (0 = 9600, 1 = 14400, 2 = 19200); if it shows 9600, write the baud rate itself.

How do I correct a reading that is off?

Write a correction to Temperature Correction or Humidity Correction, from -10.0 to 10.0 °C or %RH. Compare the result with a reference instrument and adjust in small steps.

Readings drop out with several sensors on one cable.

Give each sensor its own address; two sensors on address 1 disturb each other. Terminate both ends of a long line with 120 ohm and keep the power supply close to the sensors.

Want to see how it works?

Electrician working in an open distribution board