7-in-1 Soil Condition Sensor

7-in-1 Soil condition Sensor

Some commentary on the subject would seem to suggest that the validity, or at least accuracy, of measurements made with this type of sensor are questionable. The exercise here is nonetheless more one of establishing the requirements for communications with an RS485 sensor than anything to do with the sensor itself or the measurements it reports.

To date, I have used the manual for a similar sensor, retrieved from the ComWinTop website, as a guide in forumlating the necessary Modbus RTU queries.

Testing Notes
  • The sensor specifications indicate that it will operate with a supply voltage of 4.5~30V. In the event, it responded to Modbus RTU queries reliably and reported plausible ambient temperature readings—other readings are a bit meaningless in a 'bench testing' environment—on a 5V supply from the [USB powered] CubeCell Plus.
  • Supplied with a default baud rate setting of 4800 but could be reset to 9600 using the relevant Modbus RTU command.
  • Responds to a Modbus RTU broadcast address of 0xFF (0x00 is not recognised as a valid address—i.e. queries to that address do not elicit any response).
  • As supplied, when queried this sensor reports a Slave ID of 1. It also accepted a query to change this [to a Slave ID of 2] and subsequent queries reflected this change. It will respond to queries directed either to its current Slave ID or the broadcast address. Note that this, what I would consider the expected or correct behaviour, contrasts with the behaviour of the other RS485 sensors I have tested.

CubeCell Plus RS485 7-in-1 Soil Condition Sensor Hardware Configuration

7-in-1 Soil Condition Sensor [RS485] Configuration Circuit
Pin Configuration
CubeCell Plus UART-to-RS485 7-in-1 Probe
GND GND
UART_TX2 Tx
UART_RX2 Rx
Vext Vcc
Vin Brown
A+ Yellow
B- Blue
Sig-GND Black

Note that the colours of the RS485 wires on various probes that I have tested have all been different so it is important to verify which wire is which on any given probe and not rely on any idea of standardised colouring of wires.

Software

Use the following as the basis for an interactive sketch that allows the user to select the command to send and then reports the result.


RS485 Soil Condition Sensor Test Sketch
#include <softSerial.h>

/*
   A simple sketch to test RS485 communications with Modbus RTU sensors.
   It uses SoftwareSerial, and assumes that we have a TTL-to-RS485 adaptor connected
   to the second CubeCell Dev-Board Plus UART (UART_TX2/UART_RX2) and the sensor under
   test.
*/

// Define baud rate as appropriate
// 7-in-1 Soil Condition          4800 (default)
// SHT30 Temperature & Humidity   9600 (default)
// QDY30A Water Level             9600 (default)

#define RS485BaudRate 9600

int counter = 0;
String receiveString, sendString;

// The following are valid query strings for the listed sensors. Remove the comment prefix
// from the query that is to be sent. For more detail, refer to the pages for individual
// sensors.

// 7-in-1 Soil Condition
byte queryData[]{ 0xFF, 0x03, 0x07, 0xD0, 0x00, 0x01, 0x91, 0x59 }; // Broadcast Enquire Slave ID
//byte queryData[]{ 0x01, 0x06, 0x07, 0xD0, 0x00, 0x02, 0x08, 0x86 }; // Set Slave ID to 2
//byte queryData[]{ 0x01, 0x06, 0x07, 0xD1, 0x00, 0x02, 0x59, 0x46 }; // Set Baud to 9600

// SHT30 Temperature & Humidity
//byte queryData[]{ 0x00, 0x03, 0x07, 0xD0, 0x00, 0x01, 0x85, 0x56 }; // Broadcast Enquire Slave ID

// QDY30A Water Level
//byte queryData[]{ 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x85, 0xDB }; // Broadcast Enquire Slave ID

byte receivedData[20];  // Size set as required by individual sensors

// Define the serial entity for connection to the RS485 adaptor

softSerial RS485(UART_TX2, UART_RX2);

void setup() {

  // Supply power to the RS485 adaptor

  pinMode(Vext, OUTPUT);
  digitalWrite(Vext, LOW);
 
  // Open the serial ports

  Serial.begin(115200);        // To the Serial Monitor
  RS485.begin(RS485BaudRate);  // To the RS485 bus
  delay(500);

  Serial.println("[setup] CubeCell Plus RS485 Sensor Test");
}

void loop() {

  // Send the query...
  // Note that a Set query (e.g. baud rate or Slave ID) may result in loss of
  // communication until sketch RS485BaudRate or query strings are adjusted to match
  
  Serial.println("[loop] Sending query...");
  RS485.write(queryData, sizeof(queryData));
  
  delay(500);  // Will need to wait a little before checking for a response...
  
  // Check if we've received anything...
  
  if ( RS485.available() > 0 ) {
  
    // Report anything we receive on the RS485 bus
    
    RS485.readBytes(receivedData, sizeof(receivedData));
    Serial.print("[loop] Received Data : ");
    for ( int i = 0; i <= sizeof(receivedData); i++ ) {
      Serial.print("0x");
      Serial.print(receivedData[i],HEX);
      if ( i < sizeof(receivedData) ) {
        Serial.print(", ");
      }
    }
    Serial.println();

  } else {
    Serial.println("[loop] No response...");
  }
  delay(5000);
}

Further details pending

03-09-2026