Traditional Chinese Medicine Drip Irrigation System: Technology Empowerment for Precise Irrigation

Water management is crucial in the cultivation of traditional Chinese medicinal herbs. Today, we will explore an innovative drip irrigation system for these herbs, examining how its clever design achieves precise irrigation and supports the healthy growth of medicinal plants.

1. Exploring the System Architecture

(1) Overall Architecture

The overall architecture of this drip irrigation system resembles a precisely coordinated network, with each component working closely together. The Mega2560 is responsible for collecting light intensity (BH1750) and soil temperature (DS18B20), acting as a keen observer that constantly monitors changes in light and soil temperature. The data is then transmitted to the Arduino Uno, which not only collects air temperature and humidity (DHT11) and soil moisture (YL-69) but also controls the relay and uploads data via the YED-S710 gateway. Finally, the data converges on the OneNET platform, where it is displayed, allowing us to easily view it through a mobile app and send control commands for remote control of the pump.

mermaid

graph LR

A[Mega2560] –>|Collects light/soil temperature| B[Arduino Uno]

B –>|Uploads via 4G gateway| C{OneNET Platform}

C –>|Data display| D[Mobile App]

D –>|Control commands| C

C –>|Issues commands| B

B –>|Controls relay| E[Water Pump]

(2) Hardware Responsibilities

Each hardware component has a clear role: the Mega2560 focuses on collecting light and soil temperature; the Arduino Uno takes on the responsibilities of collecting air temperature and humidity, soil moisture, controlling the relay, and uploading data; smooth data interaction between the two boards is achieved through the TX3/RX3 serial port.

2. Revealing Hardware Connections

Hardware connections are the foundation for the stable operation of the system. The key connection verification table is as follows:

Table

Device Connection Pins Function Verification Method

YED-S710 Gateway Mega2560 RX0/TX1 Send AT command and check response

Relay Module Uno D8 Serial send HIGH/LOW test

DHT11 Uno D2 Read temperature and humidity values

YL-69 Soil Moisture Uno A0 Analog value range detection (dry 300-600, wet 0-300)

BH1750 Mega2560 SDA(20)/SCL(21) I2C address scan (0x23)

DS18B20 Mega2560 D2 Read temperature value (-55°C ~ +125°C)

3. OneNET Platform Configuration Guide

(1) Creating Products and Devices

1. Log in to the OneNET platform.

2. Create a product named “Traditional Chinese Medicine Drip Irrigation System”, selecting the protocol as “MQTT Legacy” and the connection method as “Cellular”.

3. Add devices, recording the device ID and API Key, which are crucial credentials for communication between the device and the platform.

(2) Defining Data Streams

Defining data streams allows the platform to accurately recognize the meaning of the data.

json

{

“data_streams”: [

{“id”:”soil_hum”, “name”:”Soil Moisture”, “unit”:”%”},

{“id”:”air_temp”, “name”:”Air Temperature”, “unit”:”℃”},

{“id”:”soil_temp”, “name”:”Soil Temperature”, “unit”:”℃”},

{“id”:”light”, “name”:”Light Intensity”, “unit”:”lx”},

{“id”:”pump_sta”, “name”:”Pump Status”, “unit”:”bool”}

]

}

(3) Creating Mobile Control Interface

In application development, create a new application, adding real-time data cards, historical curves, and a switch button (labeled “Irrigation Switch”), allowing us to easily control irrigation from our mobile devices.

4. Analyzing Arduino Code Implementation

(1) Mega2560 Code

The Mega2560 is primarily responsible for sensor data collection and communication.

arduino

#include <Wire.h>

#include <BH1750.h>

#include <OneWire.h>

#include <DallasTemperature.h>

#define ONE_WIRE_BUS 2

BH1750 lightMeter;

OneWire oneWire(ONE_WIRE_BUS);

DallasTemperature sensors(&oneWire);

void setup() {

Serial1.begin(9600); // Communication with the gateway

Serial3.begin(9600); // Communication with Uno

Wire.begin();

lightMeter.begin();

sensors.begin();

}

void loop() {

// Collect data

sensors.requestTemperatures();

float soilTemp = sensors.getTempCByIndex(0);

float light = lightMeter.readLightLevel();

// Package data and send to Uno

Serial3.print(“DATA,”);

Serial3.print(soilTemp);

Serial3.print(“,”);

Serial3.println(light);

delay(5000); // 5 seconds data collection cycle

}

(2) Arduino Uno Code

The Arduino Uno serves as the core for control and cloud communication, with a more complex code implementation.

arduino

#include <SoftwareSerial.h>

#include <DHT.h>

#define DHTPIN 2

#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);

SoftwareSerial megaSerial(10, 11); // RX=10, TX=11 (connected to Mega2560 TX3/RX3)

// OneNET parameters

const String deviceID = “Your_Device_ID”;

const String apiKey = “Your_API_Key”;

bool pumpStatus = false;

void setup() {

Serial.begin(115200); // Communication with the gateway

megaSerial.begin(9600); // Communication with Mega

pinMode(8, OUTPUT);

dht.begin();

initGPRS();

}

