Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » Connecting RS485 Soil Moisture & Temperature Sensor to Arduino
Arduino Projects

Connecting RS485 Soil Moisture & Temperature Sensor to Arduino

Mamtaz AlamBy Mamtaz AlamUpdated:September 18, 20237 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
Connecting RS485 Soil Moisture & Temperature Sensor to Arduino
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

Overview:

In this guide, we will explore how to interface a Soil Moisture & Temperature Sensor with Arduino using the RS485 protocol. This setup will allow us to monitor the moisture content and temperature of the soil, which are crucial parameters for agriculture and gardening.

Soil moisture sensors measure the volumetric water content in soil. By understanding the moisture levels, farmers and gardeners can make informed decisions about irrigation, ensuring optimal plant growth. The temperature of the soil also plays a significant role in plant health, affecting root growth and nutrient uptake.

Soil Temperature & Moisture Sensor

For this project, we will utilize the Renkeer Soil Moisture & Temperature Sensor, which is specifically designed for in-ground measurements. This sensor can measure soil moisture levels ranging from 0% to 100% and soil temperature from -40°C to 60°C with impressive accuracy. Its low-power consumption makes it ideal for remote locations, powered by solar panels or batteries. Earlier, we used Capacitive Soil Moisture Sensor and also Resistive Soil Moisture Sensor, but they are not industrial graded.

Therefore we are using Industrial Grade Soil Sensor for this project. To interface the sensor with the Arduino, we will use the RS485 communication protocol. The data from the Soil Moisture & Temperature Sensor will be presented on an OLED screen connected to the Arduino.



Bill of Materials

For this project, we need the following components. You can purchase all these components from the given links.

S.N.ComponentsQuantityPurchase Link
1Arduino Nano Board1Amazon | AliExpress | SunFounder
2Soil Temperature Humidity Sensor1Renkeer
30.96" I2C OLED Display1Amazon | AliExpress | SunFounder
4MAX485 Module1Amazon | AliExpress | SunFounder
55V Power Supply1Amazon | AliExpress | SunFounder
6Jumper Wires10Amazon | AliExpress | SunFounder
7Breadboard1Amazon | AliExpress | SunFounder

Soil Moisture & Temperature Sensor

The Soil Temperature and Humidity Sensor is a device designed to check soil warmth and wetness.

Soil Temperature Humidity Sensor

It’s compared with high-quality German sensors to make sure it’s accurate. This sensor is quick to give results and works reliably. It’s good for all soil types, even those with salts. One thing to note is when measuring frozen ice layers, the water value might be low and not accurate, so users need to adjust for that. One of its best features is that it can be left in the ground for a long time. It won’t corrode and is completely waterproof.

This sensor is useful in many areas. It’s great for science projects, helping farmers save water, and making sure plants in greenhouses grow well. It’s also used in places like sewage plants and grain storage.

Technical Parameters

  1. Supply power: 4.5~30V DC
  2. Power consumption: 0.4W
  3. Moisture measurement range: 0~100% RH
  4. Temperature measurement range: -40℃~60℃(personal)
  5. Moisture accuracy: ±3%RH(default)
  6. Temperature accuracy: ±0.5℃(default)
  7. Work environment: -20℃~60℃,0~80%RH
  8. Output signal: RS485
  9. Parameter configuration: software



Physical Parameters

  1. Probe length: 70 mm
  2. Probe diameter: 3 mm
  3. Probe material: 304 stainless steel
  4. Sealing material: Epoxy resin (black flame retardant)
  5. Cable length: standard two meters (RVV 4 * 0.3)
  6. Protection class: IP68

How To Use

1. Speed Measurement Method:
Choose the right spot for measurement, avoiding areas with stones. Ensure the needle doesn’t hit any hard objects. Clear the topsoil up to the desired measurement depth, but keep the soil below compact.

Insert the sensor vertically into the soil without shaking it side to side. For accurate results, it’s recommended to take an average from several measurements at a small point.

