7 in 1 Soil Sensor

Somsak Lima
9 min readOct 1, 2021

--

ใช้ PC ทดสอบ โดยใช้อุปกรณ์ตามภาพ

เชื่อมต่อด้วย Speed 4800,8,1,N เรียกใช้ QmodMaster แล้วตั้งค่าตามภาพ

หมายเหตุ โปรแกรม qmodmaster สามารถ Download ได้จาก https://sourceforge.net/projects/qmodmaster/

เมื่ออ่านค่าได้แล้ว ถ้าเปิด ฺBus Montor จะเห็นคำสั่งที่ส่งไป และส่งกลับมา

เช่น 01 03 00 00 00 09 85 CC

ตัวอย่างโปรแกรม MicroPython

#7 in 1 Soil Sensor
#https://github.com/techbase123/micropython-modbus
# Copyright M2M Use at Your Own Risk
from machine import UART
import time
from time import sleep
from uModBusSerial import uModBusSerial
modbus= uModBusSerial (1, baudrate=4800, pins=(32, 33))
slave_addr=0x01
starting_address=0x00
register_quantity=9
signed=True
register_value = modbus.read_holding_registers(slave_addr, starting_address, register_quantity, signed)
print(‘Holding register value: ‘ + ‘ ‘.join(‘{:d}’.format(x) for x in register_value))
print (‘Temp :’,register_value[1]/10,’ C’)
print (‘Moisture :’,register_value[0]/10,’ %’)
print (‘Conductivity :’,register_value[2],’ us/cm’)
print (‘PH :’,register_value[3]/10,’ PH’)
print (‘Nitrogen (N) :’,register_value[4],’ mg/kg,mg/L’)
print (‘Phosphorus (P) :’,register_value[5],’ mg/kg,mg/L’)
print (‘Potassium (K) :’,register_value[6],’ mg/kg,mg/L’)

คู่มือ Seven-in-1 soil Sensor

Chapter 1 Product Introduction
1.1 Product overview
1.2 Functions and features
1.3 Main parameters
1.4 System framework diagram
1.5 Product selection
Chapter 2 Hardware Connection
2.1 Inspection before equipment installation
Chapter 3 How to Use
3.1 Quick test method
3.2 Buried measurement method
3.3 Matters needing attention
Chapter 4 Configuration Software Installation and Use
4.1 Connect the sensor to the computer
4.2 Use of sensor monitoring software
Chapter 5 Communication Protocol
5.1 Basic communication parameters
5.2 Data frame format definition
5.3 Register address
5.4 Communication protocol example and explanation

Chapter 1 Product Introduction

1.1 Product overview

The transmitter has stable performance and high sensitivity,Fast response,
stable output, suitable for various Earthy. It is an important tool for observing
and studying the occurrence, evolution, improvement and water and salt
dynamics of saline soil. By measuring the dielectric constant of the soil,can
directly and stably reflect the truth of various soils Moisture content. Can
measure soil moisture. The volume percentage is a soil moisture measurement method that meets the current international standards. Can be buried in the soil for a long time, resistant to long-term electrolysis, corrosion,
resistance, vacuum potting, completely waterproof.

The transmitter is suitable for soil moisture monitoring, scientific
experiments, water-saving irrigation, greenhouses, flowers and vegetables,
grassland pastures, soil rapid testing, plant cultivation, sewage treatment,
precision agriculture and other occasions for temperature and humidity,
electrical conductivity, PH value testing .

1.2 Functions and features
1.Integrate 7 items of soil moisture, conductivity, temperature, nitrogen,
phosphorus and potassium, and pH value into one.
2.Low threshold, few steps, fast measurement speed, no reagents, and
unlimited detection time.
3.The electrode is made of specially treated alloy material, which can withstand strong external shocks and is not easy to damage.4.Completely sealed, resistant to acid and alkali corrosion, and can be buried insoil or directly in water for long-term dynamic testing.
5.High precision, fast response, good interchangeability, probe insertion design can ensure accurate measurement and reliable performance.
6.It can also be used for the conductivity of integrated water and fertilizer
solutions and other nutrient solutions and substrates.
7.High pH measurement accuracy, accuracy up to ±0.3PH, fast response
speed and good interchangeability

This product can also be used in combination of multiple sensors on a 485
bus. In theory, a bus can be used for 254 485 sensors, and the other end is
connected to a PLC with a 485 interface, connect the single-chip
microcomputer through the 485 interface chip, or use the USB to 485 to
connect to the computer, and use the sensor configuration tool provided by our company for configuration and testing.
(only one device can be connected when using the configuration software).

Chapter 2 Hardware Connection

2.1 Inspection before equipment installation
Equipment List:
1.Transmitter equipment 1 set
2.Certificate of conformity, wiring instructions, etc.
3.USB to 485 (optional)2.2 Interface description
Wide-voltage power supply input can be 4.5~30V. When wiring the 485
signal line, pay attention to the two lines A/B not to be reversed, and the
addresses of multiple devices on the bus must not conflict.

Chapter 3 How to Use

Since the electrode directly measures the conductivity of the soluble salt
ions in the soil, the soil volumetric water content must be higher than about 20% when the soluble ions in the soil can accurately reflect the conductivity of the soil. In the long-term observation, the measured value after irrigation or rainfall is closer to the true level. If you are performing a quick test, you can water the soil to be tested first, and perform the measurement after the water is fully penetrated.