void loop() {

// Local sensor data collection

float airTemp = dht.readTemperature();

float airHumidity = dht.readHumidity();

int soilHum = analogRead(A0);

// Receive data from Mega

if(megaSerial.available()){

String data = megaSerial.readStringUntil(‘\n’);

if(data.startsWith(“DATA,”)){

int idx1 = data.indexOf(‘,’,5);

float soilTemp = data.substring(5, idx1).toFloat();

float light = data.substring(idx1+1).toFloat();

// Data upload

String json = “{“

“soil_hum:” + String(map(soilHum,300,600,0,100)) + “,” // Humidity calibration

“air_temp:” + String(airTemp) + “,”

“soil_temp:” + String(soilTemp) + “,”

“light:” + String(light) + “,”

“pump_sta:” + String(pumpStatus) +

“}”;

sendToCloud(json);

}

}

checkCloudCommand();

delay(30000); // 30 seconds upload interval

}

void initGPRS() {

Serial.println(“AT+CFUN=1”); // Enable full functionality mode

delay(2000);

Serial.println(“AT+CGATT=1”); // Attach to GPRS network

delay(5000);

Serial.println(“AT+CSTT=\”CMNET\””); // Set APN

delay(2000);

Serial.println(“AT+CIICR”); // Activate mobile scenario

delay(5000);

}

void sendToCloud(String data) {

Serial.println(“AT+CIPSTART=\”TCP\”,\”183.230.40.33\”,8743″);

delay(3000);

String cmd = “POST /devices/” + deviceID + “/datapoints HTTP/1.1\r\n”

“api-key:” + apiKey + “\r\n”

“Host:api.heclouds.com\r\n”

“Content-Length:” + String(data.length()) + “\r\n\r\n”

+ data;

Serial.print(“AT+CIPSEND=”);

Serial.println(cmd.length());

delay(500);

Serial.print(cmd);

delay(2000);

Serial.println(“AT+CIPCLOSE”);

}

void checkCloudCommand() {

while(Serial.available()){

String resp = Serial.readString();

if(resp.indexOf(“pump_switch=1”) != -1){

digitalWrite(8, HIGH);

pumpStatus = true;

} else if(resp.indexOf(“pump_switch=0”) != -1){

digitalWrite(8, LOW);

pumpStatus = false;

}

}

}

5. Full Process of Deployment and Debugging

(1) Hardware Deployment

1. Sensor Installation: The DS18B20 and YL-69 should be inserted 15cm deep into the root zone of the crops, the BH1750 should be installed 1.5 meters above the ground under a sunshade, and the DHT11 should be placed at a height of 50cm above the plant canopy, ensuring that the sensors are positioned to accurately perceive the environment.

2. Pipeline Layout:

mermaid

graph LR

A[Water Pump] –> B[Φ8mm Main Pipe] –> C[Mesh Filter] –> D[Φ4mm Drip Tube] –> E[Drip Arrow]

(2) System Debugging

1. Communication Test: In the Arduino IDE serial monitor, input AT+CSQ to check signal strength, with a normal value greater than 10; send AT+PING=”www.baidu.com” to test network connectivity, ensuring smooth communication.

2. Calibration Settings: Adjust the soil moisture calibration parameters based on actual measured values to ensure data accuracy.

arduino

// Soil moisture calibration (adjust based on actual measured values)

int dryValue = 600; // Analog value when completely dry

int wetValue = 300; // Analog value when completely wet

int soilHumidity = map(analogRead(A0), dryValue, wetValue, 0, 100);

(3) Farmer Training

1. Mobile App Operation: Open the OneNET App, select the device to view real-time data, and click the “Irrigation Switch” button to control irrigation.

2. Emergency Handling: Press the red emergency stop button on the control box if any abnormalities are detected.

6. System Optimization and Expansion Directions

(1) Local Data Storage (SD Card Expansion)

Add a MicroSD module (connected to Uno’s D4 pin) to achieve local data storage through the following code.

arduino

#include <SPI.h>

#include <SD.h>

const int chipSelect = 4;

void saveData(String data) {

File dataFile = SD.open(“datalog.txt”, FILE_WRITE);

if(dataFile){

dataFile.println(data);

dataFile.close();

}

}

(2) Intelligent Irrigation Algorithm

Implement dynamic threshold adjustments through an intelligent irrigation algorithm to make irrigation smarter.

arduino

void smartControl(float soilHum, float airTemp) {

// Dynamic threshold adjustment (for every 1℃ increase in temperature, threshold decreases by 2%)

float dynamicThreshold = 40 – (airTemp – 25) * 2;

if(soilHum < dynamicThreshold) {

digitalWrite(8, HIGH);

delay(3000); // Irrigate for 3 seconds

digitalWrite(8, LOW);

}

}

7. Usage Precautions

1. Lightning Protection Design: Connect a TVS diode (SMBJ12CA) in parallel at the power input to ensure system safety.

2. Winter Maintenance: Drain water from the pipes before winter, and place silica gel desiccant inside the control box to prevent equipment damage.

3. Regular Calibration: Conduct on-site calibration of sensors every quarter to ensure data accuracy.

This traditional Chinese medicine drip irrigation system has shown significant results in the planting base of mugwort in Qichun, Hubei, achieving a water-saving efficiency of 48%-52%, with an average response delay of 2.3 seconds under 4G networks, and a daily power consumption of ≤0.5kWh per mu. It is recommended to initially deploy 3-5 mu of experimental fields, evaluate the results after a complete growth cycle (approximately 4 months), and subsequently expand to include fertility sensors for integrated water and fertilizer intelligent control.

Technology empowers agriculture; isn’t this traditional Chinese medicine drip irrigation system impressive? If you are interested in agricultural technology, feel free to share and explore more agricultural innovation technologies together!

Leave a Comment