2. Buried measurement method:
For accurate measurements using the probe, dig a vertical pit with a diameter exceeding 20cm. Once dug, the probe should be inserted horizontally into the pit wall at the desired depth.

After inserting the probe, ensure the pit is filled tightly and allowed to stabilize. This stabilization can take several days, months, or even longer. Once stable, you can begin extended measurement and recording sessions.

Sensor Pinout

The Soil Moisture & Temperature Sensors works on RS485 Protocol and hence can communicate with easily with Arduino, ESP32 or any other microcontrollers using RS485 Module.

Here are the 4 wires for the sensor.

  • Brown Wire:  VCC (10-30V)
  • Black Wire: GND
  • Yellow Wire: RS485-A
  • Blue Wire: RS485-B




Data Frame Format Definition & Communication Protocol

Data frame format definition

Using the Modbus-RTU communication protocol, the format is as follows:

  • Initial structure ≥ 4 bytes of time
  • Address code = 1 byte
  • Function code = 1 byte
  • Data area = N bytes
  • Incorrect revision = 16 byte CRC code
  • Ending structure ≥4 byte time

Host query frame structure:

Address Code Function Code Register Origin Address Register Length Check code Low Bit Check Code High Bit
1 byte 1 byte 2 bytes 2 bytes 1 byte 1 byte

Slave response frame structure:

Address Code Function Code Effective Bytes Data Area 1 Data Area 2 Data Area N Revision Code
1 byte 1 byte 1 byte 2 bytes 2 bytes 2 bytes 2 bytes

Read the Soil Moisture & Temperature Value

Inquiry frame:

Address Code Function Code Initial Address Data Length Check code Low Bit Check Code High Bit
0x01 0x03 0x00 0x00 0x00 0x02 0xC4 0x0B

Response frame:

Address Code Function Code Returns Byte Number Humidity Number Temperature Number Check code low bit Check code high bit
0x01 0x03 0x04 0x02 0x92 0xFF 0x9B 0x5A 0x3D

Temperature calculation :
When temperature is under 0 ℃, the temperature date will be updated in complement code.
Temperature: FF9B H(hexadecimal)= -101 => temperature = -10.1℃
Humidity calculation:
Humidity: 292 H (hexadecimal)= 658 => humidity = 65.8%RH




Interfacing Soil Moisture & Temperature Sensor with Arduino

Now lets interface the Soil Humidity & Temperature Sensor with Arduino & start measuring the Soil Moisture and Temperature.

Here is the schematic for the project.

RS485 Soil Moisture & Temperature Sensor Arduino

The Soil Sensor communicates with a Microcontroller using RS485 protocol. Hence we used MAX485 Module for this project. The MAX485 is a popular RS-485 transceiver chip commonly used for serial communication. When interfacing the MAX485 with an Arduino, you’ll typically be dealing with half-duplex communication, where data transmission and reception occur at different times.

Here is a connection mapping between MAX485 & Arduino.

  • VCC (MAX485) -> 5V (Arduino)
  • GND (MAX485) -> GND (Arduino)
  • RO (MAX485) -> 2 (Digital Pin of Arduino)
  • DI (MAX485) -> 3 (Digital Pin of Arduino)
  • RE (MAX485) -> 8 (Digital Pin of Arduino)
  • DE (MAX485) -> 7 (Digital Pin of Arduino)

Soil Sensor Arduino

Here is a connection mapping between MAX485 & Soil Humidity Temperature Sensor.

  • VCC -> 5V (Soil Sensor)
  • GND  -> GND (Soil Sensor)
  • A (MAX485) -> Soil Sensor A Pin (Yellow Color)
  • B (MAX485) -> Soil Sensor B Pin (Blue Color)

Soil Humidity Temperature Sensor Connection with Arduino

You may use a breadboard for assembly and a jumper wires for connecting the sensor and RS485 Module with Arduino.


Source Code/Program for Reading Soil Moisture & Temperature

After assembling the sensor as per the circuit diagram above, lets move to the coding part of this project. According to the above table the inquiry frame for getting the Sensor reading hexadecimal is as follows:

1
0x01, 0x03, 0x00, 0x00, 0x00, 0x02, 0xC4, 0x0B

The sensor communicates at a baudrate of 4800. We have set the same parameter in the code to get the required reading.


Copy the following code and paste it on your Arduino IDE.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#include <SoftwareSerial.h>
#include <Adafruit_SSD1306.h>     // Include the Adafruit SSD1306 library to interact with the display
 
#define SCREEN_WIDTH 128          // Set the width and height of the display in pixels
#define SCREEN_HEIGHT 64
#define OLED_RESET -1             // Set the OLED reset pin to -1 if it shares the Arduino reset pin
#define SCREEN_ADDRESS 0x3C       // Set the address of the screen as specified in its datasheet
 
// Create an Adafruit_SSD1306 object called display
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
 
// Define the pins for RS485 communication
#define RE 8
#define DE 7
 
// Request frame for the soil sensor
const byte soilSensorRequest[] = {0x01, 0x03, 0x00, 0x00, 0x00, 0x02, 0xC4, 0x0B};
byte soilSensorResponse[9];
SoftwareSerial mod(2, 3); // Software serial for RS485 communication
 
 
void setup()
{
  Serial.begin(9600); // Initialize serial communication for debugging
  mod.begin(4800);    // Initialize software serial communication at 4800 baud rate
  pinMode(RE, OUTPUT); // Set RE pin as output
  pinMode(DE, OUTPUT); // Set DE pin as output
  // Start the display, looping forever if it fails
  if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
    Serial.println(F("SSD1306 allocation failed"));
    for (;;);
  }
 
  display.clearDisplay();     // Clear the display and display the cleared screen
  display.display();
  delay(500);
}
 
 
void loop()
{
  // Start the transmission mode for RS485
  digitalWrite(DE, HIGH);
  digitalWrite(RE, HIGH);
  delay(10);
 
  // Send the request frame to the soil sensor
  mod.write(soilSensorRequest, sizeof(soilSensorRequest));
 
  // End the transmission mode and set to receive mode for RS485
  digitalWrite(DE, LOW);
  digitalWrite(RE, LOW);
  delay(10);
 
  // Wait for the response from the sensor or timeout after 1 second
  unsigned long startTime = millis();
  while (mod.available() < 9 && millis() - startTime < 1000)
  {
    delay(1);
  }
 
  if (mod.available() >= 9) // If valid response received
  {
    // Read the response from the sensor
    byte index = 0;
    while (mod.available() && index < 9)
    {
      soilSensorResponse[index] = mod.read();
      Serial.print(soilSensorResponse[index], HEX); // Print the received byte in HEX format
      Serial.print(" ");
      index++;
    }
    Serial.println();
 
    // Parse and calculate the Moisture value
    int Moisture_Int = int(soilSensorResponse[3] << 8 | soilSensorResponse[4]);
    float Moisture_Percent = Moisture_Int / 10.0;
 
    Serial.print("Moisture: ");
    Serial.print(Moisture_Percent);
    Serial.println(" %RH");
 
 
 
    // Parse and calculate the Temperature value
    int Temperature_Int = int(soilSensorResponse[5] << 8 | soilSensorResponse[6]);
    float Temperature_Celsius = Temperature_Int / 10.0;
 
    // Check if temperature is negative and convert accordingly
    if (Temperature_Int > 0x7FFF)
    {
      Temperature_Celsius = 0x10000 - Temperature_Int;
      Temperature_Celsius = -Temperature_Celsius / 10.0;
    }
 
    Serial.print("Temperature: ");
    Serial.print(Temperature_Celsius);
    Serial.println(" °C");
 
    // Clear the display and set the text color
    display.clearDisplay();
    display.setTextColor(SSD1306_WHITE);
    
    display.setTextSize(1);
    display.setCursor(25, 0);
    display.print("Soil Moisture");
    
    display.setTextSize(2);
    display.setCursor(30, 12);
    display.print(Moisture_Percent);
    display.setTextSize(1);
    display.print("% ");
 
    display.setTextSize(1);
    display.setCursor(30, 35);
    display.print("Temperature");
 
    display.setTextSize(2);
    display.setCursor(30, 47);
    display.print(Temperature_Celsius);
    display.setTextSize(1);
    display.print("*C");
    display.display();
 
 
  }
  else
  {
    // Print error message if no valid response received
    Serial.println("Sensor timeout or incomplete frame");
    display.clearDisplay();
    display.setTextColor(SSD1306_WHITE);
    display.setTextSize(1);
 
    display.setCursor(0, 0);
    display.print("Sensor timeout");
    display.display();
  }
 
  delay(1000); // Wait for a second before the next loop iteration
}