If you are measuring on a hard surface, you should drill holes first (the
hole diameter should be smaller than the diameter of the probe), then insert
the soil and compact the soil before measuring; the transmitter should be 7
protected from severe vibration and impact, let alone knocked with hard
objects hit. Because the transmitter is in a black package, the transmitter will
heat up rapidly (up to 50°C) under strong sunlight. In order to prevent
excessive temperature from affecting the temperature measurement of the
transmitter, please place it in the field or in the field. Pay attention to shading
and protection when using.
3.1 Quick test method
Select a suitable measurement location, avoid rocks, ensure that the steel
needle does not touch hard objects, throw away the surface soil according to
the required measurement depth, maintain the original tightness of the soil
below, hold the sensor vertically and insert it into the soil. Do not shake left and right. It is recommended to measure multiple times to find the average value within a small range of a measuring point.

3.2 Buried measurement method
Dig a pit with a diameter of >20cm vertically, insert the transmitter steel
needle horizontally into the pit wall at a predetermined depth, and fill the pit
tightly. After a period of stability, measurement and measurement can be
carried out continuously for several days, months or even longer. recording.

3.3 Matters needing attention
1. All steel needles must be inserted into the soil during measurement.
2. Avoid strong sunlight directly shining on the transmitter and cause the
temperature to be too high. Pay attention to lightning protection when using in the field.
3. Do not bend the steel needle violently, pull the lead wire of the
transmitter forcefully, and do not hit or hit the transmitter violently.
4. The transmitter’s protection level is IP68, and the transmitter can be
completely immersed in water.
5. Due to the presence of radio frequency electromagnetic radiation in the
air, it is not suitable to stay in the air for a long time with electricity.

Chapter 4 Configuration Software Installation and Use

Our company provides the supporting “485 parameter configuration
software”, which can conveniently use the computer to read the parameters of
the sensor, and at the same time flexibly modify the device ID and address of
the sensor. Note that you need to ensure that there is only one sensor on the 485 bus when using the software to obtain it automatically.
4.1 Connect the sensor to the computer
After connecting the sensor to the computer through USB to 485 and 9
supplying power, you can see the correct COM port in the computer (check the COM port in “My Computer — Properties — Device Manager — Port”).

Open the data package, select “Debugging Software” — — “485 Parameter
Configuration Software”, find and open it.
If the COM port is not found in the device manager, it means that you have
not installed the USB to 485 driver (included in the data package) or the driver has not been installed correctly, please contact a technician for help.
4.2 Use of sensor monitoring software
1. The configuration interface is shown in the figure. First, obtain the
serial port number according to the method in chapter 3.1 and select the
correct serial port.
2. Click the test baud rate of the software, the software will test the baud
rate and address of the current device, the default baud rate is 4800bit/s, and
the default address is 0x01.
3. Modify the address and baud rate according to the needs of use, and
at the same time, you can query the current function status of the device.
4. If the test is unsuccessful, please recheck the equipment wiring and
485 driver installation.

Chapter 5 Communication Protocol

5.1 Basic communication parameters

5.2 Data frame format definition
Using 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
Error check = 16-bit CRC code
Time to end structure ≥ 4 bytes
Address code: the address of the transmitter,
which is unique in the communication network (factory default 0x01).
Function code: The command function instruction issued by the host,
this transmitter only uses function code 0x03 (read register data).
Data area: The data area is the specific communication data,
pay attention to the high byte of the 16bits data first!
CRC code: two-byte check code.
Host query frame structure:

Temperature calculation:
When the temperature is lower than 0 ℃, the temperature data is uploaded in
the form of complement code.
Temperature: FF9B H (hexadecimal) = -101 => temperature = -10.1℃
Moisture calculation:
Moisture: 292 H (hexadecimal) = 658 => Humidity = 65.8%, that is, the soil volumetric moisture content is 65.8%.
Conductivity calculation:
Conductivity: 3E8 H (hexadecimal) = 1000 Conductivity = 1000 us/cm
PH value calculation:
PH value: 38H (hexadecimal) = 56 => PH value = 5.6

Chapter 6 Common Problems and Solutions
No output or output error
possible reason:
1. The computer has a COM port, and the selected port is incorrect.
2. The baud rate is wrong.
3. The 485 bus is disconnected, or the A and B wires are reversed.
4. If the number of equipment is too much or the wiring is too long, power
supply should be nearby, add 485 booster, and add 120Ω terminal resistance.
5. The USB to 485 driver is not installed or damaged.
6. Equipment damage.

การตั้งค่า Baud Rate หรือ Device Address (Slave Address)

ถ้าเราต่ออุปกรณ์ RS485 หลายตัวบน Bus เดียวกัน (ใช้ได้ถึง 32 ตัว) จะต้องตั้งค่า Sensor แต่ละตัวให้มี Slave Address ต่างกัน ต้องใช้โปรแกรม RS485Control

โหลดโปรแกรม RS485ControlV21.exe ได้จาก คลิก

--

--

Somsak Lima
Somsak Lima

Written by Somsak Lima

สนับสนุนและส่งเสริมให้ผู้สนใจสามารถใช้งานเทคโนโลยี LoRa และ LoRaWAN ได้ โดยนำความรู้ที่ได้ไปต่อยอดเพื่อใช้งาน

No responses yet