Testing & Results

After uploading the code, the setup is ready for test. The OLED will immediately display the temperature and Soil Moisture Value.

The OLED Display shows room temperature value as some number, which is correct. For the Soil Moisture part, the Soil Moisture appears as zero. This is because the Sensor is kept in dry air.



To get the readings of soil moisture, dip the metallic part of the sensor in Soil.

When the water content in the Soil is increased, there is rise in Soil Moisture Value displayed on OLED Screen.

For field and practical testing, you can dip the Sensor in the Soil.

This is how you can use the Soil Humidity and Temperature Sensor with Arduino to read the Soil Moisture & Temperature Value.


Video Tutorial & Guide

RS485 Soil Moisture & Temperature Sensor In-Depth Tutorial with Arduino
Watch this video on YouTube.


Conclusion

In conclusion, the guide provided a comprehensive overview of interfacing the Renkeer Soil Moisture & Temperature Sensor with Arduino through the RS485 protocol. This combination offers a powerful tool for real-time monitoring of soil conditions, essential for effective agriculture and gardening. With its impressive accuracy and range, the sensor is especially suitable for remote areas, thanks to its low power consumption.

Displaying the data on an OLED screen ensures clear visibility of readings, paving the way for improved crop management and efficient water usage. This system is not only technologically advanced but also a significant step towards sustainable farming practices.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleThe Best 60W Electric Soldering Iron Station – Test & Review
Next Article DIY 5V 3A USB Charger for Car or Solar Panel (4-30V Input)

Related Posts

DC Energy Meter using Arduino

Build a DC Energy Meter using Arduino – 32V/5A

Updated:August 26, 20252K
Interfacing ADXL375 Accelerometer with Arduino

Interfacing ADXL375 Accelerometer with Arduino (±200g)

Updated:June 28, 2025
PZEM-004T Arduino Energy Meter

DIY AC Energy Meter using PZEM-004T & Arduino

Updated:March 6, 20258K
Interfacing BMI160 Accelerometer & Gyroscope with Arduino

Interfacing BMI160 Accelerometer & Gyroscope with Arduino

Updated:February 2, 20259K
Password Based Door Lock Security System Using Arduino & Keypad

Password Based Door Lock Security System Using Arduino & Keypad

Updated:February 2, 20252436K
Earthquake Detector Alarm with with Accelerometer & Arduino

Earthquake Detector Alarm with Accelerometer & Arduino

Updated:February 2, 2025661K
Add A Comment

CommentsCancel reply

Latest Posts
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

May 31, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

February 1, 2026
Top Posts & Pages
  • Buck Converter: Basics, Working, Design & Application
    Buck Converter: Basics, Working, Design & Application
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • How to use INA226 DC Current Sensor with Arduino
    How to use INA226 DC Current Sensor with Arduino
  • How to use Modbus RTU with ESP32 to read Sensor Data
    How to use Modbus RTU with ESP32 to read Sensor Data
  • Designing of MPPT Solar Charge Controller using Arduino
    Designing of MPPT Solar Charge Controller using Arduino
  • ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
    ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
  • IoT Based ECG Monitoring with AD8232 ECG Sensor & ESP32
    IoT Based ECG Monitoring with AD8232 ECG Sensor & ESP32
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (204)
    • ESP32 MicroPython (7)
    • ESP32 Projects (81)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.